refreshVersions icon indicating copy to clipboard operation
refreshVersions copied to clipboard

refreshVersions does not work properly with java-platform plugin

Open StefanHirche opened this issue 3 years ago • 3 comments

Describe the problem

If using the refreshVersions plugin with the java-platform plugin, the resulting files do not use correct version in dependencyConstraints section.

⚠️ Current behavior

Only the normal dependency is correctly resolved, the dependencies in the constraints block are not.

✅ Expected behavior

All dependency versions are resolved, also those in the constraints block.

💣 Steps to reproduce

Use both plugins, add something like

javaPlatform {
  allowDependencies()
}

dependencies {
    constraints {
        api ("org.apache.logging.log4j:log4j-api:_")
    }
    api ("org.apache.commons:commons-lang3:_")
}

Only the normal dependency is correctly resolved, the dependencies in the constraints block are not.

📱 Tech info

StefanHirche avatar Mar 29 '22 09:03 StefanHirche

have same issue, but with normal dependencies, not with some constraints.

image

For example Glide:

 implementation 'com.github.bumptech.glide:glide:4.13.2'
    implementation 'com.github.bumptech.glide:okhttp3-integration:4.13.2'
    kapt "com.github.bumptech.glide:compiler:4.13.2"
    implementation "com.github.technoir42:glide-debug-indicator:0.9.1"

is migrated to:

    implementation 'com.github.bumptech.glide:glide:_'
    implementation 'com.github.bumptech.glide:okhttp3-integration:_'
    kapt "com.github.bumptech.glide:compiler:_"
    implementation "com.github.technoir42:glide-debug-indicator:_"

with version.properties file:

version.com.github.technoir42..glide-debug-indicator=0.9.1

version.com.github.bumptech.glide..okhttp3-integration=4.13.2

version.com.github.bumptech.glide..glide=4.13.2

version.com.github.bumptech.glide..compiler=4.13.2

Every dependency, which has two dots in name failed to resolve to gradle files and is replaced with underscope.

mtrakal avatar Jun 07 '22 11:06 mtrakal

OK, I'll just add the generated module.json file

{
  "formatVersion": "1.1",
  "component": {
    "group": "de.kgucms.tps.scripts",
    "module": "platform",
    "version": "14.1.0-SNAPSHOT",
    "attributes": {
      "org.gradle.status": "integration"
    }
  },
  "createdBy": {
    "gradle": {
      "version": "7.4"
    }
  },
  "variants": [
    {
      "name": "apiElements",
      "attributes": {
        "org.gradle.category": "platform",
        "org.gradle.usage": "java-api"
      },
      "dependencies": [
        {
          "group": "org.apache.commons",
          "module": "commons-lang3",
          "version": {
            "requires": "3.12.0",
            "rejects": [
              "_"
            ]
          }
        }
      ],
      "dependencyConstraints": [
        {
          "group": "org.apache.logging.log4j",
          "module": "log4j-api",
          "version": {
            "requires": "_"
          }
        }
      ]
    },
    {
      "name": "runtimeElements",
      "attributes": {
        "org.gradle.category": "platform",
        "org.gradle.usage": "java-runtime"
      },
      "dependencies": [
        {
          "group": "org.apache.commons",
          "module": "commons-lang3",
          "version": {
            "requires": "3.12.0",
            "rejects": [
              "_"
            ]
          }
        }
      ],
      "dependencyConstraints": [
        {
          "group": "org.apache.logging.log4j",
          "module": "log4j-api",
          "version": {
            "requires": "_"
          }
        }
      ]
    }
  ]
}

and the generated pom-default.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <!-- This module was also published with a richer model, Gradle metadata,  -->
  <!-- which should be used instead. Do not delete the following line which  -->
  <!-- is to indicate to Gradle or any Gradle module metadata file consumer  -->
  <!-- that they should prefer consuming it instead. -->
  <!-- do_not_remove: published-with-gradle-metadata -->
  <modelVersion>4.0.0</modelVersion>
  <groupId>de.kgucms.tps.scripts</groupId>
  <artifactId>platform</artifactId>
  <version>14.1.0-SNAPSHOT</version>
  <packaging>pom</packaging>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>_</version>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <version>3.12.0</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
</project>

My usecase would be to generate a gradle platform that i can reuse in different software projects. But I'd like to manage the versions used in the platform with refreshVersions. But if this does not work with constrained, this is not possible. Maybe this works as designed and I misunderstood the feature? But the documentation of platform suggests that it is possible to create basically a dependency list or BOM without the contrained and the possibility to constrain versions when using the platform to values given in the platform. I would use the second use case, but then a concrete version has to be entered in those files above. Thanks for your work

StefanHirche avatar Sep 19 '22 09:09 StefanHirche

Anything new here, as I would really like to use the java platform feature, but not without an automatism to update versions. Anything I can do to help but be silent and wait?

StefanHirche avatar Mar 06 '24 09:03 StefanHirche