Transitive dependencies not working

Hi,

i am writing a gradle plugin and transitive dependencies are not working there.

This is how i create the configuration and set transitive to true:

ConfigurationContainer configurations = project.getConfigurations();
configurations.create("my_configuration");

for (Configuration configuration : configurations) {
  configuration.getResolutionStrategy().cacheChangingModulesFor(0, TimeUnit.SECONDS);
  configuration.setTransitive(true);
}

Then i add a dependency:

project.getDependencies().add("my_configuration", "Tools.Build.build_tool_testing:demo:1.0-SNAPSHOT@jar");

The pom file of the dependecy which i add in the plugin:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>Tools.Build.build_tool_testing</groupId>
  <artifactId>demo</artifactId>
  <version>1.0-SNAPSHOT</version>
  <description>description</description>
  <developers>
    <developer>
      <id>dummy</id>
      <name>dummy</name>
      <email>dummy@dummy.dummy</email>
    </developer>
  </developers>
  <dependencies>
    <dependency>
      <groupId>some.group</groupId>
      <artifactId>test</artifactId>
      <version>1.0.0-SNAPSHOT</version>
    </dependency>
  </dependencies>
</project>

When i execute “gradle dependencies” it is only showing “Tools.Build.build_tool_testing:demo” but not “some.group:test”. Am i doing anything wrong or is there something missing?
(There is much more going on in the plugin, but i think this is the most relevant part)

Thanks a lot!

The configuration is transitive by default, even if you don’t set it to true.

Adding @jar to the end of the dependency notation specifically means you want only that JAR and no transitive dependencies for that particular dependency.

Thanks a lot! I completely missed that. Now it´s working as expected.