user2269774
user2269774

Reputation: 283

Can I remove the 'jar' task in gradle build?

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???

Upvotes: 9

Views: 12644

Answers (3)

Thami Bouchnafa
Thami Bouchnafa

Reputation: 2167

In build.gradle.kts file:

tasks.withType<Jar>  {
    enabled = false
}

Upvotes: 1

kashisrini
kashisrini

Reputation: 1

This worked for me:

configurations.archives.with {
    artifacts.remove artifacts.find { it.toString().contains("jar") }
}

Upvotes: 0

Crazyjavahacking
Crazyjavahacking

Reputation: 9707

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

Upvotes: 20

Related Questions