How to exclude a jar from gradle

sunleo :

I try to exclude a jar from gradle build but how to do that for my project part I am not clear.Below are the dependencies I have to exclude only geronimo-javamail_1.4_spec/1.7.1 jar because which gives error when I try to send mail.Please give your guidance to solve this.

    dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-batch")
    //compile("org.springframework.boot:spring-boot-devtools")
    compile('org.apache.commons':'commons-lang3':'3.5'){
                exclude module: 'geronimo'
    }
    compile group: 'org.apache.cxf', name: 'cxf-spring-boot-starter-jaxws', version: '3.1.10'
    compile group: 'org.apache.cxf', name: 'cxf-rt-ws-security', version: '3.1.10'
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

update:exclusion is not working

OlgaMaciaszek :

First of all, there is an issue with this statement:

compile('org.apache.commons':'commons-lang3':'3.5')

If you want to use the colon notation for a dependency, it has to be all in one String, like so:

compile('org.apache.commons:commons-lang3:3.5')

Also, you should probably use the full module name: module: 'geronimo-javamail_1.4_spec'.

Finally, geronimo-javamail_1.4_spec is a transitive dependency of more than one dependency in this setup, so you should exclude it everywhere where necessary one by one, or exclude it altogether like so:

configurations {
    all*.exclude module: 'geronimo-javamail_1.4_spec'
}

This should be added in your build.gradle file at the same level as the dependencies{} section, not within it, so the final code would look like this:

configurations {
    all*.exclude module: 'geronimo-javamail_1.4_spec'
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile("org.springframework.boot:spring-boot-starter-web")  
    compile("org.springframework.boot:spring-boot-starter-batch")
    //compile("org.springframework.boot:spring-boot-devtools")
    compile('org.apache.commons:commons-lang3:3.5')
    compile group: 'org.apache.cxf', name: 'cxf-spring-boot-starter-jaxws', version: '3.1.10'
    compile group: 'org.apache.cxf', name: 'cxf-rt-ws-security', version: '3.1.10'
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to exclude a jar from gradle

Gradle: How to exclude a particular package from a jar?

How to exclude a dependency from built JAR in Gradle?

Exclude class from jar with gradle

How can I exclude files in Gradle's jar.from?

How to exclude resources from the JAR in Gradle and also run via IntelliJ

In an Android Gradle build, how to exclude dependencies from an included jar file?

Gradle - Exclude file from being packaged with jar

How to exclude transitive jar dependency in Gradle?

Gradle build: Exclude resources files from Spring Boot Jar file

Exclude all compiled classes from jar built by gradle java project

Exclude Test folder and Resources from Gradle Jar build

Maven - How to exclude dependencies from generated JAR

How to exclude a package from a jar (with maven)

How to tell Gradle not to exclude .so files in my .jar dependency?

How to exclude files from aar with Gradle dynamically?

How to build a gradle jar from a github library

how to exclude gradle dependencies

How to exclude a set of packages from maven build jar?

How to exclude resource file from spring boot jar?

How to exclude dependencies from maven assembly plugin : jar-with-dependencies?

How can I exclude *.DSA and *.SF files from shaded jar?

How to use maven assembly plugin to exclude a package from dependency jar?

How do I exclude a package from an imported JAR for a project in Eclipse?

How to include runtime dependency in jar generated from gradle jar task

Gradle exclude local jar during testRunTime

How to copy a gradle dependency jar from gradle's cache?

Exclude package from external JAR in Android Studio during Gradle build process

Exclude BuildConfig.class and R.class from Android library jar in Gradle