Skip to content

Commit

Permalink
Update to use Nebula-Release plugin (GoogleCloudPlatform#78)
Browse files Browse the repository at this point in the history
* Migrate to release plugin.

* Migrate to new publishing task instead of legacy version.

* Ignore mock server download.

* Fix signing, and create test publication for now.

* Fix signing and publishing for maven.

* Fix version issue.

* Add publish task to release automation.  Update docs for releasing snapshots.

* Bump versions to 0.14.0

* Fix Javadoc so that build succeeds (GoogleCloudPlatform#79)

Co-authored-by: Punya Biswal <[email protected]>
  • Loading branch information
jsuereth and punya authored Jan 28, 2021
1 parent fee5081 commit acd3d8e
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 48 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ out/
build/
bin/

# Mock server download
mock_server*
12 changes: 12 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ your OSSRH (OSS Repository Hosting) account and signing keys.
checkstyle.ignoreFailures=false
```
### Using GPG-Agent for artifact signing
## Download the mock server
- Run the `get_mock_server.sh` script, which downloads the [mock server
Expand All @@ -53,6 +56,15 @@ your OSSRH (OSS Repository Hosting) account and signing keys.
$ source ./get_mock_server.sh
```
## Release a Snapshot
If you've followed the above steps, you can release snapshots for consumption using the following:
```bash
$ ./gradlew snapshot -Dmock.server.path=$MOCKSERVER
```


## Tagging the Release

The first step in the release process is to create a release branch, bump
Expand Down
133 changes: 92 additions & 41 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,44 @@
* limitations under the License.
*/

import nebula.plugin.release.git.opinion.Strategies
plugins {
id "com.diffplug.spotless"
id 'nebula.release'
}

// Configure release mechanism.
// Nebula plugin will not configure if .git doesn't exist, let's allow building on it by stubbing it
// out. This supports building from the zip archive downloaded from GitHub.
def releaseTask
if (file('.git').exists()) {
release {
defaultVersionStrategy = Strategies.getSNAPSHOT()
}
nebulaRelease {
addReleaseBranchPattern(/v\d+\.\d+\.x/)
}

releaseTask = tasks.named("release")
releaseTask.configure {
mustRunAfter("snapshotSetup", "finalSetup")
}
} else {
releaseTask = tasks.register('release')
}

ext.isReleaseVersion = !version.toString().endsWith("-SNAPSHOT")

subprojects {
apply plugin: 'jacoco'
apply plugin: 'java-library'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'com.diffplug.spotless'

apply plugin: 'nebula.nebula-release'
group = "com.google.cloud.opentelemetry"
version = "0.13.1-SNAPSHOT" // CURRENT_VERSION
version = "0.14.0-SNAPSHOT" // CURRENT_VERSION

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -39,8 +65,10 @@ subprojects {

// Set up java codestyle checking and correction.
plugins.withId("java") {
plugins.apply('checkstyle')
plugins.apply('com.diffplug.spotless')

// Configure our default module name for maven publishing
archivesBaseName = "${project.name}"
}

// Include license check and auto-format support.
Expand Down Expand Up @@ -117,60 +145,83 @@ subprojects {
archives javadocJar, sourcesJar
}

signing {
required false
// Allow using the GPG agent on linux instead of passwords in a .properties file.
if (rootProject.hasProperty('signingUseGpgCmd')) {
useGpgCmd()
javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
sign configurations.archives
}

uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
java {
withJavadocJar()
withSourcesJar()
}

releaseTask.configure {
finalizedBy(tasks.named('publish'))
}

def configureAuth = {
if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword)
}
publishing {
publications {
maven(MavenPublication) {
from components.java
groupId = 'com.google.cloud.opentelemetry'
afterEvaluate {
artifactId = archivesBaseName
}

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/", configureAuth)

snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/", configureAuth)

pom.project {
name 'OpenTelemetry Operations Java'
description 'OpenTelemetry exporters to Google Cloud Trace and Google Cloud Monitoring'
packaging 'jar'
url 'https://github.com/GoogleCloudPlatform/opentelemetry-operations-java'

scm {
connection 'scm:git:https://github.com/GoogleCloudPlatform/opentelemetry-operations-java'
developerConnection 'scm:git:https://github.com/GoogleCloudPlatform/opentelemetry-operations-java'
url 'https://github.com/GoogleCloudPlatform/opentelemetry-operations-java'
}

versionMapping {
allVariants {
fromResolutionResult()
}
}
pom {
name = 'OpenTelemetry Operations Java'
url = 'https://github.com/GoogleCloudPlatform/opentelemetry-operations-java'
licenses {
license {
name 'The Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}

developers {
developer {
id 'com.google.cloud.opentelemetry'
name 'OpenTelemetry Operations Contributors'
email '[email protected]'
id = 'com.google.cloud.opentelemetry'
name = 'OpenTelemetry Operations Contributors'
email = '[email protected]'
organization = 'Google Inc'
organizationUrl 'https://cloud.google.com/products/operations'
organizationUrl = 'https://cloud.google.com/products/operations'
}
}
scm {
connection = 'scm:git:https://github.com/GoogleCloudPlatform/opentelemetry-operations-java'
developerConnection = 'scm:git:https://github.com/GoogleCloudPlatform/opentelemetry-operations-java'
url = 'https://github.com/GoogleCloudPlatform/opentelemetry-operations-java'
}
afterEvaluate {
// description is not available until evaluated.
description = project.description
}
}
}
}
repositories {
maven {
def ossrhRelease = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def ossrhSnapshot = "https://oss.sonatype.org/content/repositories/snapshots/"
url = isReleaseVersion ? ossrhRelease : ossrhSnapshot
credentials {
username = rootProject.hasProperty('ossrhUsername') ? rootProject.ossrhUsername : "Unknown user"
password = rootProject.hasProperty('ossrhPassword') ? rootProject.ossrhPassword : "Unknown password"
}
}
}
}

signing {
required false
// Allow using the GPG agent on linux instead of passwords in a .properties file.
if (rootProject.hasProperty('signingUseGpgCmd')) {
useGpgCmd()
}
sign publishing.publications.maven
}
}
4 changes: 2 additions & 2 deletions exporters/auto/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

plugins {
id "com.github.johnrengelman.shadow" version "6.0.0"
id "com.github.johnrengelman.shadow"
}

description = 'Auto Exporter for OpenTelemetry'
Expand All @@ -37,4 +37,4 @@ tasks.build.dependsOn tasks.shadowJar

shadowJar{
classifier = null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public interface MetricDescriptorStrategy {
* Determines what to do with metrci descriptors.
*
* @param batchDescriptors The set of metrics being exported in a batch.
* @param client A consumer that will ensure metric descriptors are registered to cloud
* @param export A consumer that will ensure metric descriptors are registered to cloud
* monitoring.
*/
void exportDescriptors(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
class TraceTranslator {

// TODO(nilebox): Extract the constant
private static final String OPEN_TELEMETRY_LIBRARY_VERSION = "0.6.0";
private static final String EXPORTER_VERSION = "0.1.0";
private static final String OPEN_TELEMETRY_LIBRARY_VERSION = "0.14.1";
private static final String EXPORTER_VERSION = "0.14.0";
private static final String AGENT_LABEL_KEY = "g.co/agent";
private static final String AGENT_LABEL_VALUE_STRING =
"opentelemetry-java "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void testToAttributesProto() {
assertTrue(translatedAttributes.containsAttributeMap("g.co/agent"));
assertEquals(
translatedAttributes.getAttributeMapMap().get("g.co/agent").getStringValue().getValue(),
"opentelemetry-java 0.6.0; google-cloud-trace-exporter 0.1.0");
"opentelemetry-java 0.14.1; google-cloud-trace-exporter 0.14.0");
}

@Test
Expand Down Expand Up @@ -191,7 +191,7 @@ public Attributes getAttributes() {
Map<String, AttributeValue> attributeMap = attributes.getAttributeMapMap();
assertEquals("value", attributeMap.get("key").getStringValue().getValue());
assertEquals(
"opentelemetry-java 0.6.0; google-cloud-trace-exporter 0.1.0",
"opentelemetry-java 0.14.1; google-cloud-trace-exporter 0.14.0",
attributeMap.get("g.co/agent").getStringValue().getValue());
}

Expand Down
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
pluginManagement {
plugins {
id "com.diffplug.spotless" version "5.9.0"
id 'nebula.release' version '15.2.0'
id "com.github.johnrengelman.shadow" version "6.0.0"
}
}

Expand Down

0 comments on commit acd3d8e

Please sign in to comment.