java - Don't copy parent pom when copying child modules -


i want exclude parent pom (where following code located) being copied when package:copy goal executed , can't find examples or figure out on own:

<plugin>     <groupid>org.apache.maven.plugins</groupid>     <artifactid>maven-dependency-plugin</artifactid>     <version>2.10</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>${project.packaging}</type>                         <classifier>shaded</classifier>                         <destfilename>${project.name}.${project.packaging}</destfilename>                         <excludes>*.pom</excludes> <!-- not working -->                     </artifactitem>                 </artifactitems>                 <outputdirectory>${rootdir}/target/modules</outputdirectory>                 <silent>true</silent>                 <overwritereleases>true</overwritereleases>                 <overwritesnapshots>true</overwritesnapshots>             </configuration>         </execution>     </executions> </plugin> 

regardless of <excludes> setting inside artifactitem, still includes parent projects niftyparent.pom. want exclude file being copies ${rootdir}/target/modules directory.

incase asks, ${rootdir} property points parent project directory without hardcoding relative/absolute paths (for sake of argument ~/workspace/nifty.

you use skip configuration element of plugin maven property defined in parent , modules in order skip execution.

in parent pom can configure following:

<properties>     <skip-dependency-copy>true</skip-dependency-copy> </properties>  <build>     <plugins>         <plugin>             <groupid>org.apache.maven.plugins</groupid>             <artifactid>maven-dependency-plugin</artifactid>             <version>2.10</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>${project.packaging}</type>                                 <classifier>shaded</classifier>                                 <destfilename>${project.name}.${project.packaging}</destfilename>                             </artifactitem>                         </artifactitems>                         <outputdirectory>${rootdir}/target/modules</outputdirectory>                         <silent>false</silent>                         <overwritereleases>true</overwritereleases>                         <overwritesnapshots>true</overwritesnapshots>                         <skip>${skip-dependency-copy}</skip>                     </configuration>                 </execution>             </executions>         </plugin>     </plugins> </build> 

note additional property , skip element configuration.

then, in each module configure following:

<properties>     <skip-dependency-copy>false</skip-dependency-copy> </properties> 

as such, switching on/off based on parent/module location. additional advantage of approach able skip modules (if required) , able switch on/off (in case off) command line (overriding defined properties values) via instance:

mvn package -dskip-dependency-copy=true 

this approach not using plugin configuration, it's used whenever skip required in many other plugins , cases.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -