[pkg-java] r18649 - in trunk/maven-archiver/debian: . patches
Emmanuel Bourg
ebourg-guest at moszumanska.debian.org
Sun Mar 1 22:23:56 UTC 2015
Author: ebourg-guest
Date: 2015-03-01 22:23:56 +0000 (Sun, 01 Mar 2015)
New Revision: 18649
Added:
trunk/maven-archiver/debian/patches/02-use-changelog-date-as-pom.properties-timestamp.patch
Modified:
trunk/maven-archiver/debian/changelog
trunk/maven-archiver/debian/patches/series
Log:
Honour DEB_BUILD_DATE when generating pom.properties (#775010)
Modified: trunk/maven-archiver/debian/changelog
===================================================================
--- trunk/maven-archiver/debian/changelog 2015-02-27 15:23:39 UTC (rev 18648)
+++ trunk/maven-archiver/debian/changelog 2015-03-01 22:23:56 UTC (rev 18649)
@@ -1,3 +1,13 @@
+maven-archiver (2.5-2) UNRELEASED; urgency=medium
+
+ * Team upload.
+ * The date set in the DEB_BUILD_DATE environment variable is now used
+ for the timestamp in the pom.properties file embedded in the jar files
+ generated by maven-archiver to make the builds reproducible.
+ Thanks to Chris West (Closes: #775010)
+
+ -- Emmanuel Bourg <ebourg at apache.org> Sun, 01 Mar 2015 23:11:39 +0100
+
maven-archiver (2.5-1) unstable; urgency=medium
* Team upload.
Added: trunk/maven-archiver/debian/patches/02-use-changelog-date-as-pom.properties-timestamp.patch
===================================================================
--- trunk/maven-archiver/debian/patches/02-use-changelog-date-as-pom.properties-timestamp.patch (rev 0)
+++ trunk/maven-archiver/debian/patches/02-use-changelog-date-as-pom.properties-timestamp.patch 2015-03-01 22:23:56 UTC (rev 18649)
@@ -0,0 +1,100 @@
+Description: Honour DEB_BUILD_DATE when generating pom.properties
+Author: Chris West <solo-debianbugs at goeswhere.com>, Emmanuel Bourg <ebourg at apache.org>
+Forwarded: not-needed
+Bug-Debian: https://bugs.debian.org/775010
+--- a/src/main/java/org/apache/maven/archiver/PomPropertiesUtil.java
++++ b/src/main/java/org/apache/maven/archiver/PomPropertiesUtil.java
+@@ -25,6 +25,7 @@
+ import java.io.IOException;
+ import java.io.InputStream;
+ import java.io.OutputStream;
++import java.util.Date;
+ import java.util.Properties;
+
+ import org.apache.maven.project.MavenProject;
+@@ -105,7 +106,8 @@
+ final String artifactId = project.getArtifactId();
+ final String groupId = project.getGroupId();
+
+- Properties p = new Properties();
++ Date buildDate = DebianUtils.getDebianBuildDate();
++ Properties p = buildDate == null ? new Properties() : new TimestampedProperties(buildDate);
+
+ p.setProperty( "groupId", project.getGroupId() );
+
+--- /dev/null
++++ b/src/main/java/org/apache/maven/archiver/TimestampedProperties.java
+@@ -0,0 +1,45 @@
++package org.apache.maven.archiver;
++
++import java.io.*;
++import java.util.*;
++import java.util.regex.*;
++
++/**
++ * Properties file timestamped with a specified date.
++ */
++class TimestampedProperties extends Properties
++{
++ private Date date;
++
++ public TimestampedProperties(Date date) {
++ this.date = date;
++ }
++
++ @Override
++ public void store(OutputStream out, String comments) throws IOException {
++ store(new OutputStreamWriter(out, "ISO-8859-1"), comments);
++ }
++
++ @Override
++ public void store(Writer out, String comments) throws IOException {
++ // store the properties file in memory
++ StringWriter buffer = new StringWriter();
++ super.store(buffer, comments);
++
++ // Replace the date on the second line of the file
++ String[] lines = buffer.toString().split(Pattern.quote(System.getProperty("line.separator")));
++ lines[1] = "#" + date.toString();
++
++ // write the file
++ BufferedWriter writer = new BufferedWriter(out);
++ try {
++ for (String line : lines) {
++ writer.write(line);
++ writer.newLine();
++ }
++ writer.flush();
++ } finally {
++ writer.close();
++ }
++ }
++}
+--- /dev/null
++++ b/src/main/java/org/apache/maven/archiver/DebianUtils.java
+@@ -0,0 +1,25 @@
++package org.apache.maven.archiver;
++
++import java.text.ParseException;
++import java.text.SimpleDateFormat;
++import java.util.Date;
++
++class DebianUtils {
++
++ /**
++ * Returns the Debian build date specified by the DEB_BUILD_DATE environment variable.
++ */
++ static Date getDebianBuildDate() {
++ String envName = "DEB_BUILD_DATE";
++ String envVariable = System.getenv(envName);
++ if (envVariable == null) {
++ return null;
++ }
++
++ try {
++ return new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz").parse(envVariable);
++ } catch (ParseException e) {
++ throw new IllegalArgumentException("maven-archiver: " + envName + " not in recognised format", e);
++ }
++ }
++}
Modified: trunk/maven-archiver/debian/patches/series
===================================================================
--- trunk/maven-archiver/debian/patches/series 2015-02-27 15:23:39 UTC (rev 18648)
+++ trunk/maven-archiver/debian/patches/series 2015-03-01 22:23:56 UTC (rev 18649)
@@ -1 +1,2 @@
01-maven-artifact-compatibility.patch
+02-use-changelog-date-as-pom.properties-timestamp.patch
More information about the pkg-java-commits
mailing list