diff --git a/tycho-p2-director-plugin/src/main/java/org/eclipse/tycho/plugins/p2/director/ProductArchiverMojo.java b/tycho-p2-director-plugin/src/main/java/org/eclipse/tycho/plugins/p2/director/ProductArchiverMojo.java index b5b5e5af9b..e6e2e16c10 100644 --- a/tycho-p2-director-plugin/src/main/java/org/eclipse/tycho/plugins/p2/director/ProductArchiverMojo.java +++ b/tycho-p2-director-plugin/src/main/java/org/eclipse/tycho/plugins/p2/director/ProductArchiverMojo.java @@ -125,6 +125,15 @@ public final class ProductArchiverMojo extends AbstractProductMojo { @Parameter private boolean parallel; + /** + * Controls if for {@code .tar.gz} archives the creation-time is stored as + * {@code LIBARCHIVE.creationtime } attribute in each entry. Currently {@code GNU tar} does not + * support that attributes and emits warnings about the {@code unknown extended header keyword + * 'LIBARCHIVE.creationtime'} when extracting such archive. + */ + @Parameter(defaultValue = "false") + private boolean storeCreationTime; + @Component private MavenProjectHelper helper; @@ -230,6 +239,7 @@ private void materialize(Product product, TargetEnvironment env) throws MojoExec private void createCommonsCompressTarGz(File productArchive, File sourceDir) throws IOException { TarGzArchiver archiver = new TarGzArchiver(); + archiver.setStoreCreationTimeAttribute(storeCreationTime); archiver.setLog(getLog()); archiver.addDirectory(sourceDir); archiver.setDestFile(productArchive); diff --git a/tycho-p2-director-plugin/src/main/java/org/eclipse/tycho/plugins/tar/TarGzArchiver.java b/tycho-p2-director-plugin/src/main/java/org/eclipse/tycho/plugins/tar/TarGzArchiver.java index 51792d9a6e..b8054f9616 100644 --- a/tycho-p2-director-plugin/src/main/java/org/eclipse/tycho/plugins/tar/TarGzArchiver.java +++ b/tycho-p2-director-plugin/src/main/java/org/eclipse/tycho/plugins/tar/TarGzArchiver.java @@ -52,6 +52,7 @@ public class TarGzArchiver { private File destFile; private List sourceDirs = new ArrayList<>(); private Log log = new SystemStreamLog(); + private boolean storeCreationTime; public TarGzArchiver() { } @@ -64,6 +65,10 @@ public void setDestFile(File destFile) { this.destFile = destFile; } + public void setStoreCreationTimeAttribute(boolean storeCreationTime) { + this.storeCreationTime = storeCreationTime; + } + public void addDirectory(File directory) { this.sourceDirs.add(directory); } @@ -129,6 +134,9 @@ private TarArchiveEntry createTarEntry(File tarRootDir, File source) throws IOEx tarEntry.setMode(FilePermissionHelper.toOctalFileMode(attrs.permissions())); } tarEntry.setModTime(source.lastModified()); + if (!storeCreationTime) { // GNU tar cannot handle 'LIBARCHIVE.creationtime' attributes and emits a lot of warnings on it + tarEntry.setCreationTime(null); + } return tarEntry; }