This message was deleted.
# develocity
s
This message was deleted.
f
Hey @Jörgen Andersson I’m taking a look and will get back to you
🙏 1
Hi @Jörgen Andersson I reproduced your setup with a simple scenario like
Copy code
parent project
    sub1 (packaging pom)
        declares a few compile dependencies
    sub2 (packaging jar)
        declares a dependency on sub1 with type = pom
        has a few tests
When running
mvn clean install
, all is good, and I can see that the transitive dependencies declared in
sub1
are also present on e.g. the compile classpath of
sub2
, as transitive dependencies of the
sub1
pom. Then, I changed the
sub1
pom a bit, by adding a fake
<properties><foo>bar</foo></properties>
, and as you mentioned, the test goal is not taken from cache anymore. The comparison shows a difference in the
testClasspathElements
file property, where
sub1/pom.xml
is different. So I guess I reproduced it properly. Then, I tried declaring a runtime classpath normalization on
sub2
pom
Copy code
<build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.gradle</groupId>
          <artifactId>gradle-enterprise-maven-extension</artifactId>
          <configuration>
            <gradleEnterprise>
              <normalization>
                <runtimeClassPath>
                  <ignoredFiles>
                    <ignoredFile>**/pom.xml</ignoredFile>
                  </ignoredFiles>
                </runtimeClassPath>
              </normalization>
            </gradleEnterprise>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
and this didn’t work. I debugged it and this kind of normalization only works for files inside elements on the runtime class path. (e.g. a
foo.jar
that contains a
path/to/pom.xml
file would be normalized withtout this
pom.xml
file). You cannot filter out classpath elements like that. I also tried to use https://maven.apache.org/surefire/maven-surefire-plugin/examples/configuring-classpath.html#removing-dependency-classpath-elements to remove this
pom.xml
from the surefire classpath, but this doesn’t seem to work for ‘pom’ dependencies :/ Have you considered using
dependencyManagement
in the parent project, to declare your dependencies (with their versions, etc), and only declare them via
dependencies
(without version) in the child modules ? You would still have to declare the dependencies in all consuming modules (like here ‘sub2’) instead of centralizing them in ‘sub1’, but just with their groupId+artifactId. Or, you can live with the ‘packing jar’ approach, maybe ? With this approach, the
sub1 pom.xml
is not added to the classpath, but the (empty)
sub1.jar
, and also its transitive dependencies.
j
Thanks @François Guillot for your efforts. Yes, it seems you have repoduced correctly. Your description is all the same as what we've seen on our side. Using
dependencyManagement
is not an option in this case (we use it in many other places) since the purpose of the pom-dependency is to group a set of runtime-dependencies that needs to be included in severals pom:s building runtime packages (rpm:s in our case). We don't want to repeat the dependencies in each pom where needed. Changing from pom-packaging to jar-packaging was the solution we ended up using, but it is a bit of a work-around. In general I can't see any reason why Gradle Enterprise Maven Extension should consider a pom-file on the runtime classpath at all while calculating the cache-key. I can't see how it could possible affect the execution. Maybe that is something you could consider for future updates?
f
We’re discussing internally, because you do have a point (and this exact same behavior happens on the Gradle implementation too). I’ll get back when I have some more info
🙏 1
Hey @Jörgen Andersson Sorry, it took some time to discuss this with relevant folks. We looked at this holistically, also from a Gradle perspective, because we don’t want our caching implementations to differ much in general. And it turns out that Gradle is doing it wrong here too. You can depend on a pom (which would be e.g. à la Gradle
Copy code
implementation(group:artifact:version@pom) { transitive = true }
) and you end up exactly as in your case, with the transitive jars, but also the pom on the runtime classpath. We are weighing different options here, as to how to best solve this. Given this is not blocking you (correct me if I’m wrong), we’re going to take a little bit of time to do it right for both build tools. I’ll try to ping you early next year when I have more news or when we release a new version of the Gradle Enterprise Maven extension that will filter this out.
j
Thanks @François Guillot! You are correct. It is not blocking for us. Our team can go with the workaround if they want to proceede faster. Still looking forward to your fix, though.