简体   繁体   中英

maven-dependency-plugin <includes> tag doesn't work

The <includes> tag in the maven-dependency-plugin entry give below doesn't seem to work.

            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>unpack</id>
                    <phase>package</phase>
                    <goals>
                        <goal>unpack</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>org.test</groupId>
                                <artifactId>test-build-common</artifactId>
                                <version>${project.version}</version>
                                <classifier>others</classifier>
                                <type>tar</type>
                                <outputDirectory>target</outputDirectory>
                                <includes>**/common_test.sh</includes>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>

The contents of the test-others.tar retrieved by the above entry containts the following items

common/a.sh  
common/b.sh  
common/common_test.sh

I expect the only common/common_test.sh to be extracted to the target directory during build. However, all files are actually extracted to the target directory. Due to space constraints on the disc, unwanted files are not be extracted.

How can I properly pick only the required files to be extracted?

UPDATE: Seems this is bug is version 2.8. It works in version 2.10 of the plugin.

You have to use exclude as well because if you will see the documentation the includes says , (component code = return isIncluded( name ) AND !isExcluded( name );)

So use as well and that will work fine.

You can use the link below for your reference. https://maven.apache.org/plugins/maven-dependency-plugin/unpack-dependencies-mojo.html

Use version 2.10 or later of maven-dependency-plugin. Versions 2.8 and 2.9 do not process includes,excludes correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM