Can I remove the 'jar' task in gradle build?
Asked Answered
A

3

9

When I use the code below, a file of jar will generate after gradle build.

apply plugin 'java'

Is there any settings won't generate the file of jar??

I can write a custom plugins,but the code below was wrong.

dependencies {
    compile project(':crm.common')
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

I want find a way that donot generate the file of jar. And can run compile in dependencies. Is there any way can do that???

Apraxia answered 23/10, 2016 at 11:58 Comment(0)
P
19

You can do that by 2 ways:

  1. explicitly exclude the jar task from execution: gradle build -x jar

  2. disable the jar task in build.gradle: apply plugin: 'java' jar.enabled = false

Pathy answered 23/10, 2016 at 22:5 Comment(2)
with the 2nd, how can I still be able to manually execute it singularly whenever I want? Launching gradlew jar I see > Task :jar SKIPPEDPyrogallate
@Pyrogallate in that case you'd need to remove the dependency from build to jar instead of disabling itSkean
B
0

This worked for me:

configurations.archives.with {
    artifacts.remove artifacts.find { it.toString().contains("jar") }
}
Boy answered 30/9, 2019 at 6:38 Comment(0)
H
0

In build.gradle.kts file:

tasks.withType<Jar>  {
    enabled = false
}
Highflier answered 13/8 at 8:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.