Merge pull request #11 from apache/ignore
ignore versionBackup
diff --git a/src/it/basic/verify.bsh b/src/it/basic/verify.bsh
index 0e96a92..d5e9275 100644
--- a/src/it/basic/verify.bsh
+++ b/src/it/basic/verify.bsh
@@ -35,13 +35,28 @@
"META-INF/application.xml",
"META-INF/appserver-application.xml",
};
+
+// Reproducible Builds: check that every entry has the same timestamp
+long entryTime = -1;
+
for ( String included : includedEntries )
{
System.out.println( "Checking for existence of " + included );
- if ( jar.getEntry( included ) == null )
+ JarEntry jarEntry = jar.getEntry( included );
+ if ( jarEntry == null )
{
throw new IllegalStateException( "Missing archive entry: " + included );
}
+ if ( entryTime < 0 )
+ {
+ entryTime = jarEntry.getTime();
+ }
+ if ( entryTime != jarEntry.getTime() )
+ {
+ throw new IllegalStateException( "Invalid jar entry time: " + jarEntry.getTime()
+ + " of archive entry: " + included
+ + ", expected: " + entryTime );
+ }
}
jar.close();
diff --git a/src/it/skinny-wars/ear-module/pom.xml b/src/it/skinny-wars/ear-module/pom.xml
index 24981aa..6f9911a 100644
--- a/src/it/skinny-wars/ear-module/pom.xml
+++ b/src/it/skinny-wars/ear-module/pom.xml
@@ -27,6 +27,10 @@
<version>1.0</version>
<packaging>ear</packaging>
+ <properties>
+ <project.build.outputTimestamp>2020-05-01T12:12:12Z</project.build.outputTimestamp>
+ </properties>
+
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
diff --git a/src/it/skinny-wars/verify.bsh b/src/it/skinny-wars/verify.bsh
index f501413..279331b 100644
--- a/src/it/skinny-wars/verify.bsh
+++ b/src/it/skinny-wars/verify.bsh
@@ -35,12 +35,27 @@
"WEB-INF/web.xml",
"META-INF/MANIFEST.MF"
};
+
+// Reproducible Builds: check that every entry has the same timestamp
+long entryTime = -1;
+
for ( String included : includedEntries )
{
System.out.println( "Checking for included archive entry " + included );
- if ( jar.getEntry( included ) == null )
+ JarEntry jarEntry = jar.getEntry( included );
+ if ( jarEntry == null )
{
- throw new IllegalStateException( "Missing archive entry: " + included );
+ throw new IllegalStateException( "Missing WAR entry: " + included );
+ }
+ if ( entryTime < 0 )
+ {
+ entryTime = jarEntry.getTime();
+ }
+ if ( entryTime != jarEntry.getTime() )
+ {
+ throw new IllegalStateException( "Invalid jar entry time: " + jarEntry.getTime()
+ + " of archive entry: " + included
+ + ", expected: " + entryTime );
}
}
diff --git a/src/main/java/org/apache/maven/plugins/ear/EarMojo.java b/src/main/java/org/apache/maven/plugins/ear/EarMojo.java
index 413f3b6..8c4d4ce 100644
--- a/src/main/java/org/apache/maven/plugins/ear/EarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/ear/EarMojo.java
@@ -33,7 +33,9 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.Date;
import java.util.List;
+import java.util.Objects;
import java.util.zip.ZipException;
import org.apache.maven.archiver.MavenArchiveConfiguration;
@@ -208,19 +210,19 @@
private boolean skinnyWars;
/**
- * The Jar archiver.
+ * The Jar archiver to create the output archive.
*/
@Component( role = Archiver.class, hint = "jar" )
private JarArchiver jarArchiver;
/**
- * The Zip archiver.
+ * The Zip archiver for Skinny WAR repackaging.
*/
@Component( role = Archiver.class, hint = "zip" )
private ZipArchiver zipArchiver;
/**
- * The Zip Un archiver.
+ * The Zip Un archiver for Skinny WAR repackaging.
*/
@Component( role = UnArchiver.class, hint = "zip" )
private ZipUnArchiver zipUnArchiver;
@@ -284,7 +286,32 @@
// Initializes ear modules
super.execute();
+ final File earFile;
+ final MavenArchiver archiver;
+ final Date reproducibleLastModifiedDate;
+ try
+ {
+ earFile = getEarFile( outputDirectory, finalName, classifier );
+ archiver = new EarMavenArchiver( getModules() );
+ getLog().debug( "Jar archiver implementation [" + jarArchiver.getClass().getName() + "]" );
+ archiver.setArchiver( jarArchiver );
+ archiver.setOutputFile( earFile );
+
+ archiver.setCreatedBy( "Maven EAR Plugin", "org.apache.maven.plugins", "maven-ear-plugin" );
+
+ // configure for Reproducible Builds based on outputTimestamp value
+ reproducibleLastModifiedDate = archiver.configureReproducible( outputTimestamp );
+ }
+ catch ( Exception e )
+ {
+ throw new MojoExecutionException( "Error assembling EAR", e );
+ }
+
zipArchiver.setUseJvmChmod( useJvmChmod );
+ if ( reproducibleLastModifiedDate != null )
+ {
+ zipArchiver.configureReproducible( reproducibleLastModifiedDate );
+ }
zipUnArchiver.setUseJvmChmod( useJvmChmod );
final JavaEEVersion javaEEVersion = JavaEEVersion.getJavaEEVersion( version );
@@ -374,24 +401,13 @@
{
if ( new File( getWorkDirectory(), outdatedResource ).lastModified() < startTime )
{
+ getLog().info( "deleting outdated resource " + outdatedResource );
new File( getWorkDirectory(), outdatedResource ).delete();
}
}
try
{
- File earFile = getEarFile( outputDirectory, finalName, classifier );
- final MavenArchiver archiver = new EarMavenArchiver( getModules() );
- final JarArchiver theJarArchiver = getJarArchiver();
- getLog().debug( "Jar archiver implementation [" + theJarArchiver.getClass().getName() + "]" );
- archiver.setArchiver( theJarArchiver );
- archiver.setOutputFile( earFile );
-
- archiver.setCreatedBy( "Maven EAR Plugin", "org.apache.maven.plugins", "maven-ear-plugin" );
-
- // configure for Reproducible Builds based on outputTimestamp value
- archiver.configureReproducible( outputTimestamp );
-
getLog().debug( "Excluding " + Arrays.asList( getPackagingExcludes() ) + " from the generated EAR." );
getLog().debug( "Including " + Arrays.asList( getPackagingIncludes() ) + " in the generated EAR." );
@@ -558,7 +574,7 @@
*/
protected String[] getIncludes()
{
- return StringUtils.split( StringUtils.defaultString( earSourceIncludes ), "," );
+ return StringUtils.split( Objects.toString( earSourceIncludes, "" ), "," );
}
/**
@@ -685,18 +701,6 @@
unArchiver.extract();
}
- /**
- * Returns the {@link JarArchiver} implementation used to package the EAR file.
- *
- * By default the archiver is obtained from the Plexus container.
- *
- * @return the archiver
- */
- protected JarArchiver getJarArchiver()
- {
- return jarArchiver;
- }
-
private void copyFile( File source, File target )
throws MavenFilteringException, IOException, MojoExecutionException
{
diff --git a/src/test/java/org/apache/maven/plugins/ear/AbstractEarTestBase.java b/src/test/java/org/apache/maven/plugins/ear/AbstractEarTestBase.java
index f230de2..f4f0638 100644
--- a/src/test/java/org/apache/maven/plugins/ear/AbstractEarTestBase.java
+++ b/src/test/java/org/apache/maven/plugins/ear/AbstractEarTestBase.java
@@ -4,8 +4,6 @@
import java.util.TreeSet;
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugins.ear.AbstractEarModule;
-import org.apache.maven.plugins.ear.EarModule;
import org.apache.maven.plugins.ear.stub.ArtifactTestStub;
/*
diff --git a/src/test/java/org/apache/maven/plugins/ear/EarModuleTest.java b/src/test/java/org/apache/maven/plugins/ear/EarModuleTest.java
index d1abcdc..785f88b 100644
--- a/src/test/java/org/apache/maven/plugins/ear/EarModuleTest.java
+++ b/src/test/java/org/apache/maven/plugins/ear/EarModuleTest.java
@@ -21,7 +21,6 @@
import static org.junit.Assert.assertEquals;
-import org.apache.maven.plugins.ear.AbstractEarModule;
import org.junit.Test;
/**
diff --git a/src/test/java/org/apache/maven/plugins/ear/EnvEntryTest.java b/src/test/java/org/apache/maven/plugins/ear/EnvEntryTest.java
index 20f8d00..f1ba390 100644
--- a/src/test/java/org/apache/maven/plugins/ear/EnvEntryTest.java
+++ b/src/test/java/org/apache/maven/plugins/ear/EnvEntryTest.java
@@ -24,8 +24,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import org.apache.maven.plugins.ear.EnvEntry;
-
/**
* @author Stephane Nicoll
*/
diff --git a/src/test/java/org/apache/maven/plugins/ear/util/ArtifactRepositoryTest.java b/src/test/java/org/apache/maven/plugins/ear/util/ArtifactRepositoryTest.java
index 9e47c5f..f7739cc 100644
--- a/src/test/java/org/apache/maven/plugins/ear/util/ArtifactRepositoryTest.java
+++ b/src/test/java/org/apache/maven/plugins/ear/util/ArtifactRepositoryTest.java
@@ -24,8 +24,6 @@
import org.apache.maven.plugins.ear.AbstractEarTestBase;
import org.apache.maven.plugins.ear.EarPluginException;
-import org.apache.maven.plugins.ear.util.ArtifactRepository;
-import org.apache.maven.plugins.ear.util.ArtifactTypeMappingService;
import org.codehaus.plexus.configuration.PlexusConfigurationException;
import org.junit.Test;
diff --git a/src/test/java/org/apache/maven/plugins/ear/util/ArtifactTypeMappingServiceTest.java b/src/test/java/org/apache/maven/plugins/ear/util/ArtifactTypeMappingServiceTest.java
index bae714c..4805368 100644
--- a/src/test/java/org/apache/maven/plugins/ear/util/ArtifactTypeMappingServiceTest.java
+++ b/src/test/java/org/apache/maven/plugins/ear/util/ArtifactTypeMappingServiceTest.java
@@ -24,7 +24,6 @@
import org.apache.maven.plugins.ear.EarModuleFactory;
import org.apache.maven.plugins.ear.EarPluginException;
import org.apache.maven.plugins.ear.UnknownArtifactTypeException;
-import org.apache.maven.plugins.ear.util.ArtifactTypeMappingService;
import org.codehaus.plexus.configuration.PlexusConfigurationException;
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
diff --git a/src/test/java/org/apache/maven/plugins/ear/util/EarMavenArchiverTest.java b/src/test/java/org/apache/maven/plugins/ear/util/EarMavenArchiverTest.java
index 95793c5..693c84a 100644
--- a/src/test/java/org/apache/maven/plugins/ear/util/EarMavenArchiverTest.java
+++ b/src/test/java/org/apache/maven/plugins/ear/util/EarMavenArchiverTest.java
@@ -8,7 +8,6 @@
import org.apache.maven.plugins.ear.AbstractEarTestBase;
import org.apache.maven.plugins.ear.EarModule;
import org.apache.maven.plugins.ear.EjbModule;
-import org.apache.maven.plugins.ear.util.EarMavenArchiver;
import org.junit.Test;
/*
diff --git a/src/test/java/org/apache/maven/plugins/ear/util/JavaEEVersionTest.java b/src/test/java/org/apache/maven/plugins/ear/util/JavaEEVersionTest.java
index f94bb8b..9933b08 100644
--- a/src/test/java/org/apache/maven/plugins/ear/util/JavaEEVersionTest.java
+++ b/src/test/java/org/apache/maven/plugins/ear/util/JavaEEVersionTest.java
@@ -1,8 +1,5 @@
package org.apache.maven.plugins.ear.util;
-import org.apache.maven.plugins.ear.util.InvalidJavaEEVersion;
-import org.apache.maven.plugins.ear.util.JavaEEVersion;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file