From 1c6c53ef7831bbf606ee18c6b86f2da340abaa5f Mon Sep 17 00:00:00 2001 From: pgodithi Date: Sat, 9 Apr 2022 06:23:01 -0700 Subject: [PATCH 01/14] zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi Adding code block for maven plugin zips Signed-off-by: pgodithi Adding code block for maven plugin zips Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi zip maven publish Signed-off-by: pgodithi --- build.gradle | 2 +- settings.gradle | 1 + zipsmaven/build.gradle | 102 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 zipsmaven/build.gradle diff --git a/build.gradle b/build.gradle index 550fc0f6bc..a35d30d0a1 100644 --- a/build.gradle +++ b/build.gradle @@ -413,4 +413,4 @@ allprojects { println "" } } -} +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 1c3e7ff5aa..26fbb07b83 100644 --- a/settings.gradle +++ b/settings.gradle @@ -5,3 +5,4 @@ */ rootProject.name = 'opensearch-security' +include "zipsmaven" diff --git a/zipsmaven/build.gradle b/zipsmaven/build.gradle new file mode 100644 index 0000000000..a13106ee23 --- /dev/null +++ b/zipsmaven/build.gradle @@ -0,0 +1,102 @@ +plugins { + id 'maven-publish' +} + +ext { + isSnapshot = "true" == System.getProperty("build.snapshot", "true") + opensearch_version = System.getProperty("opensearch.version", "2.0.0-alpha1-SNAPSHOT") + buildVersionQualifier = System.getProperty("build.version_qualifier", "alpha1") + // 2.0.0-alpha1-SNAPSHOT -> 2.0.0.0-alpha1-SNAPSHOT + version_tokens = opensearch_version.tokenize('-') + opensearch_build = version_tokens[0] + '.0' + if (buildVersionQualifier) { + opensearch_build += "-${buildVersionQualifier}" + opensearch_build_nosnapshot = opensearch_build + } + if (isSnapshot) { + opensearch_build += "-SNAPSHOT" + } +} + + +allprojects { + // Default to the apache license + project.ext.licenseName = 'The Apache Software License, Version 2.0' + project.ext.licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + publishing { + repositories { + maven { + name = 'staging' + url = "${rootProject.buildDir}/local-staging-repo" + } + } + publications { + // add license information to generated poms + all { + pom.withXml { XmlProvider xml -> + Node node = xml.asNode() + node.appendNode('inceptionYear', '2021') + + Node license = node.appendNode('licenses').appendNode('license') + license.appendNode('name', project.licenseName) + license.appendNode('url', project.licenseUrl) + + Node developer = node.appendNode('developers').appendNode('developer') + developer.appendNode('name', 'OpenSearch') + developer.appendNode('url', 'https://github.com/opensearch-project/security') + } + } + } + } +} + +def group = "org.opensearch.plugin" +def pluginversion = opensearch_build +def component = "opensearch-security" +def description = "OpenSearch Security plugin Zip" +def zipFile = "${component}-${pluginversion}.zip" +def zipArtifact = "${rootProject.buildDir}/distributions/${zipFile}" + + +publishing { + publications { + maven(MavenPublication) { + //Add ext.publish = 'skip' to skip publishing skip to maven staging repo + groupId = "${group}" + artifactId = "${component}" + version = "${pluginversion}" + // Add extension, to get zip as in pom file + artifact(zipArtifact) { + extension 'zip' + } + pom { + name = "${component}" + description = "${description}" + } + } + } +} + +task printZipsPublishProperty { + doLast { + tasks.withType(PublishToMavenRepository).all { publishTask -> + if (publication.hasProperty('publish')) { + println(publication.publish) + }else { + println("null") + } + } + } +} + +afterEvaluate { + tasks.withType(PublishToMavenRepository).all { publishTask -> + publishTask.onlyIf { task -> + if (publication.hasProperty('publish') && publication.publish == 'skip') { + return false + } + return true + } + } +} + From c6b81bc8150039ad40f69f4fee96a31e00a051f9 Mon Sep 17 00:00:00 2001 From: pgodithi Date: Mon, 11 Apr 2022 09:01:01 -0700 Subject: [PATCH 02/14] Adding better gradle project dir Signed-off-by: pgodithi --- {zipsmaven => maven/plugin-zips}/build.gradle | 0 settings.gradle | 5 ++++- 2 files changed, 4 insertions(+), 1 deletion(-) rename {zipsmaven => maven/plugin-zips}/build.gradle (100%) diff --git a/zipsmaven/build.gradle b/maven/plugin-zips/build.gradle similarity index 100% rename from zipsmaven/build.gradle rename to maven/plugin-zips/build.gradle diff --git a/settings.gradle b/settings.gradle index 26fbb07b83..4077b95925 100644 --- a/settings.gradle +++ b/settings.gradle @@ -5,4 +5,7 @@ */ rootProject.name = 'opensearch-security' -include "zipsmaven" + +//Adding pluginZips project under maven folder, this is to publish generated plugin zips to maven repo +include 'pluginZips' +project(':pluginZips').projectDir = file('maven/plugin-zips') From e60fa660b68e922f36e2c02fe4328233d8ede89b Mon Sep 17 00:00:00 2001 From: pgodithi Date: Mon, 11 Apr 2022 09:04:37 -0700 Subject: [PATCH 03/14] Adding better gradle project dir Signed-off-by: pgodithi --- maven/plugin-zips/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/maven/plugin-zips/build.gradle b/maven/plugin-zips/build.gradle index a13106ee23..cf1557de94 100644 --- a/maven/plugin-zips/build.gradle +++ b/maven/plugin-zips/build.gradle @@ -62,6 +62,7 @@ publishing { publications { maven(MavenPublication) { //Add ext.publish = 'skip' to skip publishing skip to maven staging repo + ext.publish = 'skip' groupId = "${group}" artifactId = "${component}" version = "${pluginversion}" From ea06f383f271029b1b233aabe2612cf635693d3e Mon Sep 17 00:00:00 2001 From: pgodithi Date: Mon, 11 Apr 2022 09:06:05 -0700 Subject: [PATCH 04/14] Adding better gradle project dir Signed-off-by: pgodithi --- maven/plugin-zips/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/maven/plugin-zips/build.gradle b/maven/plugin-zips/build.gradle index cf1557de94..a13106ee23 100644 --- a/maven/plugin-zips/build.gradle +++ b/maven/plugin-zips/build.gradle @@ -62,7 +62,6 @@ publishing { publications { maven(MavenPublication) { //Add ext.publish = 'skip' to skip publishing skip to maven staging repo - ext.publish = 'skip' groupId = "${group}" artifactId = "${component}" version = "${pluginversion}" From f3669bc38243fe0bdb638d7c78094ac5736a603f Mon Sep 17 00:00:00 2001 From: pgodithi Date: Mon, 11 Apr 2022 10:32:27 -0700 Subject: [PATCH 05/14] Adding better gradle project dir Signed-off-by: pgodithi --- maven/plugin-zips/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/maven/plugin-zips/build.gradle b/maven/plugin-zips/build.gradle index a13106ee23..3fbb50926f 100644 --- a/maven/plugin-zips/build.gradle +++ b/maven/plugin-zips/build.gradle @@ -63,6 +63,7 @@ publishing { maven(MavenPublication) { //Add ext.publish = 'skip' to skip publishing skip to maven staging repo groupId = "${group}" + ext.publish = 'skip' artifactId = "${component}" version = "${pluginversion}" // Add extension, to get zip as in pom file From 6c9b65139b36a0d1f6b380b8114f519f16409da9 Mon Sep 17 00:00:00 2001 From: pgodithi Date: Mon, 11 Apr 2022 10:33:44 -0700 Subject: [PATCH 06/14] Adding better gradle project dir Signed-off-by: pgodithi --- maven/plugin-zips/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/maven/plugin-zips/build.gradle b/maven/plugin-zips/build.gradle index 3fbb50926f..a13106ee23 100644 --- a/maven/plugin-zips/build.gradle +++ b/maven/plugin-zips/build.gradle @@ -63,7 +63,6 @@ publishing { maven(MavenPublication) { //Add ext.publish = 'skip' to skip publishing skip to maven staging repo groupId = "${group}" - ext.publish = 'skip' artifactId = "${component}" version = "${pluginversion}" // Add extension, to get zip as in pom file From a2e998adcdf2f9950ce1943ea09575e04715192a Mon Sep 17 00:00:00 2001 From: pgodithi Date: Mon, 11 Apr 2022 12:59:45 -0700 Subject: [PATCH 07/14] Added a readme info Signed-off-by: pgodithi --- DEVELOPER_GUIDE.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index d583cef0d5..ac08523bde 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -5,6 +5,7 @@ So you want to contribute code to this project? Excellent! We're glad you're her - [Prerequisites](#prerequisites) - [Native platforms](#native-platforms) - [Building](#building) + - [Publish zips to maven](#to-publish-generated-plugin-zips-to-maven-repo) - [Using IntelliJ IDEA](#using-intellij-idea) - [Submitting Changes](#submitting-changes) - [Backports](#backports) @@ -127,6 +128,15 @@ curl -XGET https://localhost:9200/_plugins/_security/authinfo -u 'admin:admin' - "sso_logout_url": null } ``` +## To Publish generated plugin zips to maven repo +The generated plugin zip `opensearch-security-.zip` after the build, inside the folder `build/distributions` can be published to maven repo. This can be done by including the project `pluginZips` inside `settings.gradle` file. Once added the generated plugin zip will be published to maven repo with following maven coordinates +``` + org.opensearch.plugin + opensearch-security + + zip +``` +To skip the publish, while this sub-project is still included, pass the flag as ` ext.publish = 'skip'` to file `build.gradle` inside `maven/plugin-zips/` folder. ## Using IntelliJ IDEA From cec70e9899d605237dc8844da41f8c73cb86da5d Mon Sep 17 00:00:00 2001 From: pgodithi Date: Mon, 11 Apr 2022 13:13:04 -0700 Subject: [PATCH 08/14] Fixed lint errors Signed-off-by: pgodithi --- maven/plugin-zips/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/maven/plugin-zips/build.gradle b/maven/plugin-zips/build.gradle index a13106ee23..7c49ec319f 100644 --- a/maven/plugin-zips/build.gradle +++ b/maven/plugin-zips/build.gradle @@ -99,4 +99,3 @@ afterEvaluate { } } } - From 107818cd339a37968e918d752ffc852a2b901f47 Mon Sep 17 00:00:00 2001 From: pgodithi Date: Mon, 11 Apr 2022 13:15:29 -0700 Subject: [PATCH 09/14] Fixed lint errors Signed-off-by: pgodithi --- maven/plugin-zips/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven/plugin-zips/build.gradle b/maven/plugin-zips/build.gradle index 7c49ec319f..9ef669ee77 100644 --- a/maven/plugin-zips/build.gradle +++ b/maven/plugin-zips/build.gradle @@ -98,4 +98,4 @@ afterEvaluate { return true } } -} +} \ No newline at end of file From f6d8ab292258fc674880dad4e7025672ff134291 Mon Sep 17 00:00:00 2001 From: pgodithi Date: Mon, 11 Apr 2022 13:22:08 -0700 Subject: [PATCH 10/14] Fixed lint errors Signed-off-by: pgodithi --- maven/plugin-zips/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maven/plugin-zips/build.gradle b/maven/plugin-zips/build.gradle index 9ef669ee77..6bab9135f2 100644 --- a/maven/plugin-zips/build.gradle +++ b/maven/plugin-zips/build.gradle @@ -9,13 +9,13 @@ ext { // 2.0.0-alpha1-SNAPSHOT -> 2.0.0.0-alpha1-SNAPSHOT version_tokens = opensearch_version.tokenize('-') opensearch_build = version_tokens[0] + '.0' - if (buildVersionQualifier) { + /*if (buildVersionQualifier) { opensearch_build += "-${buildVersionQualifier}" opensearch_build_nosnapshot = opensearch_build } if (isSnapshot) { opensearch_build += "-SNAPSHOT" - } + }*/ } From 8d1b8dd42f6deffb73a0869c2ad84ae676139c07 Mon Sep 17 00:00:00 2001 From: pgodithi Date: Mon, 11 Apr 2022 13:23:43 -0700 Subject: [PATCH 11/14] Fixed lint errors Signed-off-by: pgodithi --- maven/plugin-zips/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven/plugin-zips/build.gradle b/maven/plugin-zips/build.gradle index 6bab9135f2..1b8cddb59f 100644 --- a/maven/plugin-zips/build.gradle +++ b/maven/plugin-zips/build.gradle @@ -55,7 +55,7 @@ def pluginversion = opensearch_build def component = "opensearch-security" def description = "OpenSearch Security plugin Zip" def zipFile = "${component}-${pluginversion}.zip" -def zipArtifact = "${rootProject.buildDir}/distributions/${zipFile}" +def zipArtifact = "${rootProject.buildDir}/distributions/opensearch-security-2.0.0.0.zip" publishing { From 6278a23564f637c5dfd777c3e97dd1193de9453c Mon Sep 17 00:00:00 2001 From: pgodithi Date: Mon, 11 Apr 2022 13:25:10 -0700 Subject: [PATCH 12/14] Fixed lint errors Signed-off-by: pgodithi --- maven/plugin-zips/build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/maven/plugin-zips/build.gradle b/maven/plugin-zips/build.gradle index 1b8cddb59f..9ef669ee77 100644 --- a/maven/plugin-zips/build.gradle +++ b/maven/plugin-zips/build.gradle @@ -9,13 +9,13 @@ ext { // 2.0.0-alpha1-SNAPSHOT -> 2.0.0.0-alpha1-SNAPSHOT version_tokens = opensearch_version.tokenize('-') opensearch_build = version_tokens[0] + '.0' - /*if (buildVersionQualifier) { + if (buildVersionQualifier) { opensearch_build += "-${buildVersionQualifier}" opensearch_build_nosnapshot = opensearch_build } if (isSnapshot) { opensearch_build += "-SNAPSHOT" - }*/ + } } @@ -55,7 +55,7 @@ def pluginversion = opensearch_build def component = "opensearch-security" def description = "OpenSearch Security plugin Zip" def zipFile = "${component}-${pluginversion}.zip" -def zipArtifact = "${rootProject.buildDir}/distributions/opensearch-security-2.0.0.0.zip" +def zipArtifact = "${rootProject.buildDir}/distributions/${zipFile}" publishing { From 3d8daf967c8e5dd3a9f5b7f4b0640b126f98494f Mon Sep 17 00:00:00 2001 From: pgodithi Date: Mon, 11 Apr 2022 13:27:36 -0700 Subject: [PATCH 13/14] Fixed lint errors Signed-off-by: pgodithi --- maven/plugin-zips/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven/plugin-zips/build.gradle b/maven/plugin-zips/build.gradle index 9ef669ee77..7c49ec319f 100644 --- a/maven/plugin-zips/build.gradle +++ b/maven/plugin-zips/build.gradle @@ -98,4 +98,4 @@ afterEvaluate { return true } } -} \ No newline at end of file +} From c9f54c4ea4c6b7cd1f37889336a65c8a404c8d74 Mon Sep 17 00:00:00 2001 From: pgodithi Date: Mon, 11 Apr 2022 13:34:14 -0700 Subject: [PATCH 14/14] Fixed lint errors Signed-off-by: pgodithi --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index a35d30d0a1..550fc0f6bc 100644 --- a/build.gradle +++ b/build.gradle @@ -413,4 +413,4 @@ allprojects { println "" } } -} \ No newline at end of file +}