diff --git a/commons/VersionScript.groovy b/commons/VersionScript.groovy deleted file mode 100644 index 61c016a2173e..000000000000 --- a/commons/VersionScript.groovy +++ /dev/null @@ -1,35 +0,0 @@ -File mainDir = new File("${project.basedir}/src/main"); -if (mainDir.exists() && !mainDir.isDirectory()) { - println("Main dir does not exist, wont create Version.java!"); - return; -} -final File versionFile = new File("${project.basedir}/src/main/java/com/navercorp/pinpoint/common/Version.java"); -if (versionFile.exists() && versionFile.isDirectory()) { - println("Version file exists and is directory! Wont overwrite"); - return; -} -final String versionField = " public static final String VERSION = \"${project.version}\";"; -if (versionFile.exists()) { - FileInputStream fileInputStream = new FileInputStream(versionFile); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF8"); - BufferedReader bufferedReader = new BufferedReader(inputStreamReader); - String versionCheck; - while ((versionCheck = bufferedReader.readLine()) != null) { - if (versionCheck.contains(versionField)) { - println("Version field already exist."); - return; - } - } - - println("Version file already exists, overwriting!"); -} -println("Creating Version.java File"); -BufferedWriter writer = new BufferedWriter(new FileWriter(versionFile)); - -writer.write("package com.navercorp.pinpoint.common;\n"); -writer.write("public final class Version {\n"); -writer.write(versionField); -writer.write('\n'); -writer.write("}"); -writer.close(); - diff --git a/commons/pom.xml b/commons/pom.xml index d66b9a1a02f2..162bebafb9b1 100644 --- a/commons/pom.xml +++ b/commons/pom.xml @@ -38,17 +38,18 @@ - org.codehaus.gmaven - groovy-maven-plugin - 2.1.1 + org.codehaus.mojo + templating-maven-plugin + 3.0.0 - generate-sources + filter-src - execute + filter-sources - ${project.basedir}/VersionScript.groovy + ${basedir}/src/main/java-templates + ${project.build.directory}/generated-sources/java-templates diff --git a/commons/src/main/java-templates/com/navercorp/pinpoint/common/VersionTemplate.java b/commons/src/main/java-templates/com/navercorp/pinpoint/common/VersionTemplate.java new file mode 100644 index 000000000000..8b55dd04b1f0 --- /dev/null +++ b/commons/src/main/java-templates/com/navercorp/pinpoint/common/VersionTemplate.java @@ -0,0 +1,4 @@ +package com.navercorp.pinpoint.common; +public final class VersionTemplate { + static final String VERSION_TEMPLATE = "${project.version}"; +} \ No newline at end of file diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/Version.java b/commons/src/main/java/com/navercorp/pinpoint/common/Version.java index 2c472d7d61bc..bfdcd1dc9d31 100644 --- a/commons/src/main/java/com/navercorp/pinpoint/common/Version.java +++ b/commons/src/main/java/com/navercorp/pinpoint/common/Version.java @@ -1,4 +1,4 @@ package com.navercorp.pinpoint.common; public final class Version { - public static final String VERSION = "3.1.0-SNAPSHOT"; + public static final String VERSION = VersionTemplate.VERSION_TEMPLATE; } \ No newline at end of file