I want to exclude junit library from compile configuration but keep it in testCompile configuration.
Here is my build.gradle
apply plugin: "java"
repositories {
mavenCentral()
}
dependencies {
compile 'commons-httpclient:commons-httpclient:3.0.1'
testCompile 'junit:junit:4.12'
}
configurations.compile {
dependencies {
// exclude group: "junit"
}
}
Here is dependency tree
$ ./gradlew dependencies
:dependencies
------------------------------------------------------------
Root project
------------------------------------------------------------
archives - Configuration for archive artifacts.
No dependencies
compile - Dependencies for source set 'main'.
\--- commons-httpclient:commons-httpclient:3.0.1
+--- junit:junit:3.8.1
+--- commons-logging:commons-logging:1.0.3
\--- commons-codec:commons-codec:1.2
compileClasspath - Compile classpath for source set 'main'.
\--- commons-httpclient:commons-httpclient:3.0.1
+--- junit:junit:3.8.1
+--- commons-logging:commons-logging:1.0.3
\--- commons-codec:commons-codec:1.2
compileOnly - Compile dependencies for source set 'main'.
\--- commons-httpclient:commons-httpclient:3.0.1
+--- junit:junit:3.8.1
+--- commons-logging:commons-logging:1.0.3
\--- commons-codec:commons-codec:1.2
default - Configuration for default artifacts.
\--- commons-httpclient:commons-httpclient:3.0.1
+--- junit:junit:3.8.1
+--- commons-logging:commons-logging:1.0.3
\--- commons-codec:commons-codec:1.2
runtime - Runtime dependencies for source set 'main'.
\--- commons-httpclient:commons-httpclient:3.0.1
+--- junit:junit:3.8.1
+--- commons-logging:commons-logging:1.0.3
\--- commons-codec:commons-codec:1.2
testCompile - Dependencies for source set 'test'.
+--- commons-httpclient:commons-httpclient:3.0.1
| +--- junit:junit:3.8.1 -> 4.12
| | \--- org.hamcrest:hamcrest-core:1.3
| +--- commons-logging:commons-logging:1.0.3
| \--- commons-codec:commons-codec:1.2
\--- junit:junit:4.12 (*)
testCompileClasspath - Compile classpath for source set 'test'.
+--- commons-httpclient:commons-httpclient:3.0.1
| +--- junit:junit:3.8.1 -> 4.12
| | \--- org.hamcrest:hamcrest-core:1.3
| +--- commons-logging:commons-logging:1.0.3
| \--- commons-codec:commons-codec:1.2
\--- junit:junit:4.12 (*)
testCompileOnly - Compile dependencies for source set 'test'.
+--- commons-httpclient:commons-httpclient:3.0.1
| +--- junit:junit:3.8.1 -> 4.12
| | \--- org.hamcrest:hamcrest-core:1.3
| +--- commons-logging:commons-logging:1.0.3
| \--- commons-codec:commons-codec:1.2
\--- junit:junit:4.12 (*)
testRuntime - Runtime dependencies for source set 'test'.
+--- commons-httpclient:commons-httpclient:3.0.1
| +--- junit:junit:3.8.1 -> 4.12
| | \--- org.hamcrest:hamcrest-core:1.3
| +--- commons-logging:commons-logging:1.0.3
| \--- commons-codec:commons-codec:1.2
\--- junit:junit:4.12 (*)
Here is dependency tree when I uncommented exclude
$ ./gradlew dependencies
:dependencies
------------------------------------------------------------
Root project
------------------------------------------------------------
archives - Configuration for archive artifacts.
No dependencies
compile - Dependencies for source set 'main'.
\--- commons-httpclient:commons-httpclient:3.0.1
+--- commons-logging:commons-logging:1.0.3
\--- commons-codec:commons-codec:1.2
compileClasspath - Compile classpath for source set 'main'.
\--- commons-httpclient:commons-httpclient:3.0.1
+--- commons-logging:commons-logging:1.0.3
\--- commons-codec:commons-codec:1.2
compileOnly - Compile dependencies for source set 'main'.
\--- commons-httpclient:commons-httpclient:3.0.1
+--- commons-logging:commons-logging:1.0.3
\--- commons-codec:commons-codec:1.2
default - Configuration for default artifacts.
\--- commons-httpclient:commons-httpclient:3.0.1
+--- commons-logging:commons-logging:1.0.3
\--- commons-codec:commons-codec:1.2
runtime - Runtime dependencies for source set 'main'.
\--- commons-httpclient:commons-httpclient:3.0.1
+--- commons-logging:commons-logging:1.0.3
\--- commons-codec:commons-codec:1.2
testCompile - Dependencies for source set 'test'.
\--- commons-httpclient:commons-httpclient:3.0.1
+--- commons-logging:commons-logging:1.0.3
\--- commons-codec:commons-codec:1.2
testCompileClasspath - Compile classpath for source set 'test'.
\--- commons-httpclient:commons-httpclient:3.0.1
+--- commons-logging:commons-logging:1.0.3
\--- commons-codec:commons-codec:1.2
testCompileOnly - Compile dependencies for source set 'test'.
\--- commons-httpclient:commons-httpclient:3.0.1
+--- commons-logging:commons-logging:1.0.3
\--- commons-codec:commons-codec:1.2
testRuntime - Runtime dependencies for source set 'test'.
\--- commons-httpclient:commons-httpclient:3.0.1
+--- commons-logging:commons-logging:1.0.3
\--- commons-codec:commons-codec:1.2