This is an automated email from the ASF dual-hosted git repository. olamy pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-build-cache-extension.git
The following commit(s) were added to refs/heads/master by this push: new 642494d [PR-105] Regression : direct input files located in target (usually scanned via scanning plugins configurations) are not correctly excluded. (#105) 642494d is described below commit 642494d908ee165b264e0f48ec915032a6029f3e Author: Kévin Buntrock <kevin.buntr...@kleegroup.com> AuthorDate: Sun Nov 19 06:41:26 2023 +0100 [PR-105] Regression : direct input files located in target (usually scanned via scanning plugins configurations) are not correctly excluded. (#105) --- .../checksum/exclude/ExclusionResolver.java | 11 +++-- .../projects/include-exclude/assembly-sources.xml | 15 +++++++ src/test/projects/include-exclude/pom.xml | 48 ++++++++++++++++++++++ 3 files changed, 71 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/maven/buildcache/checksum/exclude/ExclusionResolver.java b/src/main/java/org/apache/maven/buildcache/checksum/exclude/ExclusionResolver.java index 4ac8ef1..189d310 100644 --- a/src/main/java/org/apache/maven/buildcache/checksum/exclude/ExclusionResolver.java +++ b/src/main/java/org/apache/maven/buildcache/checksum/exclude/ExclusionResolver.java @@ -138,19 +138,24 @@ public class ExclusionResolver { // target/test-classes by default Path testOutputDirectoryPath = absoluteNormalizedPath(build.getTestOutputDirectory()); - directoryExclusions.add( + addFileAndDirectoryExclusion( new Exclusion(buildDirectoryPath, Exclusion.MatcherType.FILENAME, Exclusion.EntryType.ALL)); if (!outputDirectoryPath.startsWith(buildDirectoryPath)) { - directoryExclusions.add( + addFileAndDirectoryExclusion( new Exclusion(outputDirectoryPath, Exclusion.MatcherType.FILENAME, Exclusion.EntryType.ALL)); } if (!testOutputDirectoryPath.startsWith(buildDirectoryPath)) { - directoryExclusions.add( + addFileAndDirectoryExclusion( new Exclusion(testOutputDirectoryPath, Exclusion.MatcherType.FILENAME, Exclusion.EntryType.ALL)); } } + private void addFileAndDirectoryExclusion(final Exclusion exclusion) { + directoryExclusions.add(exclusion); + filesExclusions.add(exclusion); + } + private Path absoluteNormalizedPath(String directory) { return Paths.get(directory).toAbsolutePath().normalize(); } diff --git a/src/test/projects/include-exclude/assembly-sources.xml b/src/test/projects/include-exclude/assembly-sources.xml new file mode 100644 index 0000000..42ab9ff --- /dev/null +++ b/src/test/projects/include-exclude/assembly-sources.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd"> + <id>sources</id> + <formats> + <format>zip</format> + </formats> + <includeBaseDirectory>false</includeBaseDirectory> + <fileSets> + <fileSet> + <directory>src</directory> + </fileSet> + </fileSets> +</assembly> diff --git a/src/test/projects/include-exclude/pom.xml b/src/test/projects/include-exclude/pom.xml index d23c69a..092c94d 100644 --- a/src/test/projects/include-exclude/pom.xml +++ b/src/test/projects/include-exclude/pom.xml @@ -51,6 +51,54 @@ <version>${projectVersion}</version> </extension> </extensions> + + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-assembly-plugin</artifactId> + <version>3.3.0</version> + <executions> + <execution> + <!-- zip sources --> + <id>make-sources</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <appendAssemblyId>true</appendAssemblyId> + <descriptors> + <descriptor>assembly-sources.xml</descriptor> + </descriptors> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <version>3.3.1</version> + <executions> + <execution> + <id>copy-resources</id> + <phase>validate</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>${project.build.directory}/copy-of-zip</outputDirectory> + <resources> + <resource> + <directory>${project.build.directory}</directory> + <includes> + <include>${project.build.directory}/include-exclude-${project.version}-sources.zip</include> + </includes> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> + </plugins> </build> </project>