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

Publication without afterEvaluate as specified in quickstart does not work. #18

Open
runningcode opened this issue Feb 18, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@runningcode
Copy link

Expected and Results

I have a publication named “pluginMaven” and “com.foo.pluginMarkerMaven”.

My nmcp block is configured like so:

nmcp {
    publish("pluginMaven") {
      username = System.getenv("OSSRH_USERNAME")
      password = System.getenv("OSSRH_PASSWORD")
      // or if you want to publish automatically
      publicationType = "USER_MANAGED"
    }
    publish("com.foo.pluginMarkerMaven") {
      username = System.getenv("OSSRH_USERNAME")
      password = System.getenv("OSSRH_PASSWORD")
      // or if you want to publish automatically
      publicationType = "USER_MANAGED"
    }
}

The build fails with Nmcp: cannot find publication 'pluginMaven'. Candidates are: ‘’ I would expect it not to fail.

To fix this I add afterEvaluate.

nmcp {
  afterEvaluate {
    publish("pluginMaven") {
      username = System.getenv("OSSRH_USERNAME")
      password = System.getenv("OSSRH_PASSWORD")
      // or if you want to publish automatically
      publicationType = "USER_MANAGED"
    }
    publish("com.foo.pluginMarkerMaven") {
      username = System.getenv("OSSRH_USERNAME")
      password = System.getenv("OSSRH_PASSWORD")
      // or if you want to publish automatically
      publicationType = "USER_MANAGED"
    }
  }
}

Related environent and versions

I’m using Gradle 8.12.1 and nmcp 0.0.8 and gradle plugin publish 1.3.1

Reproduction steps

No response

Anything else?

No response

@runningcode runningcode added the bug Something isn't working label Feb 18, 2025
@martinbonnin
Copy link
Member

Thanks for opening this!

I'm guessing gradle plugin publish creates the publication? And they are probably created after your script is evaluated?

We could do something like publications.configureEach {} and check for the name of the poublication in there to make everything more lazy. This always gets me a bit itchy because it goes in callback hell land but this is probably the way forward here. I'll dig!

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