eclipse plugin - Gradle excludes self when excluding all transitive dependencies -
i've com across particular problem have been unable solve , grateful help. included jar dependencies artifact dependencies in java project. looked following:
compile "com.example:projecta:1.0.0@jar"
so far good. let's call project 'a'. have included project in java project b, again gradle. i've noticed published maven-publish did not exclude transitive dependencies, in pom file, when using in b.
so started using transitive flag:
dependency("com.example:projecta:1.0.0") { transitive = false }
this makes sure in project b, excluded transitive deps of when using eclipse plugin , gradle itself.
however problem missing exclusion in published pom.xml remained. found issue seems solved @ time of writing , gradle version: gradle-2945
so tried following:
dependency("com.example:projecta:1.0.0") { exclude group: '*' }
the pom file correctly has desired exclude rules transitive dependencies in accordance maven doc:
<groupid>com.example</groupid> <artifactid>projecta</artifactid> <version>1.0.0</version> <exclusions> <exclusion> <groupid>*</groupid> <artifactid>*</artifactid> </exclusion> </exclusions>
however lead different set of problems; neither eclipse nor gradle when using compilejava task compile code in project b when including in fashion. along transitive dependencies had disappeared.
the strange thing though according dependencies task part of compile classpath.
i using jre7 , gradle 2.3 eclipse 4.41 , use nexus internal maven repository.
i expect not required use transitive flag , manipulate generated pom file manually adding desired exclusions.
sample project reproduce problem using dbcp project a:
main.java:
import org.apache.commons.dbcp.basicdatasource; public class main { public static void main(string[] args) { system.out.println("hello world"); basicdatasource ds = new basicdatasource(); } }
build.gradle:
version = '0.0.1' group = 'com.example' apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'maven-publish' repositories { mavencentral() } dependencies { compile ('commons-dbcp:commons-dbcp:1.4') { transitive=false } // { // exclude group: '*' // } } publishing { publications { mavenjava(mavenpublication) { components.java } } }
i think may have been bug in gradle. tested example files both gradle 2.3 , 2.5 command line. if use transitive = false
, both versions compile project fine. switching exclude group: '*'
syntax causes 2.3 build break. gradle 2.5 continues work fine.
in short, gradle upgrade should fix problem.
Comments
Post a Comment