Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<mavenArchiverVersion>3.5.1</mavenArchiverVersion>
<mavenFilteringVersion>3.2.0</mavenFilteringVersion>
<mavenVersion>3.2.5</mavenVersion>
<javaVersion>7</javaVersion>
<javaVersion>8</javaVersion>
<project.build.outputTimestamp>2021-09-05T09:31:59Z</project.build.outputTimestamp>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ private class DefaultWarPackagingContext
this.artifactFactory = artifactFactory;
this.filteringDeploymentDescriptors = filteringDeploymentDescriptors;
this.nonFilteredFileExtensions =
nonFilteredFileExtensions == null ? Collections.<String>emptyList() : nonFilteredFileExtensions;
nonFilteredFileExtensions == null ? Collections.emptyList() : nonFilteredFileExtensions;
this.resourceEncoding = resourceEncoding;
this.propertiesEncoding = propertiesEncoding;
// This is kinda stupid but if we loop over the current overlays and we request the path structure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.attribute.BasicFileAttributes;

import org.apache.commons.io.input.XmlStreamReader;
import org.apache.maven.artifact.Artifact;
Expand Down Expand Up @@ -342,14 +344,15 @@ protected boolean copyFile( WarPackagingContext context, File source, File desti
{
context.addResource( targetFilename );

if ( onlyIfModified && destination.lastModified() >= source.lastModified() )
BasicFileAttributes readAttributes = Files.readAttributes( source.toPath(), BasicFileAttributes.class );
if ( onlyIfModified && destination.lastModified() >= readAttributes.lastModifiedTime().toMillis() )
{
context.getLog().debug( " * " + targetFilename + " is up to date." );
return false;
}
else
{
if ( source.isDirectory() )
if ( readAttributes.isDirectory() )
{
context.getLog().warn( " + " + targetFilename + " is packaged from the source folder" );

Expand All @@ -364,16 +367,14 @@ protected boolean copyFile( WarPackagingContext context, File source, File desti
{
String msg = "Failed to create " + targetFilename;
context.getLog().error( msg, e );
IOException ioe = new IOException( msg );
ioe.initCause( e );
throw ioe;
throw new IOException( msg, e );
}
}
else
{
FileUtils.copyFile( source.getCanonicalFile(), destination );
// preserve timestamp
destination.setLastModified( source.lastModified() );
destination.setLastModified( readAttributes.lastModifiedTime().toMillis() );
context.getLog().debug( " + " + targetFilename + " has been copied." );
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected File setUpMojo( final String testId, ArtifactStub[] artifactStubs, Str
}
}

configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
setVariableValueToObject( mojo, "workDirectory", workDirectory );

return webAppDirectory;
Expand Down
46 changes: 23 additions & 23 deletions src/test/java/org/apache/maven/plugins/war/WarExplodedMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void testSimpleExplodedWar()

// configure mojo
resources[0].setDirectory( webAppResource.getAbsolutePath() );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
setVariableValueToObject( mojo, "webResources", resources );
mojo.execute();

Expand Down Expand Up @@ -124,7 +124,7 @@ public void testSimpleExplodedWarWTargetPath()
// configure mojo
resources[0].setDirectory( webAppResource.getAbsolutePath() );
resources[0].setTargetPath( "targetPath" );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
setVariableValueToObject( mojo, "webResources", resources );
mojo.execute();

Expand Down Expand Up @@ -162,7 +162,7 @@ public void testExplodedWar_WithCustomWebXML()
File webAppDirectory = new File( getTestDirectory(), testId );

// configure mojo
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
mojo.setWebXml( new File( xmlSource, "web.xml" ) );
mojo.execute();

Expand Down Expand Up @@ -200,7 +200,7 @@ public void testExplodedWar_WithContainerConfigXML()
File webAppDirectory = new File( getTestDirectory(), testId );

// configure mojo
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
mojo.setContainerConfigXML( new File( xmlSource, "config.xml" ) );
mojo.execute();

Expand Down Expand Up @@ -246,7 +246,7 @@ public void testExplodedWar_WithSimpleExternalWARFile()

// configure mojo
project.addArtifact( warArtifact );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
setVariableValueToObject( mojo, "workDirectory", workDirectory );
mojo.execute();

Expand Down Expand Up @@ -293,7 +293,7 @@ public void testExplodedWarMergeWarLocalFileOverride()

// configure mojo
project.addArtifact( warArtifact );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
setVariableValueToObject( mojo, "workDirectory", workDirectory );
mojo.execute();

Expand All @@ -309,7 +309,7 @@ public void testExplodedWarMergeWarLocalFileOverride()
expectedFile.setLastModified( time );

project.addArtifact( warArtifact );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
setVariableValueToObject( mojo, "workDirectory", workDirectory );
mojo.execute();

Expand Down Expand Up @@ -394,7 +394,7 @@ public void testExplodedWar_WithEJB()

// configure mojo
project.addArtifact( ejbArtifact );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
mojo.execute();

// validate operation
Expand Down Expand Up @@ -431,7 +431,7 @@ public void testExplodedWarWithJar()

// configure mojo
project.addArtifact( jarArtifact );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
mojo.execute();

// validate operation
Expand Down Expand Up @@ -469,7 +469,7 @@ public void testExplodedWar_WithEJBClient()

// configure mojo
project.addArtifact( ejbArtifact );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
mojo.execute();

// validate operation
Expand Down Expand Up @@ -507,7 +507,7 @@ public void testExplodedWar_WithTLD()

// configure mojo
project.addArtifact( tldArtifact );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
mojo.execute();

// validate operation
Expand Down Expand Up @@ -545,7 +545,7 @@ public void testExplodedWar_WithPAR()

// configure mojo
project.addArtifact( parartifact );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
mojo.execute();

// validate operation
Expand Down Expand Up @@ -585,7 +585,7 @@ public void testExplodedWarWithAar()

// configure mojo
project.addArtifact( aarArtifact );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
mojo.execute();

// validate operation
Expand Down Expand Up @@ -625,7 +625,7 @@ public void testExplodedWarWithMar()

// configure mojo
project.addArtifact( marArtifact );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
mojo.execute();

// validate operation
Expand Down Expand Up @@ -665,7 +665,7 @@ public void testExplodedWarWithXar()

// configure mojo
project.addArtifact( xarArtifact );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
mojo.execute();

// validate operation
Expand Down Expand Up @@ -708,7 +708,7 @@ public void testExplodedWar_WithDuplicateDependencies()
ejbArtifactDup.setGroupId( "org.dup.ejb" );
project.addArtifact( ejbArtifact );
project.addArtifact( ejbArtifactDup );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
mojo.execute();

// validate operation
Expand Down Expand Up @@ -760,7 +760,7 @@ public void testExplodedWar_DuplicateWithClassifier()
project.addArtifact( ejbArtifact );
project.addArtifact( ejbArtifactDup );

this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
mojo.execute();

// validate operation
Expand Down Expand Up @@ -796,7 +796,7 @@ public void testExplodedWar_WithClasses()
File classesDir = createClassesDir( testId, false );

// configure mojo
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
mojo.execute();

// validate operation
Expand Down Expand Up @@ -829,7 +829,7 @@ public void testExplodedWar_WithSourceIncludeExclude()
File webAppDirectory = new File( getTestDirectory(), testId );

// configure mojo
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
setVariableValueToObject( mojo, "warSourceIncludes", "**/*sit.jsp" );
setVariableValueToObject( mojo, "warSourceExcludes", "**/last*.*" );
mojo.execute();
Expand Down Expand Up @@ -874,7 +874,7 @@ public void testExplodedWar_WithWarDependencyIncludeExclude()

// configure mojo
project.addArtifact( includeexcludeWarArtifact );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
setVariableValueToObject( mojo, "dependentWarIncludes", "**/*Include.jsp,**/*.xml" );
setVariableValueToObject( mojo, "dependentWarExcludes", "**/*Exclude*,**/MANIFEST.MF" );
setVariableValueToObject( mojo, "workDirectory", workDirectory );
Expand Down Expand Up @@ -919,7 +919,7 @@ public void testExplodedWarWithSourceModificationCheck()
File webAppDirectory = new File( getTestDirectory(), testId );

// configure mojo
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );

// destination file is already created manually containing an "error" string
// source is newer than the destination file
Expand Down Expand Up @@ -982,7 +982,7 @@ public void testExplodedWarWithOutputFileNameMapping()
// configure mojo
project.addArtifact( jarArtifact );
mojo.setOutputFileNameMapping( "@{artifactId}@.@{extension}@" );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
mojo.execute();

// validate operation
Expand Down Expand Up @@ -1026,7 +1026,7 @@ public void testExplodedWarWithOutputFileNameMappingAndDuplicateDependencies()
project.addArtifact( ejbArtifact );
project.addArtifact( ejbArtifactDup );
mojo.setOutputFileNameMapping( "@{artifactId}@.@{extension}@" );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project );
mojo.execute();

// validate operation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void testSimpleExplodedInplaceWar()

// configure mojo
resources[0].setDirectory( webAppResource.getAbsolutePath() );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, null, project );
this.configureMojo( mojo, new LinkedList<>(), classesDir, webAppSource, null, project );
setVariableValueToObject( mojo, "webResources", resources );
mojo.execute();

Expand Down
Loading