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 49dc9ff Fixes #367 - Do not consider project level glob as additional input value (#372) 49dc9ff is described below commit 49dc9ffc280ec7e09f7f88898565d2524401e596 Author: Moritz Becker <moritz.bec...@gmx.at> AuthorDate: Fri Oct 10 07:50:44 2025 +0200 Fixes #367 - Do not consider project level glob as additional input value (#372) --- .../buildcache/checksum/MavenProjectInput.java | 2 +- .../apache/maven/buildcache/its/Issue367Test.java | 78 ++++++++++++++++++++++ .../projects/mbuildcache-367/.mvn/extensions.xml | 25 +++++++ .../.mvn/maven-build-cache-config.xml | 32 +++++++++ src/test/projects/mbuildcache-367/pom.xml | 33 +++++++++ .../main/custom-resources/input/test.properties | 1 + 6 files changed, 170 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/maven/buildcache/checksum/MavenProjectInput.java b/src/main/java/org/apache/maven/buildcache/checksum/MavenProjectInput.java index 969d10f..d305a12 100644 --- a/src/main/java/org/apache/maven/buildcache/checksum/MavenProjectInput.java +++ b/src/main/java/org/apache/maven/buildcache/checksum/MavenProjectInput.java @@ -370,7 +370,7 @@ private SortedSet<Path> getInputFiles() { Properties properties = project.getProperties(); for (String name : properties.stringPropertyNames()) { - if (name.startsWith(CACHE_INPUT_NAME)) { + if (name.startsWith(CACHE_INPUT_NAME) && !CACHE_INPUT_GLOB_NAME.equals(name)) { String path = properties.getProperty(name); startWalk(Paths.get(path), projectGlob, recursive, collectedFiles, visitedDirs); } diff --git a/src/test/java/org/apache/maven/buildcache/its/Issue367Test.java b/src/test/java/org/apache/maven/buildcache/its/Issue367Test.java new file mode 100644 index 0000000..4214401 --- /dev/null +++ b/src/test/java/org/apache/maven/buildcache/its/Issue367Test.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.buildcache.its; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; + +import org.apache.commons.lang3.SystemUtils; +import org.apache.maven.buildcache.its.junit.IntegrationTest; +import org.apache.maven.it.VerificationException; +import org.apache.maven.it.Verifier; +import org.junit.jupiter.api.Test; + +import static java.util.Arrays.asList; +import static org.junit.jupiter.api.Assumptions.assumeFalse; + +@IntegrationTest("src/test/projects/mbuildcache-367") +class Issue367Test { + + private static final String PROJECT_NAME = "org.apache.maven.caching.test:mbuildcache-367"; + + @Test + void fileOutsideInputDirectoryMatchingProjectLevelGlobPatternShouldNotInvalidateCache(Verifier verifier) + throws VerificationException, IOException { + assumeFalse(SystemUtils.IS_OS_WINDOWS); + + verifier.setAutoclean(false); + + verifier.setLogFileName("../log-0.txt"); + verifier.executeGoals(asList("package")); + verifier.verifyErrorFreeLog(); + verifier.verifyTextInLog("Local build was not found"); + verifyTextNotInLog(verifier, "Found cached build"); + + verifier.setLogFileName("../log-1.txt"); + verifier.executeGoals(asList("package")); + verifier.verifyErrorFreeLog(); + verifier.verifyTextInLog("Found cached build"); + verifyTextNotInLog(verifier, "Local build was not found"); + + Files.copy( + Paths.get(verifier.getBasedir(), "src/main/custom-resources/input/test.properties"), + Paths.get(verifier.getBasedir(), "{*.properties}")); + + verifier.setLogFileName("../log-2.txt"); + verifier.executeGoals(asList("package")); + verifier.verifyErrorFreeLog(); + verifier.verifyTextInLog("Found cached build"); + verifyTextNotInLog(verifier, "Local build was not found"); + } + + private static void verifyTextNotInLog(Verifier verifier, String text) throws VerificationException { + List<String> lines = verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false); + for (String line : lines) { + if (Verifier.stripAnsi(line).contains(text)) { + throw new VerificationException("Text found in log: " + text); + } + } + } +} diff --git a/src/test/projects/mbuildcache-367/.mvn/extensions.xml b/src/test/projects/mbuildcache-367/.mvn/extensions.xml new file mode 100644 index 0000000..8df78f8 --- /dev/null +++ b/src/test/projects/mbuildcache-367/.mvn/extensions.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright 2021 the original author or authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<extensions> + <extension> + <groupId>org.apache.maven.extensions</groupId> + <artifactId>maven-build-cache-extension</artifactId> + <version>${projectVersion}</version> + </extension> +</extensions> diff --git a/src/test/projects/mbuildcache-367/.mvn/maven-build-cache-config.xml b/src/test/projects/mbuildcache-367/.mvn/maven-build-cache-config.xml new file mode 100644 index 0000000..02c9adb --- /dev/null +++ b/src/test/projects/mbuildcache-367/.mvn/maven-build-cache-config.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<cache xmlns="http://maven.apache.org/BUILD-CACHE-CONFIG/1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/BUILD-CACHE-CONFIG/1.2.0 https://maven.apache.org/xsd/build-cache-config-1.2.0.xsd"> + <input> + <global> + <glob>{*.properties}</glob> + <includes> + <include>src/main/custom-resources/input/</include> + </includes> + </global> + </input> +</cache> diff --git a/src/test/projects/mbuildcache-367/pom.xml b/src/test/projects/mbuildcache-367/pom.xml new file mode 100644 index 0000000..6397b4b --- /dev/null +++ b/src/test/projects/mbuildcache-367/pom.xml @@ -0,0 +1,33 @@ +<!-- + + Copyright 2021 the original author or authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven.caching.test</groupId> + <artifactId>mbuildcache-367</artifactId> + <version>0.0.1-SNAPSHOT</version> + <packaging>jar</packaging> + + <properties> + <maven.compiler.source>1.8</maven.compiler.source> + <maven.compiler.target>1.8</maven.compiler.target> + + <maven.build.cache.input.glob>{*.properties}</maven.build.cache.input.glob> + </properties> +</project> diff --git a/src/test/projects/mbuildcache-367/src/main/custom-resources/input/test.properties b/src/test/projects/mbuildcache-367/src/main/custom-resources/input/test.properties new file mode 100644 index 0000000..f70f10e --- /dev/null +++ b/src/test/projects/mbuildcache-367/src/main/custom-resources/input/test.properties @@ -0,0 +1 @@ +A