Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use wildcards to include/exclude a groupID from the maven dependency plugin's unpack-dependencies goal?

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>
like image 803
carej Avatar asked Oct 29 '25 16:10

carej


1 Answers

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>
like image 150
Joern Avatar answered Nov 01 '25 08:11

Joern



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!