diff --git a/build.gradle b/build.gradle index 1ef0b3e283a1..3f39259307f1 100755 --- a/build.gradle +++ b/build.gradle @@ -49,8 +49,11 @@ wrapper { } allprojects { - version = versionNumber + releaseQualifier + releaseType - ext.isReleaseVersion = !version.endsWith("SNAPSHOT") + ext.isReleaseVersion = true + if(version.contains("SNAPSHOT")) { + ext.isReleaseVersion = false + version = (version as String).replaceFirst(/SNAPSHOT.*/, 'SNAPSHOT') + } repositories { mavenLocal() diff --git a/ci/pipelines/geode-build/deploy_pipeline.sh b/ci/pipelines/geode-build/deploy_pipeline.sh index 0066f20b6614..bca3526aa153 100755 --- a/ci/pipelines/geode-build/deploy_pipeline.sh +++ b/ci/pipelines/geode-build/deploy_pipeline.sh @@ -73,6 +73,7 @@ version-bucket: ${VERSION_BUCKET} artifact-bucket: ${ARTIFACT_BUCKET} gradle-global-args: ${GRADLE_GLOBAL_ARGS} maven-snapshot-bucket: ${MAVEN_SNAPSHOT_BUCKET} +semver-prerelease-token: ${SEMVER_PRERELEASE_TOKEN} YML diff --git a/ci/pipelines/geode-build/jinja.template.yml b/ci/pipelines/geode-build/jinja.template.yml index eb1d24af9b4c..1d3aeda5dee3 100644 --- a/ci/pipelines/geode-build/jinja.template.yml +++ b/ci/pipelines/geode-build/jinja.template.yml @@ -197,7 +197,7 @@ jobs: trigger: true - get: geode-build-version params: - pre: build + pre: {{semver-prerelease-token}} - do: - put: concourse-metadata-resource - task: create_instance @@ -385,7 +385,7 @@ jobs: trigger: true - get: geode-build-version params: - pre: build + pre: {{semver-prerelease-token}} - do: - put: concourse-metadata-resource - task: create_instance diff --git a/ci/pipelines/meta/meta.properties b/ci/pipelines/meta/meta.properties index a5894c842168..66de26bcdabe 100644 --- a/ci/pipelines/meta/meta.properties +++ b/ci/pipelines/meta/meta.properties @@ -23,4 +23,5 @@ ARTIFACT_BUCKET=files.apachegeode-ci.info PUBLIC=true REPOSITORY_PUBLIC=true GRADLE_GLOBAL_ARGS="" -MAVEN_SNAPSHOT_BUCKET=maven.apachegeode-ci.info +MAVEN_SNAPSHOT_BUCKET=gcs://maven.apachegeode-ci.info/snapshot/ +SEMVER_PRERELEASE_TOKEN=SNAPSHOT diff --git a/ci/scripts/archive_results.sh b/ci/scripts/archive_results.sh index 88bf95b3814e..d9261faa8d35 100755 --- a/ci/scripts/archive_results.sh +++ b/ci/scripts/archive_results.sh @@ -48,7 +48,6 @@ fi SANITIZED_GRADLE_TASK=${GRADLE_TASK##*:} TMPDIR=${DEST_DIR}/tmp GEODE_BUILD=${DEST_DIR}/geode -GEODE_BUILD_VERSION_NUMBER=$(echo "${GRADLE_GLOBAL_ARGS}"|tr ' ' '\n' | grep "versionNumber *=" - ${GEODE_BUILD}/gradle.properties | awk -F "=" '{print $2; exit}' | tr -d ' ') BUILD_TIMESTAMP=$(date +%s) GEODE_PULL_REQUEST_ID_FILE=${BUILDROOT}/geode/.git/resource/version.json @@ -68,21 +67,31 @@ if [ -z ${MAINTENANCE_VERSION+x} ]; then exit 1 fi -if [ -z "${GEODE_PULL_REQUEST_ID}" ]; then +if [ -e "${GEODE_PULL_REQUEST_ID_FILE}" ]; then + GEODE_PULL_REQUEST_ID=$(cat ${GEODE_PULL_REQUEST_ID_FILE}) + FULL_PRODUCT_VERSION="geode-pr-${GEODE_PULL_REQUEST_ID}" +else + # semver resource, e.g., "1.9.0-SNAPSHOT.325" CONCOURSE_VERSION=$(cat ${GEODE_BUILD_VERSION_FILE}) - CONCOURSE_PRODUCT_VERSION=${CONCOURSE_VERSION%%-*} - GEODE_PRODUCT_VERSION=${GEODE_BUILD_VERSION_NUMBER} + # Prune all after '-', yielding e.g., "1.9.0" + GEODE_PRODUCT_VERSION=${CONCOURSE_VERSION%%-*} + # Prune all before '-', yielding e.g., "SNAPSHOT.325" CONCOURSE_BUILD_SLUG=${CONCOURSE_VERSION##*-} - BUILD_ID=${CONCOURSE_VERSION##*.} - FULL_PRODUCT_VERSION=${GEODE_PRODUCT_VERSION}-${CONCOURSE_BUILD_SLUG} + # Prune all before '.', yielding e.g., "SNAPSHOT" + SNAPSHOT_SLUG=${CONCOURSE_BUILD_SLUG##*.} + # Prune all before '.', yielding e.g., "325" + BUILD_ID=$(printf "%04d" ${CONCOURSE_VERSION##*.}) + + # Rebuild version, zero-padded + FULL_PRODUCT_VERSION=${GEODE_PRODUCT_VERSION}-${SNAPSHOT_SLUG}.${BUILD_ID} echo "Concourse VERSION is ${CONCOURSE_VERSION}" echo "Geode product VERSION is ${GEODE_PRODUCT_VERSION}" + echo "Full product VERSION is ${FULL_PRODUCT_VERSION}" echo "Build ID is ${BUILD_ID}" -else - FULL_PRODUCT_VERSION="geode-pr-${GEODE_PULL_REQUEST_ID}" fi + directories_file=${DEST_DIR}/artifact_directories mkdir -p ${TMPDIR} diff --git a/ci/scripts/execute_build.sh b/ci/scripts/execute_build.sh index ff23960f9648..e057badc96e9 100755 --- a/ci/scripts/execute_build.sh +++ b/ci/scripts/execute_build.sh @@ -41,7 +41,6 @@ BUILD_DATE=$(date +%s) if [ -e "${ROOT_DIR}/geode-build-version" ] ; then GEODE_BUILD_VERSION_FILE=${ROOT_DIR}/geode-build-version/number GEODE_RESULTS_VERSION_FILE=${ROOT_DIR}/results/number - GEODE_BUILD_VERSION_NUMBER=$(echo "${GRADLE_GLOBAL_ARGS}"|tr ' ' '\n' | grep "versionNumber *=" - geode/gradle.properties | awk -F "=" '{print $2; exit}' | tr -d ' ') GEODE_BUILD_DIR=/tmp/geode-build GEODE_PULL_REQUEST_ID_FILE=${ROOT_DIR}/geode/.git/id @@ -49,14 +48,23 @@ if [ -e "${ROOT_DIR}/geode-build-version" ] ; then GEODE_PULL_REQUEST_ID=$(cat ${GEODE_PULL_REQUEST_ID_FILE}) FULL_PRODUCT_VERSION="geode-pr-${GEODE_PULL_REQUEST_ID}" else + # semver resource, e.g., "1.9.0-SNAPSHOT.325" CONCOURSE_VERSION=$(cat ${GEODE_BUILD_VERSION_FILE}) - CONCOURSE_PRODUCT_VERSION=${CONCOURSE_VERSION%%-*} - GEODE_PRODUCT_VERSION=${GEODE_BUILD_VERSION_NUMBER} + # Prune all after '-', yielding e.g., "1.9.0" + GEODE_PRODUCT_VERSION=${CONCOURSE_VERSION%%-*} + # Prune all before '-', yielding e.g., "SNAPSHOT.325" CONCOURSE_BUILD_SLUG=${CONCOURSE_VERSION##*-} - BUILD_ID=${CONCOURSE_VERSION##*.} - FULL_PRODUCT_VERSION=${GEODE_PRODUCT_VERSION}-${CONCOURSE_BUILD_SLUG} + # Prune all before '.', yielding e.g., "SNAPSHOT" + SNAPSHOT_SLUG=${CONCOURSE_BUILD_SLUG##*.} + # Prune all before '.', yielding e.g., "325" + BUILD_ID=$(printf "%04d" ${CONCOURSE_VERSION##*.}) + + # Rebuild version, zero-padded + FULL_PRODUCT_VERSION=${GEODE_PRODUCT_VERSION}-${SNAPSHOT_SLUG}.${BUILD_ID} + echo "Concourse VERSION is ${CONCOURSE_VERSION}" echo "Geode product VERSION is ${GEODE_PRODUCT_VERSION}" + echo "Full product VERSION is ${FULL_PRODUCT_VERSION}" echo "Build ID is ${BUILD_ID}" fi @@ -99,6 +107,7 @@ GRADLE_ARGS="\ ${DEFAULT_GRADLE_TASK_OPTIONS} \ ${GRADLE_SKIP_TASK_OPTIONS} \ ${GRADLE_GLOBAL_ARGS} \ + -Pversion=${FULL_PRODUCT_VERSION} \ -PbuildId=${BUILD_ID} \ build install javadoc spotlessCheck rat checkPom resolveDependencies -x test" diff --git a/ci/scripts/execute_publish.sh b/ci/scripts/execute_publish.sh index c0e3f7bf9ebf..be5c348a9c68 100755 --- a/ci/scripts/execute_publish.sh +++ b/ci/scripts/execute_publish.sh @@ -37,7 +37,6 @@ EMAIL_BODY="results/body" GEODE_BUILD_VERSION_FILE=${ROOT_DIR}/geode-build-version/number GEODE_RESULTS_VERSION_FILE=${ROOT_DIR}/results/number -GEODE_BUILD_VERSION_NUMBER=$(echo "${GRADLE_GLOBAL_ARGS}"|tr ' ' '\n' | grep "versionNumber *=" - geode/gradle.properties | awk -F "=" '{print $2; exit}' | tr -d ' ') GEODE_BUILD_DIR=/tmp/geode-build GEODE_PULL_REQUEST_ID_FILE=${ROOT_DIR}/geode/.git/id @@ -45,14 +44,23 @@ if [ -e "${GEODE_PULL_REQUEST_ID_FILE}" ]; then GEODE_PULL_REQUEST_ID=$(cat ${GEODE_PULL_REQUEST_ID_FILE}) FULL_PRODUCT_VERSION="geode-pr-${GEODE_PULL_REQUEST_ID}" else + # semver resource, e.g., "1.9.0-SNAPSHOT.325" CONCOURSE_VERSION=$(cat ${GEODE_BUILD_VERSION_FILE}) - CONCOURSE_PRODUCT_VERSION=${CONCOURSE_VERSION%%-*} - GEODE_PRODUCT_VERSION=${GEODE_BUILD_VERSION_NUMBER} + # Prune all after '-', yielding e.g., "1.9.0" + GEODE_PRODUCT_VERSION=${CONCOURSE_VERSION%%-*} + # Prune all before '-', yielding e.g., "SNAPSHOT.325" CONCOURSE_BUILD_SLUG=${CONCOURSE_VERSION##*-} - BUILD_ID=${CONCOURSE_VERSION##*.} - FULL_PRODUCT_VERSION=${GEODE_PRODUCT_VERSION}-${CONCOURSE_BUILD_SLUG} + # Prune all before '.', yielding e.g., "SNAPSHOT" + SNAPSHOT_SLUG=${CONCOURSE_BUILD_SLUG##*.} + # Prune all before '.', yielding e.g., "325" + BUILD_ID=$(printf "%04d" ${CONCOURSE_VERSION##*.}) + + # Rebuild version, zero-padded + FULL_PRODUCT_VERSION=${GEODE_PRODUCT_VERSION}-${SNAPSHOT_SLUG}.${BUILD_ID} + echo "Concourse VERSION is ${CONCOURSE_VERSION}" echo "Geode product VERSION is ${GEODE_PRODUCT_VERSION}" + echo "Full product VERSION is ${FULL_PRODUCT_VERSION}" echo "Build ID is ${BUILD_ID}" fi @@ -68,7 +76,10 @@ SET_JAVA_HOME="export JAVA_HOME=/usr/lib/jvm/java-${JAVA_BUILD_VERSION}-openjdk- GRADLE_COMMAND="./gradlew \ ${DEFAULT_GRADLE_TASK_OPTIONS} \ ${GRADLE_GLOBAL_ARGS} \ - -PbuildId=${BUILD_ID} -PmavenSnapshotBucket=${MAVEN_SNAPSHOT_BUCKET} publish" + -Pversion=${FULL_PRODUCT_VERSION} \ + -PbuildId=${BUILD_ID} \ + -PmavenRepository=\"${MAVEN_SNAPSHOT_BUCKET}\" \ + publish" echo "${GRADLE_COMMAND}" ssh ${SSH_OPTIONS} geode@${INSTANCE_IP_ADDRESS} "mkdir -p tmp && cd geode && ${SET_JAVA_HOME} && ${GRADLE_COMMAND}" diff --git a/gradle.properties b/gradle.properties index a9b44e40b34f..19983a48ea76 100755 --- a/gradle.properties +++ b/gradle.properties @@ -16,20 +16,23 @@ # Version information for use by Maven artifacts -# The full version string consists of 'versionNumber + releaseQualifier + releaseType' # # The versionNumber follows semantic versioning conventions. -versionNumber = 1.9.0 - +# X.Y.Z - major.minor.patch # The releaseQualifier uses the following conventions: # .M? - milestone release # -beta.? - beta release # - release -releaseQualifier = # The releaseType uses the following conventions: # -SNAPSHOT - development version # - release -releaseType = -SNAPSHOT +# +# The full version string consists of 'versionNumber + releaseQualifier + releaseType' +version = 1.9.0-SNAPSHOT + +# Default Maven targets +mavenSnapshotUrl = "gcs://maven.apachegeode-ci.info/snapshots" +mavenReleaseUrl = "https://repository.apache.org/service/local/staging/deploy/maven2" # Maven also uses the project group as a prefix. group = org.apache.geode diff --git a/gradle/publish.gradle b/gradle/publish.gradle index 40da7df07572..927aebd7eeab 100644 --- a/gradle/publish.gradle +++ b/gradle/publish.gradle @@ -34,58 +34,56 @@ publishing { maven(MavenPublication) { from components.java - afterEvaluate { - // uses the tasks created by nexus for sources and javadoc - if (!getTasksByName('sourcesJar', false).isEmpty()) { - artifact sourcesJar + // use the (possibly empty) Jar tasks above for sources and javadoc + artifact sourcesJar + artifact javadocJar + + pom { + name = 'Apache Geode' + description = 'Apache Geode provides a database-like consistency model, reliable transaction processing and a shared-nothing architecture to maintain very low latency performance with high concurrency processing' + url = 'http://geode.apache.org' + + scm { + url = 'https://github.com/apache/geode' + connection = 'scm:git:https://github.com:apache/geode.git' + developerConnection = 'scm:git:https://github.com:apache/geode.git' } - if (!getTasksByName('javadocJar', false).isEmpty()) { - artifact javadocJar - } - - pom { - name = 'Apache Geode' - description = 'Apache Geode provides a database-like consistency model, reliable transaction processing and a shared-nothing architecture to maintain very low latency performance with high concurrency processing' - url = 'http://geode.apache.org' - scm { - url = 'https://github.com/apache/geode' - connection = 'scm:git:https://github.com:apache/geode.git' - developerConnection = 'scm:git:https://github.com:apache/geode.git' + licenses { + license { + name = 'The Apache Software License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' } + } - licenses { - license { - name = 'The Apache Software License, Version 2.0' - url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } + withXml { + // This black magic checks to see if a dependency has the flag ext.optional=true + // set on it, and if so marks the dependency as optional in the maven pom + def depMap = project.configurations.compile.dependencies.collectEntries { [it.name, it] } + def runtimeDeps = project.configurations.runtime.dependencies.collectEntries { + [it.name, it] } - - withXml { - //This black magic checks to see if a dependency has the flag ext.optional=true - //set on it, and if so marks the dependency as optional in the maven pom - def depMap = project.configurations.compile.dependencies.collectEntries { [it.name, it] } - def runtimeDeps = project.configurations.runtime.dependencies.collectEntries { [it.name, it] } - def runtimeOnlyDeps = project.configurations.runtimeOnly.dependencies.collectEntries { [it.name, it] } - depMap.putAll(runtimeDeps) - depMap.putAll(runtimeOnlyDeps) - asNode().dependencies.dependency.findAll { - def dep = depMap.get(it.artifactId.text()) - return dep?.hasProperty('optional') && dep.optional - }.each { - if (it.optional) { - it.optional.value = 'true' - } else { - it.appendNode('optional', 'true') - } + def runtimeOnlyDeps = project.configurations.runtimeOnly.dependencies.collectEntries { + [it.name, it] + } + depMap.putAll(runtimeDeps) + depMap.putAll(runtimeOnlyDeps) + asNode().dependencies.dependency.findAll { + def dep = depMap.get(it.artifactId.text()) + return dep?.hasProperty('optional') && dep.optional + }.each { + if (it.optional) { + it.optional.value = 'true' + } else { + it.appendNode('optional', 'true') } } } - pom { - withXml { - def elem = asElement() - def hdr = elem.ownerDocument().createComment( - ''' + + withXml { + def elem = asElement() + def hdr = elem.ownerDocument().createComment( + ''' Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. @@ -101,34 +99,19 @@ publishing { See the License for the specific language governing permissions and limitations under the License. ''') - elem.insertBefore(hdr, elem.firstChild) - } + elem.insertBefore(hdr, elem.firstChild) } } } } repositories { maven { - if (project.hasProperty("mavenRepository")) { - url = project.mavenRepository - } else if (project.isReleaseVersion) { - url = "https://repository.apache.org/service/local/staging/deploy/maven2" - } else if (project.hasProperty("mavenSnapshotBucket")) { - // If testing from a non-GCE instance, then the shell needs service-account creds - // following the instructions at https://cloud.google.com/docs/authentication/production - url = "gcs://$project.mavenSnapshotBucket/snapshots" - } else { - url = "gcs://maven.apachegeode-ci.info/snapshots" - } - if (!url.toString().startsWith("gcs:")) { - credentials { - if (project.hasProperty("mavenUsername")) { - username = project.mavenUsername - } - if (project.hasProperty("mavenPassword")) { - password = project.mavenPassword - } - } + // Use specified mavenRepository if provided, else use release or snapshot defaults. + url = project.findProperty("mavenRepository") || + project.isReleaseVersion ? project.mavenReleaseUrl : project.mavenSnapshotUrl + credentials { + username project.findProperty("mavenUsername") + password project.findProperty("mavenPassword") } } }