Skip to content

Commit

Permalink
Update build.gradle to include job-scheduler jar in staging maven pub…
Browse files Browse the repository at this point in the history
…lications. (opensearch-project#117)

This change updates build.gradle to ensure the base jar has the required pom fields for publishing to maven central.
It also updates to include this jar when publishing to a local staging repository currently used by CI to pick up artifacts for promotion.

Signed-off-by: Marc Handalian <[email protected]>
  • Loading branch information
mch2 authored Jan 13, 2022
1 parent ff53a31 commit a67e734
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
34 changes: 34 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin

buildscript {
ext {
Expand Down Expand Up @@ -75,6 +76,39 @@ allprojects {
plugins.withId('java') {
sourceCompatibility = targetCompatibility = "1.8"
}

}
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'
plugins.withType(ShadowPlugin).whenPluginAdded {
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/job-scheduler')
}
}
}
}
}
}

repositories {
Expand Down
8 changes: 4 additions & 4 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ fi
[[ "$SNAPSHOT" == "true" ]] && VERSION=$VERSION-SNAPSHOT
[ -z "$OUTPUT" ] && OUTPUT=artifacts

./gradlew publishShadowPublicationToMavenLocal -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT
./gradlew publishShadowPublicationToStagingRepository -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT
mkdir -p $OUTPUT/maven/org/opensearch/opensearch-job-scheduler-spi
cp -r ./build/local-staging-repo/org/opensearch/opensearch-job-scheduler-spi $OUTPUT/maven/org/opensearch/opensearch-job-scheduler-spi
./gradlew publishToMavenLocal -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT
./gradlew publishAllPublicationsToStagingRepository -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT
mkdir -p $OUTPUT/maven/org/opensearch
cp -r ./build/local-staging-repo/org/opensearch/. $OUTPUT/maven/org/opensearch

./gradlew assemble --no-daemon --refresh-dependencies -DskipTests=true -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT
[ -z "$OUTPUT" ] && OUTPUT=artifacts
Expand Down
5 changes: 2 additions & 3 deletions spi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,8 @@ publishing {
}
developers {
developer {
id = "amazonwebservices"
organization = "Amazon Web Services"
organizationUrl = "https://aws.amazon.com"
name = "OpenSearch"
url = "https://github.com/opensearch-project/job-scheduler"
}
}
}
Expand Down

0 comments on commit a67e734

Please sign in to comment.