Excluding flatdir dependency from inherited configuration


(Jan Roman) #1

I am experiencing problem trying to exclude flatdir dependency.

I have main configuration for the project which is compile, then I need to inherit its dependencies but exclude one of them which is flatdir.

Please see buildfile:

apply plugin: 'java'
  repositories {
    mavenCentral()
 maven { url 'http://download.java.net/maven/1' }
    maven { url 'http://download.java.net/maven/2' }
 flatDir {
        dirs 'lib'
    }
}
  configurations {
 //compile
 myExtendingConfiguration{
   extendsFrom compile
 // STRANGELY enought this is working all right:
  exclude(group: 'commons-logging', name: 'commons-logging')
 // This not working:
  exclude(name:'weblogic') // FIRST log with this uncommented
 // OTHER TRIES:
 // exclude(':weblogic:')
 // exclude(group: '', name: 'weblogic', version: '')
 }
}
  dependencies {
 compile('commons-lang:commons-lang:2.6',
   'commons-logging:commons-logging:1.1.3',
   ':weblogic');
 // another try:
 // myExtendingConfiguration(configurations.compile){
 // exclude(name:'weblogic')
 //}
}

In gradle -q dependencies

I am expecting:

myExtendingConfiguration
+--- commons-lang:commons-lang:2.6
\--- commons-logging:commons-logging:1.1.3

but I am getting:

myExtendingConfiguration
No dependencies

logs are:

// Exclude flatdir dependency uncommented
19:06:59.772 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Visiting configuration :PROJ_STAGING:unspecified(myExtendingConfiguration).
19:06:59.775 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] commons-lang#commons-lang is excluded from :PROJ_STAGING:unspecified(myExtendingConfiguration).
19:06:59.775 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] commons-logging#commons-logging is excluded from :PROJ_STAGING:unspecified(myExtendingConfiguration).
19:06:59.776 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] #weblogic is excluded from :PROJ_STAGING:unspecified(myExtendingConfiguration).
19:06:59.776 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Attaching :PROJ_STAGING:unspecified(myExtendingConfiguration) to its parents.
19:06:59.776 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.TransientConfigurationResultsBuilder] Flushing resolved configuration data in Binary

gradle -q dependencies produces:

compile - Compile classpath for source set 'main'.
+--- commons-lang:commons-lang:2.6
+--- commons-logging:commons-logging:1.1.3
\--- :weblogic:
//(...)
myExtendingConfiguration
No dependencies

when I comment line 19 in my build.gradle I am getting following:

// Exclude flatdir dependency commented
19:07:52.471 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Visiting configuration :PROJ_STAGING:unspecified(myExtendingConfiguration).
19:07:52.473 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] commons-logging#commons-logging is excluded from :PROJ_STAGING:unspecified(myExtendingConfiguration).
19:07:52.473 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Visiting dependency :PROJ_STAGING:unspecified(myExtendingConfiguration) -> commons-lang:commons-lang:2.6(dependency: commons-lang#commons-lang;2.6 {compile=[default]})
19:07:52.474 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Selecting new module version commons-lang:commons-lang:2.6
19:07:52.474 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain] Attempting to resolve module 'commons-lang:commons-lang:2.6' using repositories [MavenRepo, maven, maven2, flatDir]
19:07:52.474 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain] Using module 'commons-lang:commons-lang:2.6' from repository 'MavenRepo'
19:07:52.475 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Visiting dependency :PROJ_STAGING:unspecified(myExtendingConfiguration) -> :weblogic:(dependency: #weblogic; {compile=[default]})
19:07:52.475 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Selecting new module version :weblogic:
19:07:52.475 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain] Attempting to resolve module ':weblogic:' using repositories [MavenRepo, maven, maven2, flatDir]
19:07:52.475 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain] Using module ':weblogic:' from repository 'flatDir'
19:07:52.476 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Visiting configuration commons-lang:commons-lang:2.6(default).
19:07:52.476 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Visiting configuration :weblogic:(default).
19:07:52.476 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Attaching :PROJ_STAGING:unspecified(myExtendingConfiguration) to its parents.
19:07:52.476 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Attaching commons-lang:commons-lang:2.6(default) to its parents.
19:07:52.477 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Attaching :weblogic:(default) to its parents.
19:07:52.477 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.TransientConfigurationResultsBuilder] Flushing resolved configuration data in Binary store in C:\Users\RomanJ\AppData\Local\Temp\gradle8054927434039350975.bin. Wrote root :PROJ_STAGING:unspecified:myExtendingConfiguration.

Dependencies list as follow:

compile - Compile classpath for source set 'main'.
+--- commons-lang:commons-lang:2.6
+--- commons-logging:commons-logging:1.1.3
\--- :weblogic:
(...)
myExtendingConfiguration
+--- commons-lang:commons-lang:2.6
\--- :weblogic:

Is there a way to exclude flatdir dependency when inheriting configuration?


(Peter Niederwieser) #2

Are you saying that the problem is that ‘exclude(’:weblogic’)’ excludes more than just the flatdir weblogic dependency? What if you remove the other exclude?


(Jan Roman) #3

yes! Having ‘exclude(’:weblogic’)’ excludes all other dependencies, regardles what else I have in configuration closure.