8314483: Optionally override copyright header in generated source
Reviewed-by: dholmes, iris
This commit is contained in:
parent
320162395d
commit
837d2e1cac
@ -137,4 +137,7 @@ PANDOC_HTML_MANPAGE_FILTER := $(BUILDTOOLS_OUTPUTDIR)/manpages/pandoc-html-manpa
|
|||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
|
||||||
|
# Hook to include the corresponding custom post file, if present.
|
||||||
|
$(eval $(call IncludeCustomExtension, ToolsJdk-post.gmk))
|
||||||
|
|
||||||
endif # _TOOLS_GMK
|
endif # _TOOLS_GMK
|
||||||
|
@ -114,6 +114,7 @@ public class CLDRConverter {
|
|||||||
|
|
||||||
private static Set<String> AVAILABLE_TZIDS;
|
private static Set<String> AVAILABLE_TZIDS;
|
||||||
static int copyrightYear;
|
static int copyrightYear;
|
||||||
|
static String jdkHeaderTemplate;
|
||||||
private static String zoneNameTempFile;
|
private static String zoneNameTempFile;
|
||||||
private static String tzDataDir;
|
private static String tzDataDir;
|
||||||
private static final Map<String, String> canonicalTZMap = new HashMap<>();
|
private static final Map<String, String> canonicalTZMap = new HashMap<>();
|
||||||
@ -229,6 +230,10 @@ public class CLDRConverter {
|
|||||||
tzDataDir = args[++i];
|
tzDataDir = args[++i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "-jdk-header-template":
|
||||||
|
jdkHeaderTemplate = Files.readString(Paths.get(args[++i]));
|
||||||
|
break;
|
||||||
|
|
||||||
case "-help":
|
case "-help":
|
||||||
usage();
|
usage();
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
@ -304,7 +309,9 @@ public class CLDRConverter {
|
|||||||
+ "\t-year year copyright year in output%n"
|
+ "\t-year year copyright year in output%n"
|
||||||
+ "\t-zntempfile template file for java.time.format.ZoneName.java%n"
|
+ "\t-zntempfile template file for java.time.format.ZoneName.java%n"
|
||||||
+ "\t-tzdatadir tzdata directory for java.time.format.ZoneName.java%n"
|
+ "\t-tzdatadir tzdata directory for java.time.format.ZoneName.java%n"
|
||||||
+ "\t-utf8 use UTF-8 rather than \\uxxxx (for debug)%n");
|
+ "\t-utf8 use UTF-8 rather than \\uxxxx (for debug)%n"
|
||||||
|
+ "\t-jdk-header-template <file>%n"
|
||||||
|
+ "\t\t override default GPL header with contents of file%n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void info(String fmt, Object... args) {
|
static void info(String fmt, Object... args) {
|
||||||
|
@ -174,7 +174,7 @@ class ResourceBundleGenerator implements BundleGenerator {
|
|||||||
|
|
||||||
try (PrintWriter out = new PrintWriter(file, encoding)) {
|
try (PrintWriter out = new PrintWriter(file, encoding)) {
|
||||||
// Output copyright headers
|
// Output copyright headers
|
||||||
out.println(CopyrightHeaders.getOpenJDKCopyright(CLDRConverter.copyrightYear));
|
out.println(getOpenJDKCopyright());
|
||||||
out.println(CopyrightHeaders.getUnicodeCopyright());
|
out.println(CopyrightHeaders.getUnicodeCopyright());
|
||||||
|
|
||||||
if (useJava) {
|
if (useJava) {
|
||||||
@ -294,7 +294,7 @@ class ResourceBundleGenerator implements BundleGenerator {
|
|||||||
CLDRConverter.info("Generating file " + file);
|
CLDRConverter.info("Generating file " + file);
|
||||||
|
|
||||||
try (PrintWriter out = new PrintWriter(file, "us-ascii")) {
|
try (PrintWriter out = new PrintWriter(file, "us-ascii")) {
|
||||||
out.printf(CopyrightHeaders.getOpenJDKCopyright(CLDRConverter.copyrightYear));
|
out.printf(getOpenJDKCopyright());
|
||||||
|
|
||||||
out.printf("""
|
out.printf("""
|
||||||
package sun.util.%s;
|
package sun.util.%s;
|
||||||
@ -448,4 +448,12 @@ class ResourceBundleGenerator implements BundleGenerator {
|
|||||||
});
|
});
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getOpenJDKCopyright() {
|
||||||
|
if (CLDRConverter.jdkHeaderTemplate != null) {
|
||||||
|
return String.format(CLDRConverter.jdkHeaderTemplate, CLDRConverter.copyrightYear);
|
||||||
|
} else {
|
||||||
|
return CopyrightHeaders.getOpenJDKCopyright(CLDRConverter.copyrightYear);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,21 +53,38 @@ import java.util.regex.Pattern;
|
|||||||
public class EquivMapsGenerator {
|
public class EquivMapsGenerator {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
if (args.length != 3) {
|
int i = 0;
|
||||||
|
boolean valid = true;
|
||||||
|
if (args.length != 5 && args.length !=3) {
|
||||||
|
valid = false;
|
||||||
|
} else if (args.length == 5) {
|
||||||
|
if ("-jdk-header-template".equals(args[i])) {
|
||||||
|
jdkHeaderTemplate = Files.readString(Paths.get(args[++i]));
|
||||||
|
i++;
|
||||||
|
} else {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!valid) {
|
||||||
System.err.println("Usage: java EquivMapsGenerator"
|
System.err.println("Usage: java EquivMapsGenerator"
|
||||||
|
+ " [-jdk-header-template <file>]"
|
||||||
+ " language-subtag-registry.txt LocaleEquivalentMaps.java copyrightYear");
|
+ " language-subtag-registry.txt LocaleEquivalentMaps.java copyrightYear");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
copyrightYear = Integer.parseInt(args[2]);
|
String lsrFile = args[i++];
|
||||||
readLSRfile(args[0]);
|
String outputFile = args[i++];
|
||||||
|
copyrightYear = Integer.parseInt(args[i++]);
|
||||||
|
|
||||||
|
readLSRfile(lsrFile);
|
||||||
// Builds the maps from the IANA data
|
// Builds the maps from the IANA data
|
||||||
generateEquivalentMap();
|
generateEquivalentMap();
|
||||||
// Writes the maps out to LocaleEquivalentMaps.java
|
// Writes the maps out to LocaleEquivalentMaps.java
|
||||||
generateSourceCode(args[1]);
|
generateSourceCode(outputFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String LSRrevisionDate;
|
private static String LSRrevisionDate;
|
||||||
private static int copyrightYear;
|
private static int copyrightYear;
|
||||||
|
private static String jdkHeaderTemplate;
|
||||||
private static Map<String, StringBuilder> initialLanguageMap =
|
private static Map<String, StringBuilder> initialLanguageMap =
|
||||||
new TreeMap<>();
|
new TreeMap<>();
|
||||||
private static Map<String, StringBuilder> initialRegionVariantMap =
|
private static Map<String, StringBuilder> initialRegionVariantMap =
|
||||||
@ -225,6 +242,7 @@ public class EquivMapsGenerator {
|
|||||||
try (BufferedWriter writer = Files.newBufferedWriter(
|
try (BufferedWriter writer = Files.newBufferedWriter(
|
||||||
Paths.get(fileName))) {
|
Paths.get(fileName))) {
|
||||||
writer.write(getOpenJDKCopyright());
|
writer.write(getOpenJDKCopyright());
|
||||||
|
writer.write("\n");
|
||||||
writer.write(HEADER_TEXT);
|
writer.write(HEADER_TEXT);
|
||||||
writer.write(getMapsText());
|
writer.write(getMapsText());
|
||||||
writer.write(getLSRText());
|
writer.write(getLSRText());
|
||||||
@ -241,7 +259,8 @@ public class EquivMapsGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String getOpenJDKCopyright() {
|
private static String getOpenJDKCopyright() {
|
||||||
return String.format(Locale.US, COPYRIGHT, copyrightYear);
|
return String.format(Locale.US,
|
||||||
|
(jdkHeaderTemplate != null ? jdkHeaderTemplate : COPYRIGHT), copyrightYear);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String COPYRIGHT =
|
private static final String COPYRIGHT =
|
||||||
@ -270,7 +289,6 @@ public class EquivMapsGenerator {
|
|||||||
* or visit www.oracle.com if you need additional information or have any
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
""";
|
""";
|
||||||
|
|
||||||
private static final String HEADER_TEXT =
|
private static final String HEADER_TEXT =
|
||||||
|
Loading…
Reference in New Issue
Block a user