Scripts

The Simplest Case

The following configuration will generate a windows (.bat) and unix shell script in the bin folder of the ${project.build.directory}/appassembler sub folder.

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>appassembler-maven-plugin</artifactId>
        <version>1.10</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>assemble</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <programs>
            <program>
              <mainClass>com.mycompany.app.App</mainClass>
              <id>app</id>
            </program>
          </programs>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

In the following examples we will show only the configuration block, cause the rest will be always the same.

Generate Multiple Scripts

Suppose you have created two classes which have a main you need to create two scripts. This can simply achieved by using the following configuration. There is no limitation how many scrips you can generate through a configuration like this.

<project>
  ...
  <build>
    <plugins>
        ...
        <configuration>
          <programs>
            <program>
              <mainClass>com.mycompany.app.App</mainClass>
              <id>app</id>
            </program>
            <program>
              <mainClass>com.mycompany.app.App1</mainClass>
              <id>app1</id>
            </program>
            .
            .
          </programs>
        </configuration>
      </plugin>
      ...
    </plugins>
  </build>
</project>