File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
src/main/java/org/apache/maven/plugins/jar Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 1818 */
1919package org .apache .maven .plugins .jar ;
2020
21+ import javax .lang .model .SourceVersion ;
22+
2123import java .io .IOException ;
2224import java .nio .file .Files ;
2325import java .nio .file .Path ;
@@ -230,6 +232,21 @@ protected ToolProvider getJarTool() throws MojoException {
230232 return ToolProvider .findFirst (toolId ).orElseThrow (() -> new MojoException ("No such \" " + toolId + "\" tool." ));
231233 }
232234
235+ /**
236+ * Returns whether the given release is supported.
237+ * TODO: should check is a toolchain is used.
238+ *
239+ * @param release name of an {@link SourceVersion} enumeration constant
240+ * @return whether the current environment support that version
241+ */
242+ private static boolean isSupported (String release ) {
243+ try {
244+ return SourceVersion .latestSupported ().compareTo (SourceVersion .valueOf (release )) >= 0 ;
245+ } catch (IllegalArgumentException e ) {
246+ return false ;
247+ }
248+ }
249+
233250 /**
234251 * Returns the output time stamp or, as a fallback, the {@code SOURCE_DATE_EPOCH} environment variable.
235252 * If the time stamp is expressed in seconds, it is converted to ISO 8601 format. Otherwise it is returned as-is.
@@ -246,6 +263,10 @@ protected String getOutputTimestamp() {
246263 return null ;
247264 }
248265 }
266+ if (!isSupported ("RELEASE_19" )) {
267+ log .warn ("Reproducible build requires Java 19 or later." );
268+ return null ;
269+ }
249270 for (int i = time .length (); --i >= 0 ; ) {
250271 char c = time .charAt (i );
251272 if ((c < '0' || c > '9' ) && (i != 0 || c != '-' )) {
You can’t perform that action at this time.
0 commit comments