chrisdchristo / capsule-maven-plugin

Capsule Maven Plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Should register artifacts for mvn install and mvn deploy or update documentation

tngmech opened this issue · comments

When following the documentation https://github.com/chrischristo/capsule-maven-plugin to include the plugin during builds the plugin creates e.g. the capsule-fat.jar into the target folder as expected. However the e.g. capsule-fat.jar artifact will not be installed to the local .m2 maven repo with mvn install nor will it be uploaded to e.g. Nexus during mvn deploy.
Other plugins like maven-assembly seem to register their e.g. jar-with-dependencies.jar artifact automatically. For capsule one can make things work when adding the following to the pom.xml:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <version>1.7</version>
  <executions>
    <execution>
      <id>attach-artifacts</id>
      <phase>package</phase>
      <goals>
        <goal>attach-artifact</goal>
      </goals>
      <configuration>
        <artifacts>
          <artifact>
            <file>${project.build.directory}/${project.artifactId}-${project.version}-capsule-fat.jar</file>
            <type>jar</type>
            <classifier>capsule-fat</classifier>
          </artifact>
        </artifacts>
      </configuration>
    </execution>
  </executions>
</plugin>

It would be great to either have the artifacts registered automatically thru the capsule plugin or add this snippet to the documentation to relief other users from searching stackoverflow.

Moved from puniverse/capsule-maven#6 - may close the duplicate.

Ok good idea, with 0.10.5, you can just add <goal>install</goal> and it will install as desired. See here and here. I replicated what the attach-artifact goal (above) does.

I reviewed the changes. Don't you think it's better to use the MavenProjectHelper.attachArtifact(...) method to announce the generated JARs to Maven? This way Maven handles "install" and "deploy" automatically and we could add a classifier like "capsule-fat" or "with-dependencies".

Edit: The version 0.10.5 installs the fat jar when the "install" goal is used, but "deploy" still does not work.

Ah sigh wish I had known about that method. Will update for 0.10.6. For now 0.10.5 supports install only.

verified: 0.10.6 installs and deploys the artifact as expected.

      <plugin>
        <groupId>com.github.chrischristo</groupId>
        <artifactId>capsule-maven-plugin</artifactId>
        <version>${capsule.maven.plugin.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>build</goal>
            </goals>
            <configuration>
              <types>fat</types>
              <appClass>simulator.SimulatorCli</appClass>
            </configuration>
          </execution>
        </executions>
      </plugin>

Great! will close :)