Hi, we are finalizing our Java integration in the ...
# package-authoring
t
Hi, we are finalizing our Java integration in the OVHcloud provider (that’s a good news), but we are an issue in the GH release action. I can’t find how to fix this error: “Task ‘publishToSonatype’ not found in root project ‘com.ovh.pulumi’ and its subprojects.” GH repo: https://github.com/ovh/pulumi-ovh/ I saw a few other GH repo with java sdk in pulumi providers but I can’t find what to fix. Is it possible to help us in this blocking issue? Thx
CC @limited-rainbow-51650 & @many-telephone-49025 😊
e
Tooling assumes gradle-nexus.publish-plugin and will call
publishToSonatype
t
Thanks @enough-garden-22763 , it seems that we already have this plugin but we have the error. https://github.com/ovh/pulumi-ovh/blob/main/sdk/java/build.gradle#L8
e
I think I know what's going on
Copy code
if (publishRepoUsername) {
    nexusPublishing {
        repositories {
            sonatype {
                nexusUrl.set(uri(publishRepoURL + "/service/local/"))
                snapshotRepositoryUrl.set(uri(publishRepoURL + "/content/repositories/snapshots/"))
                username = publishRepoUsername
                password = publishRepoPassword
            }
        }
    }
}

if (signingKey) {
    signing {
        useInMemoryPgpKeys(signingKey, signingPassword)
        sign publishing.publications.mainPublication
    }
}
There's unfortunate conditionals around setting up publishing. I'll file an issue to remove the conditionals or otherwise improve the error in this case.
Copy code
def resolvedVersion = System.getenv("PACKAGE_VERSION") ?:
    (project.version == "unspecified"
         ? "0.0.1"
         : project.version)

def signingKey = System.getenv("SIGNING_KEY")
def signingPassword = System.getenv("SIGNING_PASSWORD")
def publishRepoURL = System.getenv("PUBLISH_REPO_URL") ?: "<https://s01.oss.sonatype.org>"
def publishRepoUsername = System.getenv("PUBLISH_REPO_USERNAME")
def publishRepoPassword = System.getenv("PUBLISH_REPO_PASSWORD")
To complete your setup, you need to setup artifact signing and credentials - currently the gradle file expects those to be made available as environment variables.
I filed the issue https://github.com/pulumi/pulumi-java/issues/1421 to improve guidance in this case
t
About the env variable, they are defined in the GH action (c.f printscreen). It’s not the only things to do?
e
I get a different error once I specify the env var e..g.
Copy code
PUBLISH_REPO_USERNAME=tom gradle publishToSonatype                                                         ~/code/pulumi-ovh/sdk/java

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':publishMainPublicationPublicationToSonatypeRepository'.
> Failed to calculate the value of task ':compileJava' property 'javaCompiler'.
   > No matching toolchains found for requested specification: {languageVersion=21, vendor=any, implementation=vendor-specific} for MAC_OS on aarch64.
      > No locally installed toolchains match and toolchain download repositories have not been configured.

* Try:
> Learn more about toolchain auto-detection at <https://docs.gradle.org/8.4/userguide/toolchains.html#sec:auto_detection>.
> Learn more about toolchain repositories at <https://docs.gradle.org/8.4/userguide/toolchains.html#sub:download_repositories>.
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at <https://help.gradle.org>.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to <https://docs.gradle.org/8.4/userguide/command_line_interface.html#sec:command_line_warnings> in the Gradle documentation.

BUILD FAILED in 580ms
Looks like I need to setup the right Java version to be able to run this on my machine.
So sounds like the env var from that block is not propagated to the right place.
t
It’s strange because i don’t see this kind of problem in another repositories. How they manage to do it?
The SONATYPE_USERNAME environmetn variable was not corrrectly defined in the GH action, now it’s good. But we have another error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':initializeSonatypeStagingRepository'.
> Failed to find staging profile for package group: com.ovh.pulumi
Do you encounter this bug before?
e
Might worth logging into https://s01.oss.sonatype.org/ and seeing if the portal has any more detailed diagnostics. It should have created a staging profile for the release, staging profiles are usually visible through that UI.
t
Finally i found the last issue: the groupId The message was not very helping 😄
e
Indeed sad panda