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

From Java

How to exclude a jar from gradle

From Java

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

From Dev

How to exclude a dependency from built JAR in Gradle?

From Dev

Exclude class from jar with gradle

From Dev

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

From Java

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

From

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

From Java

Gradle - Exclude file from being packaged with jar

From Dev

How to exclude transitive jar dependency in Gradle?

From Java

Gradle build: Exclude resources files from Spring Boot Jar file

From Dev

Exclude all compiled classes from jar built by gradle java project

From Dev

Exclude Test folder and Resources from Gradle Jar build

From Dev

Maven - How to exclude dependencies from generated JAR

From Dev

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

From Dev

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

From Dev

How to exclude files from aar with Gradle dynamically?

From Dev

How to build a gradle jar from a github library

From Java

how to exclude gradle dependencies

From Java

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

From Java

How to exclude resource file from spring boot jar?

From Java

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

From Java

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

From Dev

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

From Dev

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

From Dev

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

From Java

Gradle exclude local jar during testRunTime

From Dev

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

From Dev

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

From Dev

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

Related Related

  1. 1

    How to exclude a jar from gradle

  2. 2

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

  3. 3

    How to exclude a dependency from built JAR in Gradle?

  4. 4

    Exclude class from jar with gradle

  5. 5

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

  6. 6

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

  7. 7

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

  8. 8

    Gradle - Exclude file from being packaged with jar

  9. 9

    How to exclude transitive jar dependency in Gradle?

  10. 10

    Gradle build: Exclude resources files from Spring Boot Jar file

  11. 11

    Exclude all compiled classes from jar built by gradle java project

  12. 12

    Exclude Test folder and Resources from Gradle Jar build

  13. 13

    Maven - How to exclude dependencies from generated JAR

  14. 14

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

  15. 15

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

  16. 16

    How to exclude files from aar with Gradle dynamically?

  17. 17

    How to build a gradle jar from a github library

  18. 18

    how to exclude gradle dependencies

  19. 19

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

  20. 20

    How to exclude resource file from spring boot jar?

  21. 21

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

  22. 22

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

  23. 23

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

  24. 24

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

  25. 25

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

  26. 26

    Gradle exclude local jar during testRunTime

  27. 27

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

  28. 28

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

  29. 29

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

HotTag

Archive