Friday, April 12, 2013

Maven - Copy Artifact in to a separate location

  • Create a Maven config file in the eclipse workspace.  maven_config.properties
  • Add the following key and value maven.output.build.path=/maven-dependency-plugin/target/test
  • Add the following two plugins to the Maven POM file.


   <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>properties-maven-plugin</artifactId>
    <version>1.0-alpha-2</version>
    <executions>
     <execution>
      <phase>initialize</phase>
      <goals>
       <goal>read-project-properties</goal>
      </goals>
      <configuration>
       <files>
        <file>../maven_config.properties</file>
       </files>
      </configuration>
     </execution>
    </executions>
   </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.7</version>
    <executions>
     <execution>
      <id>copy</id>
      <phase>package</phase>
      <goals>
       <goal>copy</goal>
      </goals>
      <configuration>
       <artifactItems>
        <artifactItem>
         <groupId>${project.groupId}</groupId>
         <artifactId>${project.artifactId}</artifactId>
         <version>${project.version}</version>
         <type>jar</type>
         <overWrite>true</overWrite>
         <outputDirectory>${maven.output.build.path}</outputDirectory>
        </artifactItem>
       </artifactItems>
      </configuration>
     </execution>
    </executions>
   </plugin>
  • Run the targets package or install

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.