I am upgrading a particular build from 2.14.1 to 4.4
It has a dependency which has packaging=pom and which is used to pull in a few other dependencies as a bundle. This is resolved as expected in 2.14.1 (i.e. you get the transitive dependencies) but this behaviour changes in 4.4 in 2 ways.
Firstly I have to explicitly say that the dependency is of type pom (as in ‘com.foo:bar:1.2.3@pom’) otherwise the build fails because there is no jar for this dependency.
Secondly, once I’ve made this change, I do not get the transitive dependencies. It appears this is because org.gradle.api.internal.artifacts.dsl.dependencies.ModuleFactoryHelper
does the following
public class ModuleFactoryHelper {
public static void addExplicitArtifactsIfDefined(ExternalDependency moduleDependency, String artifactType, String classifier) {
String actualArtifactType = artifactType;
if (actualArtifactType == null) {
if (classifier != null) {
actualArtifactType = DependencyArtifact.DEFAULT_TYPE;
}
} else {
moduleDependency.setTransitive(false);
}
if (actualArtifactType != null) {
moduleDependency.addArtifact(new DefaultDependencyArtifact(moduleDependency.getName(),
actualArtifactType, actualArtifactType, classifier, null));
}
}
}
I can workaround this by passing setting transitive = true
via a configuration closure after creating the dependency but it seems odd.
What is the rationale for this behaviour?
Is there another, correct, way to express this dependency in gradle?