3

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.

Kiran Mohan
  • 2,696
  • 6
  • 36
  • 62

2 Answers2

0

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

Kulbhushan Singh
  • 627
  • 4
  • 20
  • I think you are wrong. There is no need to use exclude. Let's say there r 2 files A and B. Only entry in pom.xml is A. Work out the values for isIncluded( A ) AND !isExcluded( A ) isIncluded( B ) AND !isExcluded( B ) – Kiran Mohan Jul 14 '15 at 09:34
  • Ok. If i see your syntax you have given the file name in but it should be something like **/common_test.sh. – Kulbhushan Singh Jul 14 '15 at 10:42
0

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

cjackson
  • 1,637
  • 1
  • 13
  • 25