Failed to resolve dependencies with classifiers in maven repo

(dev) #1


I’m seeing a strange error.

Artifact 'commons-dbcp:commons-dbcp:1.4:patched@jar' not found.

This artifact uses a “patched” classifier and is a transitive dependency declared in a maven pom. The artifact is installed in a company internal nexus maven repo. The company repo is declared (as a maven repo) in build.gradle.

With debugging on, I can see

Resource missing. [HTTP HEAD:]


Could it be that a correct pom is being found in maven central, and there is an assumption that the artifact will be there too? The artifact is not in maven central and is therefore not being found?

(dev) #2

I also tried replacing the dependency:

configurations.all {
 resolutionStrategy.eachDependency { DependencyResolveDetails details ->
  if ( == 'commons-dbcp' && =='commons-dbcp') {
   details.useTarget "commons-dbcp:commons-dbcp:1.4-DBCP330"

This returns:

Artifact 'commons-dbcp:commons-dbcp:1.4-DBCP330:patched@jar' not found.

It looks like its not possible to change the classifier.

(Luke Daley) #3

You should be able to work around this by specifying a separate artifact repository.

See example 48.28 of

(dev) #4

Thanks for that Luke. Is there any way in the resolutionStrategy.eachDependency approach to totally replace a dependency? ie. swap one for another. In the example above it seems the classifier is not being overwritten and ModuleVersionSelector only supports group/name/version.