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 to configure POM for ZIP publication #3252

Merged
merged 1 commit into from
May 10, 2022

Conversation

reta
Copy link
Collaborator

@reta reta commented May 9, 2022

Signed-off-by: Andriy Redko [email protected]

Description

Allow to configure POM for ZIP publication using DSL

publishing {
    publications {
        pluginZip(MavenPublication) { publication ->
            pom {
              name = pluginName
              description = pluginDescription
              licenses {
                license {
                  name = "The Apache License, Version 2.0"
                  url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
                }
              }
              developers {
                developer {
                  name = "OpenSearch"
                  url = "https://github.com/opensearch-project/opensearch-plugin-template-java"
                }
              }
            }
        }
    }
}

Issues Resolved

Related to opensearch-project/opensearch-plugin-template-java#31

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@reta reta requested a review from a team as a code owner May 9, 2022 14:45
@reta
Copy link
Collaborator Author

reta commented May 9, 2022

@dblock @prudhvigodithi could you folks please take a look?

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success a64bf2be45c203668557721b84c61f2978f3f22f
Log 5161

Reports 5161

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 4402e7772f8ec08e360e2855bb50f9697d66cf80
Log 5174

Reports 5174

@prudhvigodithi
Copy link
Contributor

Hey @reta please check this comment added on opensearch-plugin-template-java PR.
Thank you

@reta reta changed the title Generating POM for ZIP publication using project.ext properties Allow to configure POM for ZIP publication May 10, 2022
@reta
Copy link
Collaborator Author

reta commented May 10, 2022

@prudhvigodithi I think we are getting there - clean and concise way to customize plugin's ZIP POM file:

publishing {
    publications {
        pluginZip(MavenPublication) { publication ->
            pom {
              name = pluginName
              description = pluginDescription
              licenses {
                license {
                  name = "The Apache License, Version 2.0"
                  url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
                }
              }
              developers {
                developer {
                  name = "OpenSearch"
                  url = "https://github.com/opensearch-project/opensearch-plugin-template-java"
                }
              }
            }
        }
    }
}

@prudhvigodithi
Copy link
Contributor

Hey @reta, looks to me this neat, but this is only for zip's right, for jars, users need to declare it separately again? if so it should be fine as well, as we might need to isolate the pom fields for both, in future we might have unique fields per publication.

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 7720ae0
Log 5195

Reports 5195

mavenZip.setArtifactId(zipArtifact);
mavenZip.setVersion(zipVersion);
});
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reta we need this if/else condition so that user can declare a publication of pluginZip and pom fields ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@@ -72,10 +82,8 @@ public void apply(Project project) {
}
Task publishPluginZipPublicationToZipStagingRepository = project.getTasks()
.findByName("publishPluginZipPublicationToZipStagingRepository");
if (validatePluginZipPom != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might still need this @reta
The reason I have added this because I got the following warning
Error:

> Task :validatePluginZipPom
Execution optimizations have been disabled for task ':validatePluginZipPom' to ensure correctness due to the following reasons:
  - Gradle detected a problem with the following location: '/usr/share/opensearch/git/opensearch-plugin-template-java/build/distributions/rename-unspecified.pom'. Reason: Task ':validatePluginZipPom' uses this output of task ':generatePomFileForNebulaPublication' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.4.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validatePluginZipPom is above, I did not touch it: https://github.com/opensearch-project/OpenSearch/pull/3252/files/7720ae0d0412a97b77d1077be08cca6a95eedecf#diff-2a5851da2408bbeb8733433421917f253614fffe49449da0dd315a15ed8cdf74R80

This condition should be for publishPluginZipPublicationToZipStagingRepository, not validatePluginZipPom

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol my bad, this formatting looks like it was removed, yes I can see those 2 conditions are not touched.

@reta
Copy link
Collaborator Author

reta commented May 10, 2022

Hey @reta, looks to me this neat, but this is only for zip's right, for jars, users need to declare it separately again? if so it should be fine as well, as we might need to isolate the pom fields for both, in future we might have unique fields per publication.

Correct, this is per publication

@prudhvigodithi
Copy link
Contributor

Hey @reta
I get the following error when tested with these new changes
Cannot add a Publication with name 'pluginZip' as a Publication with that name already exists.
build.gradle

@reta
Copy link
Collaborator Author

reta commented May 10, 2022

Hey @reta I get the following error when tested with these new changes Cannot add a Publication with name 'pluginZip' as a Publication with that name already exists. build.gradle

@prudhvigodithi I assume you pulled this pull request, republished local artifacts and used 3.0.0-SNAPSHOT version for opensearch (unless you cherry-picked the change to another branch), right?

./gradlew clean test publishPluginZipPublicationToZipStagingRepository

BUILD SUCCESSFUL in 16s   

@prudhvigodithi
Copy link
Contributor

Hey @reta I get the following error when tested with these new changes Cannot add a Publication with name 'pluginZip' as a Publication with that name already exists. build.gradle

@prudhvigodithi I assume you pulled this pull request, republished local artifacts and used 3.0.0-SNAPSHOT version for opensearch (unless you cherry-picked the change to another branch), right?

./gradlew clean test publishPluginZipPublicationToZipStagingRepository

BUILD SUCCESSFUL in 16s   

Hey @reta i'm testing with actual plugin, above seems to my local gradle cache issue, but still I get another error as

2022-05-10T15:43:57.932+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2022-05-10T15:43:57.932+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
2022-05-10T15:43:57.932+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2022-05-10T15:43:57.932+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
2022-05-10T15:43:57.932+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':publishPluginZipPublicationToZipStagingRepository'.
2022-05-10T15:43:57.932+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Failed to publish publication 'pluginZip' to repository 'zipStaging'
2022-05-10T15:43:57.932+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]    > Invalid publication 'pluginZip': POM file is invalid. Check any modifications you have made to the POM file.

