Failed to resolve dependencies with classifiers in maven repo

Hello,

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: http://repo1.maven.org/maven2/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4-patched.jar]

.

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?

I also tried replacing the dependency:

configurations.all {
 resolutionStrategy.eachDependency { DependencyResolveDetails details ->
  if (details.requested.group == 'commons-dbcp' && details.requested.name =='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.

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

See example 48.28 of http://www.gradle.org/docs/current/userguide/dependency_management.html#sub:maven_repo

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.