Skip to content

Commit acd3d8e

Browse files
jsuerethpunya
andauthored
Update to use Nebula-Release plugin (GoogleCloudPlatform#78)
* 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]>
1 parent fee5081 commit acd3d8e

File tree

8 files changed

+115
-48
lines changed

8 files changed

+115
-48
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ out/
1616
build/
1717
bin/
1818

19+
# Mock server download
20+
mock_server*

RELEASING.md

+12
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ your OSSRH (OSS Repository Hosting) account and signing keys.
4343
checkstyle.ignoreFailures=false
4444
```
4545
46+
### Using GPG-Agent for artifact signing
47+
48+
4649
## Download the mock server
4750
4851
- Run the `get_mock_server.sh` script, which downloads the [mock server
@@ -53,6 +56,15 @@ your OSSRH (OSS Repository Hosting) account and signing keys.
5356
$ source ./get_mock_server.sh
5457
```
5558
59+
## Release a Snapshot
60+
61+
If you've followed the above steps, you can release snapshots for consumption using the following:
62+
63+
```bash
64+
$ ./gradlew snapshot -Dmock.server.path=$MOCKSERVER
65+
```
66+
67+
5668
## Tagging the Release
5769

5870
The first step in the release process is to create a release branch, bump

build.gradle

+92-41
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,44 @@
1414
* limitations under the License.
1515
*/
1616

