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

[WIP]Mechanism to push zip plugins. #1757

Closed
wants to merge 15 commits into from
10 changes: 10 additions & 0 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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-<version>.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
```
<groupId>org.opensearch.plugin</groupId>
<artifactId>opensearch-security</artifactId>
<version><version></version>
<packaging>zip</packaging>
```
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

Expand Down
101 changes: 101 additions & 0 deletions maven/plugin-zips/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
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 <packaging>zip</packaging> 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
}
}
}
4 changes: 4 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
*/

rootProject.name = 'opensearch-security'

//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')