4

I have a project where some of the dependencies have a secondary artifact that I would like to collect & unpack when making my distribution. By using the type and classifier parameters I was able to find these secondary artifacts, which is great.

The only problem is that the transitive dependency tree is quite large and most of the transitive dependencies do not have this secondary artifact, so the build is taking forever looking for things it will never find.

I would like to restrict the search to only certain groupIDs that could possibly have these secondary artifacts. It seems that the includeGroupIds parameter can not accept wildcards.

Is there any way to use wildcard filtering here, or will I have to live the maintenance chore of explicitly listing every group?

Here's an example of what I have now; note the long & hard to maintain list of included groups:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <executions>
    <execution>
      <id>unpack-litescale</id>
      <phase>prepare-package</phase>
      <goals>
        <goal>unpack-dependencies</goal>
      </goals>
      <configuration>
        <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
        <classifier>litescale</classifier>
        <type>zip</type>
        <includeGroupIds>com.foo.group1,com.foo.group2,com.foo.group3,com.foo.group4,com.foo.group5,com.foo.group6</includeGroupIds>
      </configuration>
    </execution>
  </executions>
</plugin>

Here's an example of what I want:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <executions>
    <execution>
      <id>unpack-litescale</id>
      <phase>prepare-package</phase>
      <goals>
        <goal>unpack-dependencies</goal>
      </goals>
      <configuration>
        <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
        <classifier>litescale</classifier>
        <type>zip</type>
        <includeGroupIds>com.foo.*</includeGroupIds>
      </configuration>
    </execution>
  </executions>
</plugin>
carej
  • 596
  • 1
  • 6
  • 18

2 Answers2

2

It seems that includeGroupIds includes all groupIds having the provided values as prefix. I.e. in your example <includeGroupIds>com.foo</includeGroupIds> should do:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <version>3.1.0</version>
  <executions>
    <execution>
      <id>unpack-litescale</id>
      <phase>prepare-package</phase>
      <goals>
        <goal>unpack-dependencies</goal>
      </goals>
      <configuration>
        <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
        <classifier>litescale</classifier>
        <type>zip</type>
        <includeGroupIds>com.foo</includeGroupIds>
      </configuration>
    </execution>
  </executions>
</plugin>
Joern
  • 1,926
  • 1
  • 13
  • 18
-1

That's not really possible with Maven in the way you're suggesting. Maven's declarative meaning you'll need to know what you want up-front. You could be a bit creative here by writing specific plugin which will do that. Also look at the Maven Assembly Plugin.

carej
  • 596
  • 1
  • 6
  • 18
KRK Owner
  • 762
  • 7
  • 16
  • 4
    Yes, I would like to **declare** that only groups that match a certain pattern should be included. I don't see how this is inconsistent with the Maven Way. – carej Oct 01 '13 at 14:43