Skip to content

Commit cc8372e

Browse files
authored
Merge pull request #257 from oracle/russ_issue_256_version_property
Use unique name for version property
2 parents 1fcb12f + 7b00af3 commit cc8372e

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

build-helper-mojo/src/main/java/com/oracle/wls/buildhelper/GitTagMojo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
@Mojo(name = "gitVersion", defaultPhase = LifecyclePhase.PREPARE_PACKAGE)
2121
public class GitTagMojo extends AbstractMojo {
2222

23-
@Parameter(required = true, defaultValue = "${project.build.outputDirectory}/version.properties")
23+
@Parameter(required = true, defaultValue = "${project.build.outputDirectory}/exporter-version.properties")
2424
private File outputFile;
2525

2626
private final GitTagExecutor executor;
@@ -48,7 +48,7 @@ public void execute() throws MojoExecutionException {
4848
}
4949

5050
private List<String> createProperties(String versionString) {
51-
return Collections.singletonList("version=" + versionString);
51+
return Collections.singletonList("monitoring-exporter-version=" + versionString);
5252
}
5353

5454
// parses the result of 'git describe --tag' to describe the current code version/

build-helper-mojo/src/test/java/com/oracle/wls/buildhelper/GitTagMojoTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void mojoAnnotatedWithDefaultPhase() {
6161
void hasRequiredOutputDirectoryParameter() throws NoSuchFieldException {
6262
assertThat(mojoTestSupport.getParameterField("outputFile").getType(), equalTo(File.class));
6363
assertThat(mojoTestSupport.getParameterAnnotation("outputFile").get("required"), is(true));
64-
assertThat(mojoTestSupport.getParameterAnnotation("outputFile").get("defaultValue"), equalTo("${project.build.outputDirectory}/version.properties"));
64+
assertThat(mojoTestSupport.getParameterAnnotation("outputFile").get("defaultValue"), equalTo("${project.build.outputDirectory}/exporter-version.properties"));
6565
}
6666

6767
@Test
@@ -92,7 +92,7 @@ void whenGitResponseIsVersionPlusHistory_createVersionProperty() throws Exceptio
9292
mojo.execute();
9393

9494
assertThat(inMemoryFileSystem.getContents(outputFile.getAbsolutePath()),
95-
containsString("version=cb4385f3aa (946 commits since v3.3.5-3)"));
95+
containsString("monitoring-exporter-version=cb4385f3aa (946 commits since v3.3.5-3)"));
9696
}
9797

9898
@Test
@@ -101,7 +101,8 @@ void whenGitResponseIsVersionOnly_createVersionProperty() throws Exception {
101101

102102
mojo.execute();
103103

104-
assertThat(inMemoryFileSystem.getContents(outputFile.getAbsolutePath()), containsString("version=v3.4-1"));
104+
assertThat(inMemoryFileSystem.getContents(outputFile.getAbsolutePath()),
105+
containsString("monitoring-exporter-version=v3.4-1"));
105106
}
106107

107108
@Test

wls-exporter-core/src/main/java/com/oracle/wls/exporter/LiveConfiguration.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
// Copyright (c) 2017, 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2017, 2023, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package com.oracle.wls.exporter;
55

6-
import com.google.gson.JsonObject;
7-
import com.google.gson.JsonParser;
8-
import com.oracle.wls.exporter.domain.ExporterConfig;
9-
import com.oracle.wls.exporter.domain.MBeanSelector;
10-
import com.oracle.wls.exporter.domain.QuerySyncConfiguration;
11-
import org.yaml.snakeyaml.Yaml;
12-
136
import java.io.ByteArrayInputStream;
147
import java.io.IOException;
158
import java.io.InputStream;
@@ -19,13 +12,23 @@
1912
import java.util.Optional;
2013
import java.util.Properties;
2114

15+
import com.google.gson.JsonObject;
16+
import com.google.gson.JsonParser;
17+
import com.oracle.wls.exporter.domain.ExporterConfig;
18+
import com.oracle.wls.exporter.domain.MBeanSelector;
19+
import com.oracle.wls.exporter.domain.QuerySyncConfiguration;
20+
import org.yaml.snakeyaml.Yaml;
21+
2222
/**
2323
* The repository for the current exporter configuration.
2424
*
2525
* @author Russell Gold
2626
*/
2727
public class LiveConfiguration {
2828

29+
public static final String VERSION_PROPERTY_FILE = "exporter-version.properties";
30+
public static final String VERSION_PROPERTY = "monitoring-exporter-version";
31+
2932
private LiveConfiguration() {
3033
// no-op
3134
}
@@ -59,10 +62,10 @@ private static ExporterConfig getConfig() {
5962
}
6063

6164
public static String getVersionString() {
62-
try (InputStream in = LiveConfiguration.class.getClassLoader().getResourceAsStream("version.properties")) {
65+
try (InputStream in = LiveConfiguration.class.getClassLoader().getResourceAsStream(VERSION_PROPERTY_FILE)) {
6366
Properties properties = new Properties();
6467
properties.load(in);
65-
return properties.getProperty("version");
68+
return properties.getProperty(VERSION_PROPERTY);
6669

6770
} catch (IOException e) {
6871
return "** unknown version";

0 commit comments

Comments
 (0)