(this is using gradle 2.4)
For one of my projects, split into several submodules, I use the shadow plugin which works very well for my needs; it has a main, and as recommended by the plugin's README, I use the application plugin in conjuction with it so that the Main-Class is generated in the manifest, all works well.
Now, this is a SonarQube plugin project, and I also use (successfully!) the gradle sonar packagin plugin. And what this plugin does is, when you ./gradlew build
, generate the sonar plugin instead of the "regular" jar.
I wish to do the same for my subproject here, except that I want it to generate only the shadow jar plugin instead of the "regular" plugin... Right now I generate both using this simple file:
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 do I modify this file so that only the shadow jar is generated and not the regular jar?
Shadow is a plugin that packages an application into an executable fat jar file if the current file is outdated. Tutorials → Working with JAR files → Fat JAR files. The task shadowJar (e.g., running the command gradlew shadowJar or gradlew clean shadowJar ) creates the JAR file in the build/libs folder.
This is because of slow internet connection or you haven't configure proxy settings correctly. Gradle needs to download some dependencies , if it cant access the repository it fires this error. All you have to do is check your internet connection and make sure gradle can access the maven repository.
The Gradle build pulls all dependencies down from the Maven Central repository, as defined by the repositories block.
You could disable the jar task by adding the following lines to your gradle script:
// Disable the 'jar' task
jar.enabled = false
So, when executing the gradle script, it will show
:jar SKIPPED
If you wish to configure all sub-projects, then you can add the following into your root build.gradle
subprojects {
// Disable the 'jar' task
tasks.jar.enabled = false
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With