106 lines
4.6 KiB
Diff
106 lines
4.6 KiB
Diff
--- jaxb-ri-4.0.5-RI/jaxb-ri/codemodel/codemodel/src/main/java/com/sun/codemodel/writer/LicenseCodeWriter.java 2025-07-17 11:04:19.315468848 +0200
|
|
+++ jaxb-ri-4.0.5-RI/jaxb-ri/codemodel/codemodel/src/main/java/com/sun/codemodel/writer/LicenseCodeWriter.java 2025-07-17 12:09:59.372158276 +0200
|
|
@@ -33,9 +33,17 @@
|
|
*/
|
|
public class LicenseCodeWriter extends FilterCodeWriter {
|
|
|
|
+ private static final String getCurrentYear() {
|
|
+ Calendar c = Calendar.getInstance();
|
|
+ String sde = System.getenv("SOURCE_DATE_EPOCH");
|
|
+ if (sde != null) {
|
|
+ c.setTimeInMillis(1000 * Long.parseLong(sde));
|
|
+ }
|
|
+ return String.valueOf(c.get(Calendar.YEAR));
|
|
+ }
|
|
private static final String COPYRIGHT_LINE_TEMPLATE = "^.*Copyright \\(c\\) (YYYY) (by )?([A-Za-z].*)$";
|
|
private static final Pattern PATTERN = Pattern.compile(COPYRIGHT_LINE_TEMPLATE, Pattern.MULTILINE);
|
|
- private static final String CURRENT_YEAR = String.valueOf(Calendar.getInstance().get(Calendar.YEAR));
|
|
+ private static final String CURRENT_YEAR = getCurrentYear();
|
|
|
|
private final Path license;
|
|
|
|
--- jaxb-ri-4.0.5-RI/jaxb-ri/txw/compiler/src/main/java/com/sun/tools/txw2/TxwTask.java 2025-07-17 11:04:19.490955785 +0200
|
|
+++ jaxb-ri-4.0.5-RI/jaxb-ri/txw/compiler/src/main/java/com/sun/tools/txw2/TxwTask.java 2025-07-17 12:14:54.350779383 +0200
|
|
@@ -14,6 +14,7 @@
|
|
import com.sun.codemodel.JPackage;
|
|
import com.sun.codemodel.writer.FileCodeWriter;
|
|
import com.sun.codemodel.writer.FilterCodeWriter;
|
|
+import com.sun.codemodel.writer.LicenseCodeWriter;
|
|
import org.apache.tools.ant.BuildException;
|
|
import org.apache.tools.ant.Project;
|
|
import com.sun.tools.rngom.parse.compact.CompactParseable;
|
|
@@ -197,55 +198,4 @@
|
|
Main.run(options);
|
|
log( "Compilation complete.", Project.MSG_INFO );
|
|
}
|
|
-
|
|
- /**
|
|
- * Writes all the source files under the specified file folder and inserts a
|
|
- * license file each java source file.
|
|
- */
|
|
- private static final class LicenseCodeWriter extends FilterCodeWriter {
|
|
-
|
|
- private static final String COPYRIGHT_LINE_TEMPLATE = "^.*Copyright \\(c\\) (YYYY) (by )?([A-Za-z].*)$";
|
|
- private static final Pattern PATTERN = Pattern.compile(COPYRIGHT_LINE_TEMPLATE, Pattern.MULTILINE);
|
|
- private static final String CURRENT_YEAR = String.valueOf(Calendar.getInstance().get(Calendar.YEAR));
|
|
-
|
|
- private final Path license;
|
|
-
|
|
- /**
|
|
- * @param core This CodeWriter will be used to actually create a storage
|
|
- * for files. LicenseCodeWriter simply decorates this underlying
|
|
- * CodeWriter by adding prolog comments.
|
|
- * @param license license File
|
|
- * @param encoding encoding
|
|
- */
|
|
- LicenseCodeWriter(CodeWriter core, File license, String encoding) {
|
|
- super(core);
|
|
- this.license = license.toPath();
|
|
- this.encoding = encoding;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public Writer openSource(JPackage pkg, String fileName) throws IOException {
|
|
- Writer w = super.openSource(pkg, fileName);
|
|
-
|
|
- PrintWriter out = new PrintWriter(w);
|
|
- try (BufferedReader br = Files.newBufferedReader(license, Charset.forName(encoding))) {
|
|
- String line;
|
|
- while ((line = br.readLine()) != null) {
|
|
- Matcher m = PATTERN.matcher(line);
|
|
- if (m.matches()) {
|
|
- out.write(line, 0, m.start(1));
|
|
- out.write(CURRENT_YEAR);
|
|
- out.write(line, m.end(1), line.length() - m.end(1));
|
|
- } else {
|
|
- out.write(line);
|
|
- }
|
|
- out.write(System.lineSeparator());
|
|
- }
|
|
- }
|
|
-
|
|
- out.flush(); // we can't close the stream for that would close the underlying stream.
|
|
-
|
|
- return w;
|
|
- }
|
|
- }
|
|
}
|
|
--- jaxb-ri-4.0.5-RI/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/Options.java 2025-07-17 11:04:19.500125417 +0200
|
|
+++ jaxb-ri-4.0.5-RI/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/Options.java 2025-07-17 13:42:13.962973199 +0200
|
|
@@ -962,9 +962,14 @@
|
|
+ Messages.format(Messages.TIME_FORMAT);
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat(format, Locale.ENGLISH);
|
|
|
|
+ Date now = new Date();
|
|
+ String sde = System.getenv("SOURCE_DATE_EPOCH");
|
|
+ if (sde != null) {
|
|
+ now = new Date(1000 * Long.parseLong(sde));
|
|
+ }
|
|
return Messages.format(
|
|
Messages.FILE_PROLOG_COMMENT,
|
|
- dateFormat.format(new Date()));
|
|
+ dateFormat.format(now));
|
|
}
|
|
|
|
/**
|