How do I do the gradle build task to generate the shadow can _instead_ of the “regular” jar?

(using gradle 2.4)

For one of my projects, divided into several submodules, I use a shadow plugin that works very well for my needs; it has the main one and, as recommended by the README plugin, I use the application plugin in combination with it so that the Main-Class is generated in the manifest, everything works fine.

Now this is the SonarQube plugin project, and I also use (successfully!) The gradle plugin for sonar packaging . And what does this plugin do when you ./gradlew build generate a sonar plugin instead of a "regular" jar.

I want to do the same for my subproject here, except that I want it to generate only the shadow jar plugin instead of the "normal" plugin ... Right now I am creating both of these files:

 buildscript { repositories { jcenter(); } dependencies { classpath(group: "com.github.jengelman.gradle.plugins", name:"shadow", version:"1.2.1"); } } apply(plugin: "application"); apply(plugin: "com.github.johnrengelman.shadow"); dependencies { // whatever } mainClassName = //whatever artifacts { shadowJar; } // Here is the hack... build.dependsOn(shadowJar); 

How can I modify this file to create only a shadow jar, not a regular jar?

+6
source share
1 answer

You can disable the jar task by adding the following lines to the gradle script:

 // Disable the 'jar' task jar.enabled = false 

So when executing the gradle script it will show

: jar SKIPPED

If you want to configure all subprojects, you can add the following to your root build.gradle

 subprojects { // Disable the 'jar' task tasks.jar.enabled = false } 
+8
source

Source: https://habr.com/ru/post/987430/


All Articles