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

[BUG] Gradle task order cause publishzip plugin to change groupid too early #501

Closed
peterzhuamazon opened this issue Aug 5, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@peterzhuamazon
Copy link
Member

peterzhuamazon commented Aug 5, 2022

We recently add publish zip plugin to notifications/core and notifications/notifications.
https://github.com/opensearch-project/notifications/blob/2.2/notifications/core/build.gradle#L23
https://github.com/opensearch-project/notifications/blob/2.2/notifications/core/build.gradle#L23

The problem being that the task of this plugin will trigger automatically no matter what task is being called.
And it will try to switch the groupid to org.opensearch.plugin permanently for plugin zips to be published on https://aws.oss.sonatype.org/content/repositories/snapshots/org/opensearch/plugin/

See code:
https://github.com/opensearch-project/OpenSearch/pull/3252/files#diff-2a5851da2408bbeb8733433421917f253614fffe49449da0dd315a15ed8cdf74R43


This is not a problem if we only have 1-2 layers of gradle dependencies.
However, notifications plugin repository structure is set in a way that:

  1. repo name notifications
  2. within repo root, there is another notifications folder for backend plugin, with root build.gradle.
  3. notifications/core and notifications/notifications have their own build.gradle which is called by the root build.gradle, and this is where the pluginzip publishing plugin is applied.

When running publish to maven local:

./gradlew publishToMavenLocal '-PexcludeTests=**/SesChannelIT*' -Dopensearch.version=2.2.0-SNAPSHOT -Dbuild.snapshot=true

The publishzip task goes before the publishmavenlocal task and switch the groupid from org.opensearch to org.opensearch.plugin way too early.

https://build.ci.opensearch.org/job/distribution-build-opensearch/5891/execution/node/240/log/

Caused by: org.gradle.api.publish.maven.InvalidMavenPublicationException: Invalid publication 'nebula': supplied groupId (org.opensearch) does not match value from POM file (org.opensearch.plugin). Cannot edit groupId directly in the POM file.

We currently have a temp fix in this PR: opensearch-project/opensearch-build#2431

It will comment out/disable apply publishzip plugin before publishtomavenlocal, then revert back so that publishzip can run after the mavenlocal task.

Thanks.

@peterzhuamazon
Copy link
Member Author

@prudhvigodithi
Copy link
Member

Keeping this open from comment added by @lukas-vlcek #554 (comment).

@jmazanec15
Copy link
Member

@prudhvigodithi @lukas-vlcek Running into a similar issue opensearch-project/neural-search#31. If we are setting groupId to "org.opensearch.plugin" for publishing, why can't we set it for the project group? This seemed to fix my issue here: opensearch-project/k-NN#596

@cwperks
Copy link
Member

cwperks commented May 4, 2023

@prudhvigodithi @vibrantvarun and I are hitting this issue trying to fix opensearch-project/job-scheduler#374 too. I have also noticed this now on security repo trying to do ./gradlew publishToMavenLocal. Having different coordinates for the zip org.opensearch.plugin vs the jars org.opensearch is causing the issue. @vibrantvarun and I have been trying to add maven publications for both packaging types. i.e.

publishing {
    publications {
        pluginJar(MavenPublication){
            pom {
                name = "opensearch-job-scheduler"
                description = "OpenSearch Job Scheduler plugin"
                packaging = "jar"
                groupId = "org.opensearch"
            }
        }
        pluginZip(MavenPublication) {
            pom {
                name = "opensearch-job-scheduler"
                description = "OpenSearch Job Scheduler plugin"
                groupId = "org.opensearch.plugin"
            }
        }
    }
    repositories {
        maven {
            name = "Snapshots" //  optional target repository name
            url = "${rootDir}/snapshots"
        }
    }
}

and even with the startParam.excludedTaskNames set to exclude running plugin zip it still picks up the groupId defined in that pom section of the publication. The workaround that worked for this issue in notifications is not working for JS: #554

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

5 participants