Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow empty versions in alias definitions in catalog #21385

Open
edudar opened this issue Jul 28, 2022 · 0 comments
Open

Allow empty versions in alias definitions in catalog #21385

edudar opened this issue Jul 28, 2022 · 0 comments

Comments

@edudar
Copy link

edudar commented Jul 28, 2022

I can add a library with or without a version to a catalog.

build.gradle:
catalog {
    versionCatalog {
        library('lib1', 'my', 'library1').version('1.0.0')
        library('lib2', 'my', 'library2').withoutVersion()
    }
}

---

toml:
[libraries]
lib1 = {group = "my", name = "library1", version = "1.0.0" }
lib2 = {group = "my", name = "library2", version = "" }

This works fine, and I can use lib1 right away or would need a platform that will provide a version for lib2. I can also override the lib1 version from settings.gradle. Now, I want to add a library without a version (aka needs a platform) and keep an option to set that version manually/override.

build.gradle:
catalog {
    versionCatalog {
        version('lib2-version', '')

        library('lib1', 'my', 'library1').version('1.0.0')
        library('lib2', 'my', 'library2').versionRef('lib2-version')
    }
}

---

toml:
[versions]
lib2-version = ""

[libraries]
lib1 = {group = "my", name = "library1", version = "1.0.0" }
lib2 = {group = "my", name = "library2", version.ref = "lib2-version" }

---

settings.gradle:
dependencyResolutionManagement {
    versionCatalogs {
        libs {
            from("my:catalog:1.0.0")
            // version('lib2-version', '1.5.0')
        }
    }
}

I'd expect that this should work in a very similar fashion as in the first case. After all, the version is "" in both cases. But it does not and fails with

Invalid TOML catalog definition:
- Problem: In version catalog libs, alias definition 'lib2-version' is invalid.    
  Reason: Version for 'lib2-version' must not be empty.  
  Possible solution: Set a value for 'version'.

Which feels like an artificial restriction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants