|
117 | 117 | import java.nio.file.Files;
|
118 | 118 | import java.nio.file.Path;
|
119 | 119 | import java.nio.file.StandardCopyOption;
|
| 120 | +import java.time.format.DateTimeFormatter; |
| 121 | +import java.time.temporal.ChronoField; |
120 | 122 | import java.util.ArrayList;
|
121 | 123 | import java.util.Arrays;
|
122 | 124 | import java.util.Calendar;
|
|
155 | 157 | public abstract class AbstractJavadocMojo
|
156 | 158 | extends AbstractMojo
|
157 | 159 | {
|
| 160 | + /** |
| 161 | + * Property with timestamp used for reproducible builds |
| 162 | + */ |
| 163 | + private static final String PROJECT_BUILD_OUTPUTTIMESTAMP = "project.build.outputTimestamp"; |
| 164 | + |
158 | 165 | /**
|
159 | 166 | * Classifier used in the name of the javadoc-options XML file, and in the resources bundle
|
160 | 167 | * artifact that gets attached to the project. This one is used for non-test javadocs.
|
@@ -923,9 +930,12 @@ public abstract class AbstractJavadocMojo
|
923 | 930 | * Specifies the text to be placed at the bottom of each output file.<br/>
|
924 | 931 | * If you want to use html, you have to put it in a CDATA section, <br/>
|
925 | 932 | * e.g. <code><![CDATA[Copyright 2005, <a href="http://www.mycompany.com">MyCompany, Inc.<a>]]></code>
|
926 |
| - * <br/> |
| 933 | + * <br> |
| 934 | + * <strong>Note:<strong>If the project has the property <code>project.build.outputTimestamp</code>, its year will |
| 935 | + * be used as {currentYear}. This way it is possible to generate reproducible javadoc jars. |
| 936 | + * <br> |
927 | 937 | * See <a href="https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#bottom">bottom</a>.
|
928 |
| - * <br/> |
| 938 | + * <br> |
929 | 939 | */
|
930 | 940 | @Parameter( property = "bottom",
|
931 | 941 | defaultValue = "Copyright © {inceptionYear}–{currentYear} {organizationName}. "
|
@@ -2977,8 +2987,18 @@ private void populateCompileArtifactMap( Map<String, Artifact> compileArtifactMa
|
2977 | 2987 | */
|
2978 | 2988 | private String getBottomText()
|
2979 | 2989 | {
|
2980 |
| - int currentYear = Calendar.getInstance().get( Calendar.YEAR ); |
2981 |
| - String year = String.valueOf( currentYear ); |
| 2990 | + final String year; |
| 2991 | + String buildTime = project.getProperties().getProperty( PROJECT_BUILD_OUTPUTTIMESTAMP ); |
| 2992 | + if ( buildTime != null ) |
| 2993 | + { |
| 2994 | + year = String.valueOf( DateTimeFormatter.ISO_DATE_TIME.parse( buildTime ).get( ChronoField.YEAR ) ); |
| 2995 | + } |
| 2996 | + else |
| 2997 | + { |
| 2998 | + getLog().debug( "Using current year due to unavailable property '" + PROJECT_BUILD_OUTPUTTIMESTAMP + "'" ); |
| 2999 | + int currentYear = Calendar.getInstance().get( Calendar.YEAR ); |
| 3000 | + year = String.valueOf( currentYear ); |
| 3001 | + } |
2982 | 3002 |
|
2983 | 3003 | String inceptionYear = project.getInceptionYear();
|
2984 | 3004 |
|
|
0 commit comments