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

[sdkman] config seems to be ignored explicitly set key/token values #737

Closed
bitspittle opened this issue Feb 2, 2022 · 6 comments
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@bitspittle
Copy link

My config, with some debugging printlns added:

sdkman {
    val (key, token) = listOf(findProperty("sdkman.key") as? String, findProperty("sdkman.token") as? String)
    if (key != null && token != null) {
        downloadUrl.set(artifactDownloadPath)
        println("SDKMAN! key and token will be set? ${key.isNotBlank() && token.isNotBlank()}")
        consumerKey.set(key)
        consumerToken.set(token)
        active.set(Active.RELEASE)
    }
    else {
        println("SDKMAN! packager disabled on this machine since key and/or token are not defined")
        active.set(Active.NEVER)
    }
}

Output:

9:34:09 AM: Executing 'jreleaserConfig'...

Type-safe dependency accessors is an incubating feature.
...

> Configure project :cli:kobweb
SDKMAN! key and token will be set? true

...

> Task :cli:kobweb:jreleaserConfig FAILED
...
[ERROR] == JReleaser ==
[ERROR] sdkman.consumerKey must not be blank. Configure a value using the Gradle DSL, or define a JRELEASER_SDKMAN_CONSUMER_KEY environment variable, or define a key/value pair in /home/d9n/.jreleaser/config.properties with key = JRELEASER_SDKMAN_CONSUMER_KEY
[ERROR] sdkman.consumerToken must not be blank. Configure a value using the Gradle DSL, or define a JRELEASER_SDKMAN_CONSUMER_TOKEN environment variable, or define a key/value pair in /home/d9n/.jreleaser/config.properties with key = JRELEASER_SDKMAN_CONSUMER_TOKEN

The error message includes instructions for other ways to set the key and value, so I probably won't be blocked, but this strikes me as a mistake? Since according to the error message itself as well as the docs, it says for the key and token properties // If left unspecified, ...

Expected:

Setting consumeKey and consumerToken directly should be supported or the documentation / error messages should be updated to match.

@bitspittle bitspittle added the bug Something isn't working label Feb 2, 2022
@aalmiray
Copy link
Member

aalmiray commented Feb 2, 2022

Did you define sdkman inside the packagers { } block? Because it works if defined inside the distribution block. This means that global settings (packagers) were not inherit to the local settings (distribution) as it happens with other packagers.

@aalmiray aalmiray added this to the v1.0.0-M2 milestone Feb 2, 2022
@aalmiray aalmiray self-assigned this Feb 2, 2022
@bitspittle
Copy link
Author

Ah yes I defined it inside the packagers block.

My distributions block is fairly sparse:

   distributions {
        create("kobweb") {
            listOf("zip", "tar").forEach { artifactExtension ->
                artifact {
                    setPath("build/distributions/{{distributionName}}-{{projectVersion}}.$artifactExtension")
                }
            }
        }
    }

@aalmiray
Copy link
Member

aalmiray commented Feb 2, 2022

I can confirm that the packagers block does not pass on explicit settings. Fix is forthcoming.

@aalmiray aalmiray changed the title SDKMAN! config seems to be ignored explicitly set key/token values [sdkman] config seems to be ignored explicitly set key/token values Feb 2, 2022
@bitspittle
Copy link
Author

Apologies, I am still seeing this issue with M2, so I have to keep my sdkman configuration disabled for now. Let me know if you want to re-open this bug for if I should create a new one.

See relevant declaration in my build.gradle: https://github.com/varabyte/kobweb/blob/609f0de11dd9fc0b6df213a600d8ecc8fcedbc16/cli/kobweb/build.gradle.kts#L105

If I'm putting my package manager declarations in the wrong place, let me know!

@aalmiray
Copy link
Member

I think the problem may be that the sdkman announcer clashes with the sdkman packager. It's a bit of history but sdkman used to be an announcer early on. It became a packager later and both modes are still supported.

I can conform that values set at packagers.sdkman are copied over to distribution.*.sdkman which is what this fix provided, however the announcers.sdkman block remains unchanged. I think this is the problem to be fixed.

@bitspittle
Copy link
Author

Just in case, if you want repro steps:

$ git clone htts://github.com/varabyte/kobweb.git && cd kobweb

Remove the "-SNAPSHOT" suffix from the kobweb-cli version in gradle/libs.version.toml:

...
kobweb-cli = "0.9.7"
...

Next, go to the CLI subdirectory:

$ cd cli/kobweb

Edit the build.gradle.kts file, changing these lines around L102:

             sdkman {
                 downloadUrl.set(artifactDownloadPath)
                 consumerKey.set("fakekey")
                 consumerToken.set("madeuptoken")
                 active.set(Active.RELEASE)
            }

Finally, back in the terminal:

../../gradlew jreleaserConfig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants