简体   繁体   中英

Gradle: excluding a jar from runtime dependencies

I need to exclude a jar from runtime dependency via Gradle.

I am getting this error:

Caused by: java.lang.IllegalStateException: Conflicting persistence unit definitions for name 'ldb-jpa': file:/D:/EricFrancis/shared/build/libs/shared.jar, file:/D:/EricFrancis/shared/build/resources/main

I'm trying to exclude the jar.

How do I tell gradle to do this?

Without more information (Gradle version, relevant parts of build script, etc.), it's hard to say. But since this isn't a Maven or Ivy dependency, I'd consider not adding it in the first place.

It turns out that I did not understand how configurations worked.

I was able to exclude the jar via:

configurations {
    testRuntime {
       exclude module: 'share'          
    }
    testCompile {
       exclude module: 'share'
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM