jeudi 12 mars 2015

Exclude a transitive JAR dependency in Gradle

I have two projects defined in Gradle, projectA and projectB defined as a multiproject.


ProjectA has a dependency with spring1-beans.jar meanwhile ProjectB has a dependency with ProjectB.


The problem I got is that ProjectB has also a depepdency with spring3-beans therefore I need to exclude the Spring1 jar, otherwise it will use the incorrect version of Spring.


The Gradle conf file for ProjectA looks like:



dependencies {
compile files('lib/spring-beans.jar')
}


and the conf for ProjectB:



dependencies {

compile project(':projects:projectA') {
exclude files('lib/spring-beans.jar')
}
}


Unfortunately, this does not work. Gradle throws the following error:



Could not find method exclude() for arguments [file collection] on project



I have also tried with module with a similar output:



The description 'lib/spring-beans.jar' is invalid



Notes:



  • I am using JARs dependencies because the project is being migrated from Ant, so I cannot switch to a remote repository even though I am opened to suggestions.


Aucun commentaire:

Enregistrer un commentaire