Search code examples
mavenmaven-assembly-plugin

maven artifact copy folder from bundle zip


Maven 3. I have following bundle zip artifact. there are resources inside the zip i want to unzip and copy those resources into project resource dir.

I created this artifact using maven-assembly-plugin

any help appreciated.

<dependency>
  <groupId>org.frb.ny.mg.spatt.commons</groupId>
  <artifactId>angular2-resources</artifactId>
  <version>1.0-SNAPSHOT</version>
  <classifier>bundle</classifier>
  <type>zip</type>
</dependency>

Solution

  • You can use the maven dependency unpack goal. For Eg:

    <project>
       [...]
       <build>
         <plugins>
           <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-dependency-plugin</artifactId>
             <version>2.10</version>
             <executions>
               <execution>
                 <id>unpack</id>
                 <phase>package</phase>
                 <goals>
                   <goal>unpack</goal>
                 </goals>
                 <configuration>
                   <artifactItems>
                     <artifactItem>
                       <groupId>junit</groupId>
                       <artifactId>junit</artifactId>
                       <version>3.8.1</version>
                       <type>zip</type>
                       <overWrite>false</overWrite>
                       <outputDirectory>${project.build.directory}/../src/main/reseources</outputDirectory>
                       <includes>**/*.class,**/*.xml</includes>
                       <excludes>**/*test.class</excludes>
                     </artifactItem>
                   </artifactItems>
                   <includes>**/*.java</includes>
                   <excludes>**/*.properties</excludes>
                   <outputDirectory>${project.build.directory}/wars</outputDirectory>
                   <overWriteReleases>false</overWriteReleases>
                   <overWriteSnapshots>true</overWriteSnapshots>
                 </configuration>
               </execution>
             </executions>
           </plugin>
         </plugins>
       </build>
       [...]
     </project>
    

    Please be advised that some of these configuration is optional. You can remove whatever you don't want.