Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
cstamas committed Jun 9, 2022
1 parent d026df4 commit e0f0ed6
Show file tree
Hide file tree
Showing 17 changed files with 431 additions and 399 deletions.
21 changes: 12 additions & 9 deletions pom.xml
Expand Up @@ -96,15 +96,6 @@
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
<version>0.3.0.M1</version><!-- Maven 3.2.5 -->
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
Expand Down Expand Up @@ -145,6 +136,18 @@
<version>${slf4jVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
<version>0.3.0.M1</version><!-- Maven 3.2.5 -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.inject</artifactId>
<version>0.3.0.M1</version><!-- Maven 3.2.5 -->
<scope>test</scope>
</dependency>

</dependencies>

Expand Down
10 changes: 8 additions & 2 deletions src/main/java/org/apache/maven/shared/filtering/BaseFilter.java
Expand Up @@ -42,12 +42,18 @@
import org.codehaus.plexus.interpolation.SingleResponseValueSource;
import org.codehaus.plexus.interpolation.ValueSource;
import org.codehaus.plexus.interpolation.multi.MultiDelimiterStringSearchInterpolator;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

class BaseFilter
extends AbstractLogEnabled
implements DefaultFilterInfo
{
private final Logger logger = LoggerFactory.getLogger( getClass() );

protected Logger getLogger()
{
return logger;
}

@Override
public List<FilterWrapper> getDefaultFilterWrappers( final MavenProject mavenProject,
Expand Down
Expand Up @@ -87,15 +87,15 @@ public void copyFile( File from, File to, boolean filtering, List<FilterWrapper>
getLogger().debug( "filtering " + from.getPath() + " to " + to.getPath() );
}
FilterWrapper[] array = filterWrappers.toArray( new FilterWrapper[0] );
FileUtils.copyFile( from, to, encoding, array, false );
FilteringUtils.copyFile( from, to, encoding, array, false );
}
else
{
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( "copy " + from.getPath() + " to " + to.getPath() );
}
FileUtils.copyFile( from, to, encoding, new FilterWrapper[0], overwrite );
FilteringUtils.copyFile( from, to, encoding, new FilterWrapper[0], overwrite );
}
}
catch ( IOException e )
Expand Down
Expand Up @@ -206,9 +206,6 @@ public void filterResources( MavenResourcesExecution mavenResourcesExecution )
{
isFilteringUsed = true;
}
boolean ignoreDelta = !outputExists || buildContext.hasDelta( mavenResourcesExecution.getFileFilters() )
|| buildContext.hasDelta( getRelativeOutputDirectory( mavenResourcesExecution ) );
getLogger().debug( "ignoreDelta " + ignoreDelta );

DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir( resourceDirectory );
Expand Down Expand Up @@ -275,26 +272,6 @@ public void filterResources( MavenResourcesExecution mavenResourcesExecution )
encoding,
mavenResourcesExecution.isOverwrite() );
}

// deal with deleted source files

scanner = buildContext.newDeleteScanner( resourceDirectory );

setupScanner( resource, scanner, mavenResourcesExecution.isAddDefaultExcludes() );

scanner.scan();

List<String> deletedFiles = Arrays.asList( scanner.getIncludedFiles() );

for ( String name : deletedFiles )
{
File destinationFile = getDestinationFile( outputDirectory, targetPath, name, mavenResourcesExecution );

destinationFile.delete();

buildContext.refresh( destinationFile );
}

}

// Warn the user if all of the following requirements are met, to avoid those that are not affected
Expand Down Expand Up @@ -497,7 +474,7 @@ private String getRelativeOutputDirectory( MavenResourcesExecution execution )
if ( execution.getMavenProject() != null && execution.getMavenProject().getBasedir() != null )
{
String basedir = execution.getMavenProject().getBasedir().getAbsolutePath();
relOutDir = PathTool.getRelativeFilePath( basedir, relOutDir );
relOutDir = FilteringUtils.getRelativeFilePath( basedir, relOutDir );
if ( relOutDir == null )
{
relOutDir = execution.getOutputDirectory().getPath();
Expand Down Expand Up @@ -529,9 +506,9 @@ private String filterFileName( String name, List<FilterWrapper> wrappers )
IOUtils.copy( reader, writer );
String filteredFilename = writer.toString();

if ( getLogger().isDebugEnabled() )
if ( LOGGER.isDebugEnabled() )
{
getLogger().debug( "renaming filename " + name + " to " + filteredFilename );
LOGGER.debug( "renaming filename " + name + " to " + filteredFilename );
}
return filteredFilename;
}
Expand Down

0 comments on commit e0f0ed6

Please sign in to comment.