简体   繁体   中英

Multimodule gradle build jar

I have a multi-module gradle build in intellij , where the parent ( java standalone httpclient ) project includes a utils project using :-

implementation project (project-name) inside dependencies{

When i run a gradle build, the jar that gets created in the build folder does not contain the classes / jar of the util project when i do a jar tvf <jarname>.jar

However, it is visible as a sub project in the gradle tool window -> task -> source sets in intellij.

One way i could get the subproject included in the parent jar was to publish it on nexus, include the snapshot and create a "jar" task. But since that deviates from the multi-module structure, it is not an acceptable solution.

Any pointers on getting the jar imported please?

PS :- The parent project is not a spring application so i cannot use the spring dependency management plugin.

Gradle will build by default a JAR that contains only the sources of the project itself. The project also provides metadata to know which dependencies it requires. This metadata can then be used when publishing to a Maven or Ivy repository to populate the relevant metadata file. That means consumers can then leverage that information to pull a dependency and its transitive dependencies.

What you are trying to achieve is different, since you want the dependencies to be embedded inside the JAR. You have different options for this:

What you exactly put in the JAR will depend on your specific use case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM