0

I have 2 projects dependency-project, main, support. Currently, main and support requires dependency-project in its build path.

We plan on adding support as another dependency for main. Is there a way to build a jar for support, but not include in it any dependency (from dependency-project) and when support-jar is already added into main, all dependencies of support-jar will be resolved via the classpath of main (since they both have dependency-project as dependency.

1 Answer 1

1

You can do it as a compile-time scope. For example in pom.xml file for support

<dependency> <groupId>org.something</groupId> <artifactId>dependency-project</artifactId> <version>1.2</version> <scope>compile</scope> </dependency> 

And then in pom.xml for main:

<dependency> <groupId>org.something</groupId> <artifactId>dependency-project</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>org.something</groupId> <artifactId>support</artifactId> <version>4.2</version> </dependency> 

This should solve your purpose.

Sign up to request clarification or add additional context in comments.

3 Comments

Would this be possible if main and dependency-project don't have maven configurations?
@Chad If they dont have maven-configuration then it depends on whatever build tool you are using. If nothing, then you can always do it manually (where you compile first with javac and then dont include jars while bundling)
But support will have project-dependency as a dependency. Can I build a jar for support without including project-dependency as a jar dependency, and maintaining it as a project dependency only at compile time?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.