forked from pinpoint-apm/pinpoint
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pinpoint-apm#11745] Apply Version templating to plugin-test module
- Loading branch information
Showing
10 changed files
with
51 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...gins-test/src/main/java-templates/com/navercorp/pinpoint/test/plugin/VersionTemplate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.navercorp.pinpoint.test.plugin; | ||
public final class VersionTemplate { | ||
public static final String VERSION_TEMPLATE = "${project.version}"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 1 addition & 50 deletions
51
...plugins-test/src/main/java/com/navercorp/pinpoint/test/plugin/util/TestPluginVersion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,9 @@ | ||
package com.navercorp.pinpoint.test.plugin.util; | ||
|
||
import java.io.Closeable; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Properties; | ||
|
||
public final class TestPluginVersion { | ||
private static final String VERSION_PROPERTIES = "testplugin-version.properties"; | ||
|
||
private static final String VERSION_KEY = "PROJECT_VERSION"; | ||
private static final String NOT_COMPILED = "${project.version}"; | ||
|
||
private static final String VERSION; | ||
|
||
static { | ||
InputStream stream = TestPluginVersion.class.getClassLoader().getResourceAsStream(VERSION_PROPERTIES); | ||
Properties properties = loadProperties(stream); | ||
|
||
VERSION = readString(properties, VERSION_KEY); | ||
} | ||
|
||
private static String readString(Properties properties, String key) { | ||
final String projectVersion = properties.getProperty(key); | ||
if (projectVersion == null) { | ||
throw new IllegalStateException(key + " key not found"); | ||
} | ||
if (NOT_COMPILED.equals(projectVersion)) { | ||
throw new IllegalStateException("Install pinpoint-test module( $test> mvn install)"); | ||
} | ||
return projectVersion; | ||
} | ||
|
||
private static void close(Closeable closeable) { | ||
if (closeable != null) { | ||
try { | ||
closeable.close(); | ||
} catch (IOException ignored) { | ||
} | ||
} | ||
} | ||
|
||
private static Properties loadProperties(InputStream stream) { | ||
Properties properties = new Properties(); | ||
try { | ||
properties.load(stream); | ||
return properties; | ||
} catch (IOException e) { | ||
throw new RuntimeException("properties load failed", e); | ||
} finally { | ||
close(stream); | ||
} | ||
} | ||
|
||
public static String getVersion() { | ||
return VERSION; | ||
return VersionUtils.VERSION; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...dule/plugins-test/src/main/java/com/navercorp/pinpoint/test/plugin/util/VersionUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.navercorp.pinpoint.test.plugin.util; | ||
|
||
public class VersionUtils { | ||
|
||
public static String VERSION = com.navercorp.pinpoint.test.plugin.VersionTemplate.VERSION_TEMPLATE; | ||
} |
1 change: 0 additions & 1 deletion
1
...-module/plugins-test-module/plugins-test/src/main/resources/testplugin-version.properties
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters