Alex Rivera | Logout

Is there any maven goal that is similar to 'dist'?

Asked 2010-11-22T13:41:24.463
9

I'm working on a project that used ant. I had a target dist that would basically do jar first, and then install the application into a directory.

This means, it would create directories like bin/, lib/ and config/ in the installation directory, and then copy the relevant files into each of these directories.

My question is two-fold:

  1. Is there any maven goal that does this kind of thing?
  2. If not, I want to do maven dist and make this happen. How would you suggest I accomplish this using Maven?
  3. If I can't have my own "target" (like dist), then what would be the best way?

Bottom line: I want to do all this, but don't want to alter the behavior of the default "targets" like compile and package etc.

Thanks, jrh

PS: I'm using maven version 2.2.21

Edit
Report

1 Answer

1

Seans answer is good and I almost went for it until I found out about the appassembler plugin http://mojo.codehaus.org/appassembler/appassembler-maven-plugin/.

See here for an example https://github.com/khmarbaise/maven-training/tree/master/502-assembly-plugin

It is called as part of the package lifecycle.

 <build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
      <source>1.6</source>
      <target>1.6</target>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>appassembler-maven-plugin</artifactId>
    <version>1.1</version>
    <executions>
      <execution>
        <phase>prepare-package</phase>
        <goals>
          <goal>assemble</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <binPrefix>utility</binPrefix>
      <assembleDirectory>${project.build.directory}/appassembler</assembleDirectory>
      <extraJvmArguments>-Xms512m -Xmx1024m</extraJvmArguments>
      <generateRepository>false</generateRepository>
      <repositoryName>lib</repositoryName>
      <repositoryLayout>flat</repositoryLayout>
      <includeConfigurationDirectoryInClasspath>true</includeConfigurationDirectoryInClasspath>
      <platforms>
        <platform>windows</platform>
        <platform>unix</platform>
      </platforms>
    
answered 2012-05-25T09:01:29.977

Your Answer