job-scheduler build.gradle

@reta
Copy link
Collaborator Author

reta commented May 10, 2022

Hey @reta I get the following error when tested with these new changes Cannot add a Publication with name 'pluginZip' as a Publication with that name already exists. build.gradle

@prudhvigodithi I assume you pulled this pull request, republished local artifacts and used 3.0.0-SNAPSHOT version for opensearch (unless you cherry-picked the change to another branch), right?

./gradlew clean test publishPluginZipPublicationToZipStagingRepository

BUILD SUCCESSFUL in 16s   

Hey @reta i'm testing with actual plugin, above seems to my local gradle cache issue, but still I get another error as

2022-05-10T15:43:57.932+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2022-05-10T15:43:57.932+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
2022-05-10T15:43:57.932+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2022-05-10T15:43:57.932+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
2022-05-10T15:43:57.932+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':publishPluginZipPublicationToZipStagingRepository'.
2022-05-10T15:43:57.932+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Failed to publish publication 'pluginZip' to repository 'zipStaging'
2022-05-10T15:43:57.932+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]    > Invalid publication 'pluginZip': POM file is invalid. Check any modifications you have made to the POM file.

job-scheduler build.gradle

@prudhvigodithi sorry, I have difficulties to follow what you are doing, these are the changes I did https://github.com/opensearch-project/job-scheduler/compare/main...reta:publishzip?expand=1

@prudhvigodithi
Copy link
Contributor

@reta now I get this, why testing fails, as allProjects settings overrides the declared publishing settings, hence failed to append license and developer fields, once merged I might need to add this point to the document.

@prudhvigodithi
Copy link
Contributor

prudhvigodithi commented May 10, 2022

Once merged, I will update the existing opensearch-plugin-template-java PR https://github.com/opensearch-project/opensearch-plugin-template-java/pull/31/files with new POM declaration format.
@dblock @bbarani

@reta reta merged commit f5c0b30 into opensearch-project:main May 10, 2022
opensearch-trigger-bot bot pushed a commit that referenced this pull request May 10, 2022
Signed-off-by: Andriy Redko <[email protected]>
(cherry picked from commit f5c0b30)
opensearch-trigger-bot bot pushed a commit that referenced this pull request May 10, 2022
Signed-off-by: Andriy Redko <[email protected]>
(cherry picked from commit f5c0b30)
@dblock
Copy link
Member

dblock commented May 10, 2022

Please update https://github.com/opensearch-project/opensearch-plugins/blob/main/BUILDING.md#custom-gradle-plugins too!

dblock pushed a commit that referenced this pull request May 10, 2022
Signed-off-by: Andriy Redko <[email protected]>
(cherry picked from commit f5c0b30)

Co-authored-by: Andriy Redko <[email protected]>
dblock pushed a commit that referenced this pull request May 10, 2022
Signed-off-by: Andriy Redko <[email protected]>
(cherry picked from commit f5c0b30)

Co-authored-by: Andriy Redko <[email protected]>
@prudhvigodithi
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch backport 2.0 Backport to 2.0 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants