0

Can I exclude some artifacts from classpath that generates by <addClasspath>true</addClasspath> option?

For example, I have some dependencies:

<dependency>
  <groupId>com.group1</groupId>
  <artifactId>lib11</artifactId>
  <version>1.0</version>
</dependency>

<dependency>
  <groupId>com.group1</groupId>
  <artifactId>lib12</artifactId>
  <version>1.0</version>
</dependency>

<dependency>
  <groupId>com.group2</groupId>
  <artifactId>lib21</artifactId>
  <version>1.0</version>
</dependency>

At now, my classpath entry in MANIFEST.MF is:

Class-Path: lib/lib11.jar lib/lib12.jar lib/lib21.jar

I want exclude some groupIds of my dependencies list and take entry in this form:

Class-Path: lib/lib21.jar

How I can do it?

DaddyRatel
  • 729
  • 3
  • 13
  • 30
  • BTW: What do you use the `Class-Path` for? – J Fabian Meier Apr 05 '19 at 17:19
  • @JFMeier I use class-path to specify all used libraries and other app modules in my runnable jar. Some modules at production stage are located in another directory rather lib. I disabled copy this dependencies to lib directory and manual specified they in class-path. I want to delete from class-path entries like lib\lib11.jar because already define it manual with correct path like lib11.jar without prefix, for example. – DaddyRatel Apr 05 '19 at 17:45
  • Interesting ... I thought that nowadays people use fat jars. Or wars/ears in an Application server. – J Fabian Meier Apr 05 '19 at 17:47
  • @JFMeier It’s not a fat jar. All dependencies are located outside jar. And it’s a desktop javafx application. – DaddyRatel Apr 05 '19 at 17:49

1 Answers1

0

When adding a tag scope with a value provided to unnecessary dependencies, they disappear from classpath, as required. For an example from the question:

<dependency>
  <groupId>com.group1</groupId>
  <artifactId>lib11</artifactId>
  <version>1.0</version>
  <scope>provided</scope>
</dependency>

<dependency>
  <groupId>com.group1</groupId>
  <artifactId>lib12</artifactId>
  <version>1.0</version>
  <scope>provided</scope>
</dependency>
DaddyRatel
  • 729
  • 3
  • 13
  • 30