17+
import nebula.plugin.release.git.opinion.Strategies
1718
plugins {
1819
id "com.diffplug.spotless"
20+
id 'nebula.release'
1921
}
22+
23+
// Configure release mechanism.
24+
// Nebula plugin will not configure if .git doesn't exist, let's allow building on it by stubbing it
25+
// out. This supports building from the zip archive downloaded from GitHub.
26+
def releaseTask
27+
if (file('.git').exists()) {
28+
release {
29+
defaultVersionStrategy = Strategies.getSNAPSHOT()
30+
}
31+
nebulaRelease {
32+
addReleaseBranchPattern(/v\d+\.\d+\.x/)
33+
}
34+
35+
releaseTask = tasks.named("release")
36+
releaseTask.configure {
37+
mustRunAfter("snapshotSetup", "finalSetup")
38+
}
39+
} else {
40+
releaseTask = tasks.register('release')
41+
}
42+
43+
ext.isReleaseVersion = !version.toString().endsWith("-SNAPSHOT")
44+
2045
subprojects {
2146
apply plugin: 'jacoco'
2247
apply plugin: 'java-library'
2348
apply plugin: 'maven'
49+
apply plugin: 'maven-publish'
2450
apply plugin: 'signing'
2551
apply plugin: 'com.diffplug.spotless'
26-
52+
apply plugin: 'nebula.nebula-release'
2753
group = "com.google.cloud.opentelemetry"
28-
version = "0.13.1-SNAPSHOT" // CURRENT_VERSION
54+
version = "0.14.0-SNAPSHOT" // CURRENT_VERSION
2955

3056
sourceCompatibility = JavaVersion.VERSION_1_8
3157
targetCompatibility = JavaVersion.VERSION_1_8
@@ -39,8 +65,10 @@ subprojects {
3965

4066
// Set up java codestyle checking and correction.
4167
plugins.withId("java") {
42-
plugins.apply('checkstyle')
4368
plugins.apply('com.diffplug.spotless')
69+
70+
// Configure our default module name for maven publishing
71+
archivesBaseName = "${project.name}"
4472
}
4573

4674
// Include license check and auto-format support.
@@ -117,60 +145,83 @@ subprojects {
117145
archives javadocJar, sourcesJar
118146
}
119147

120-
signing {
121-
required false
122-
// Allow using the GPG agent on linux instead of passwords in a .properties file.
123-
if (rootProject.hasProperty('signingUseGpgCmd')) {
124-
useGpgCmd()
148+
javadoc {
149+
if(JavaVersion.current().isJava9Compatible()) {
150+
options.addBooleanOption('html5', true)
125151
}
126-
sign configurations.archives
127152
}
128153

129-
uploadArchives {
130-
repositories {
131-
mavenDeployer {
132-
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
154+
java {
155+
withJavadocJar()
156+
withSourcesJar()
157+
}
158+
159+
releaseTask.configure {
160+
finalizedBy(tasks.named('publish'))
161+
}
133162

134-
def configureAuth = {
135-
if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
136-
authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword)
137-
}
163+
publishing {
164+
publications {
165+
maven(MavenPublication) {
166+
from components.java
167+
groupId = 'com.google.cloud.opentelemetry'
168+
afterEvaluate {
169+
artifactId = archivesBaseName
138170
}
139-
140-
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/", configureAuth)
141-
142-
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/", configureAuth)
143-
144-
pom.project {
145-
name 'OpenTelemetry Operations Java'
146-
description 'OpenTelemetry exporters to Google Cloud Trace and Google Cloud Monitoring'
147-
packaging 'jar'
148-
url 'https://github.com/GoogleCloudPlatform/opentelemetry-operations-java'
149-
150-
scm {
151-
connection 'scm:git:https://github.com/GoogleCloudPlatform/opentelemetry-operations-java'
152-
developerConnection 'scm:git:https://github.com/GoogleCloudPlatform/opentelemetry-operations-java'
153-
url 'https://github.com/GoogleCloudPlatform/opentelemetry-operations-java'
154-
}
155-
171+
versionMapping {
172+
allVariants {
173+
fromResolutionResult()
174+
}
175+
}
176+
pom {
177+
name = 'OpenTelemetry Operations Java'
178+
url = 'https://github.com/GoogleCloudPlatform/opentelemetry-operations-java'
156179
licenses {
157180
license {
158-
name 'The Apache License, Version 2.0'
159-
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
181+
name = 'The Apache License, Version 2.0'
182+
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
160183
}
161184
}
162-
163185
developers {
164186
developer {
165-
id 'com.google.cloud.opentelemetry'
166-
name 'OpenTelemetry Operations Contributors'
167-
187+
id = 'com.google.cloud.opentelemetry'
188+
name = 'OpenTelemetry Operations Contributors'
189+
168190
organization = 'Google Inc'
169-
organizationUrl 'https://cloud.google.com/products/operations'
191+
organizationUrl = 'https://cloud.google.com/products/operations'
170192
}
171193
}
194+
scm {
195+
connection = 'scm:git:https://github.com/GoogleCloudPlatform/opentelemetry-operations-java'
196+
developerConnection = 'scm:git:https://github.com/GoogleCloudPlatform/opentelemetry-operations-java'
197+
url = 'https://github.com/GoogleCloudPlatform/opentelemetry-operations-java'
198+
}
199+
afterEvaluate {
200+
// description is not available until evaluated.
201+
description = project.description
202+
}
172203
}
173204
}
174205
}
206+
repositories {
207+
maven {
208+
def ossrhRelease = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
209+
def ossrhSnapshot = "https://oss.sonatype.org/content/repositories/snapshots/"
210+
url = isReleaseVersion ? ossrhRelease : ossrhSnapshot
211+
credentials {
212+
username = rootProject.hasProperty('ossrhUsername') ? rootProject.ossrhUsername : "Unknown user"
213+
password = rootProject.hasProperty('ossrhPassword') ? rootProject.ossrhPassword : "Unknown password"
214+
}
215+
}
216+
}
217+
}
218+
219+
signing {
220+
required false
221+
// Allow using the GPG agent on linux instead of passwords in a .properties file.
222+
if (rootProject.hasProperty('signingUseGpgCmd')) {
223+
useGpgCmd()
224+
}
225+
sign publishing.publications.maven
175226
}
176227
}

exporters/auto/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
plugins {
18-
id "com.github.johnrengelman.shadow" version "6.0.0"
18+
id "com.github.johnrengelman.shadow"
1919
}
2020

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

3838
shadowJar{
3939
classifier = null
40-
}
40+
}

exporters/metrics/src/main/java/com/google/cloud/opentelemetry/metric/MetricDescriptorStrategy.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public interface MetricDescriptorStrategy {
2626
* Determines what to do with metrci descriptors.
2727
*
2828
* @param batchDescriptors The set of metrics being exported in a batch.
29-
* @param client A consumer that will ensure metric descriptors are registered to cloud
29+
* @param export A consumer that will ensure metric descriptors are registered to cloud
3030
* monitoring.
3131
*/
3232
void exportDescriptors(

exporters/trace/src/main/java/com/google/cloud/opentelemetry/trace/TraceTranslator.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
class TraceTranslator {
4646

4747
// TODO(nilebox): Extract the constant
48-
private static final String OPEN_TELEMETRY_LIBRARY_VERSION = "0.6.0";
49-
private static final String EXPORTER_VERSION = "0.1.0";
48+
private static final String OPEN_TELEMETRY_LIBRARY_VERSION = "0.14.1";
49+
private static final String EXPORTER_VERSION = "0.14.0";
5050
private static final String AGENT_LABEL_KEY = "g.co/agent";
5151
private static final String AGENT_LABEL_VALUE_STRING =
5252
"opentelemetry-java "

exporters/trace/src/test/java/com/google/cloud/opentelemetry/trace/TraceTranslatorTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public void testToAttributesProto() {
147147
assertTrue(translatedAttributes.containsAttributeMap("g.co/agent"));
148148
assertEquals(
149149
translatedAttributes.getAttributeMapMap().get("g.co/agent").getStringValue().getValue(),
150-
"opentelemetry-java 0.6.0; google-cloud-trace-exporter 0.1.0");
150+
"opentelemetry-java 0.14.1; google-cloud-trace-exporter 0.14.0");
151151
}
152152

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

settings.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
pluginManagement {
1818
plugins {
1919
id "com.diffplug.spotless" version "5.9.0"
20+
id 'nebula.release' version '15.2.0'
21+
id "com.github.johnrengelman.shadow" version "6.0.0"
2022
}
2123
}
2224

0 commit comments

Comments
 (0)