|
@@ -28,7 +28,8 @@ import java.util.regex.Pattern;
|
|
|
|
|
|
public class VerGen {
|
|
|
private static final String PACKAGE_NAME = "org.apache.zookeeper.version";
|
|
|
- private static final String TYPE_NAME = "Info";
|
|
|
+ private static final String VERSION_CLASS_NAME = "VersionInfoMain";
|
|
|
+ private static final String VERSION_INTERFACE_NAME = "Info";
|
|
|
|
|
|
static void printUsage() {
|
|
|
System.out.print("Usage:\tjava -cp <classpath> org.apache.zookeeper."
|
|
@@ -53,7 +54,7 @@ public class VerGen {
|
|
|
System.exit(ExitCode.UNEXPECTED_ERROR.getValue());
|
|
|
}
|
|
|
|
|
|
- try (FileWriter w = new FileWriter(new File(pkgdir, TYPE_NAME + ".java"))) {
|
|
|
+ try (FileWriter w = new FileWriter(new File(pkgdir, VERSION_INTERFACE_NAME + ".java"))) {
|
|
|
w.write("// Do not edit!\n// File generated by org.apache.zookeeper"
|
|
|
+ ".version.util.VerGen.\n");
|
|
|
w.write("/**\n");
|
|
@@ -75,7 +76,7 @@ public class VerGen {
|
|
|
w.write("*/\n");
|
|
|
w.write("\n");
|
|
|
w.write("package " + PACKAGE_NAME + ";\n\n");
|
|
|
- w.write("public interface " + TYPE_NAME + " {\n");
|
|
|
+ w.write("public interface " + VERSION_INTERFACE_NAME + " {\n");
|
|
|
w.write(" int MAJOR=" + version.maj + ";\n");
|
|
|
w.write(" int MINOR=" + version.min + ";\n");
|
|
|
w.write(" int MICRO=" + version.micro + ";\n");
|
|
@@ -96,6 +97,45 @@ public class VerGen {
|
|
|
+ e.getMessage());
|
|
|
System.exit(ExitCode.UNEXPECTED_ERROR.getValue());
|
|
|
}
|
|
|
+
|
|
|
+ // Generate a main class to display version data
|
|
|
+ // that can be exec'd in zkServer.sh
|
|
|
+ try (FileWriter w = new FileWriter(new File(pkgdir, VERSION_CLASS_NAME + ".java"))) {
|
|
|
+ w.write("// Do not edit!\n// File generated by org.apache.zookeeper"
|
|
|
+ + ".version.util.VerGen.\n");
|
|
|
+ w.write("/**\n");
|
|
|
+ w.write("* Licensed to the Apache Software Foundation (ASF) under one\n");
|
|
|
+ w.write("* or more contributor license agreements. See the NOTICE file\n");
|
|
|
+ w.write("* distributed with this work for additional information\n");
|
|
|
+ w.write("* regarding copyright ownership. The ASF licenses this file\n");
|
|
|
+ w.write("* to you under the Apache License, Version 2.0 (the\n");
|
|
|
+ w.write("* \"License\"); you may not use this file except in compliance\n");
|
|
|
+ w.write("* with the License. You may obtain a copy of the License at\n");
|
|
|
+ w.write("*\n");
|
|
|
+ w.write("* http://www.apache.org/licenses/LICENSE-2.0\n");
|
|
|
+ w.write("*\n");
|
|
|
+ w.write("* Unless required by applicable law or agreed to in writing, software\n");
|
|
|
+ w.write("* distributed under the License is distributed on an \"AS IS\" BASIS,\n");
|
|
|
+ w.write("* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n");
|
|
|
+ w.write("* See the License for the specific language governing permissions and\n");
|
|
|
+ w.write("* limitations under the License.\n");
|
|
|
+ w.write("*/\n");
|
|
|
+ w.write("\n");
|
|
|
+ w.write("package " + PACKAGE_NAME + ";\n\n");
|
|
|
+ w.write("public class " + VERSION_CLASS_NAME + " implements " +
|
|
|
+ PACKAGE_NAME + ".Info {\n");
|
|
|
+ w.write(" public static void main(String[] args) {\n");
|
|
|
+ w.write(" final String VER_STRING = MAJOR + \".\" + MINOR + \".\" + MICRO +");
|
|
|
+ w.write(" (QUALIFIER == null ? \"\" : \"-\" + QUALIFIER) + \" \" +");
|
|
|
+ w.write(" BUILD_DATE;" + "\n");
|
|
|
+ w.write(" System.out.println(\"Apache ZooKeeper, version \" + VER_STRING);\n");
|
|
|
+ w.write(" }\n");
|
|
|
+ w.write("}\n");
|
|
|
+ } catch (IOException e) {
|
|
|
+ System.out.println("Unable to generate version.VersionInfoMain file: "
|
|
|
+ + e.getMessage());
|
|
|
+ System.exit(1);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static class Version {
|