Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven appassembler plugin does not include the current artifact, if called iterative

[Update] The original question (below) is solved. I need to call

mvn package appassembler:assemble

instead of

mvn package
mvn appassembler:assemble

Question: Why is there a difference?

[Original]

I am trying to use the maven appassembler plugin to create a command line tool with all the dependencies assembled. It almost works but the artifact of the current module is missing. All dependent artifacts are copied to the repo and the classpath in the bat includes the current artifact. The configuration is as follows:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>appassembler-maven-plugin</artifactId>
            <configuration>
                <platforms>
                    <platform>windows</platform>
                    <platform>unix</platform>
                </platforms>
                <programs>
                    <program>
                        <mainClass>${mainclass}</mainClass>
                        <name>huffman</name>
                    </program>
                </programs>
            </configuration>
        </plugin>

Any ideas?

like image 801
openCage Avatar asked May 12 '11 16:05

openCage


1 Answers

The goal is not designed to run standalone, but as part of a lifecycle - therefore, it depends on the processes in place by the goals in package to return information to the project instance about what it has created. When you run that as two Maven commands, the information is lost.

Instead of either of these commands, you should be using something like:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>appassembler-maven-plugin</artifactId>
  <configuration>
   ... 
  </configuration>
  <executions>
    <execution>
      <id>assemble</id>
      <goals>
        <goal>assemble</goal>
      </goals>
    </execution>
  </executions>
</plugin>

This means that you then just need to run mvn package, and both steps will be run.

If your intent was to make the appassembler portion optional, you could instead put it in a profile with the same code as above.

like image 139
Brett Porter Avatar answered Nov 03 '22 10:11

Brett Porter