diff --git a/daemon/src/main/java/org/apache/maven/project/SnapshotModelCache.java b/daemon/src/main/java/org/apache/maven/project/SnapshotModelCache.java index cdbffcad..b4aee747 100644 --- a/daemon/src/main/java/org/apache/maven/project/SnapshotModelCache.java +++ b/daemon/src/main/java/org/apache/maven/project/SnapshotModelCache.java @@ -38,6 +38,7 @@ public class SnapshotModelCache implements ModelCache { } private ModelCache getDelegate(String version) { - return version.contains("SNAPSHOT") ? reactorCache : globalCache; + return version.contains("SNAPSHOT") || version.contains("${") + ? reactorCache : globalCache; } } diff --git a/integration-tests/src/test/java/org/mvndaemon/mvnd/it/ParentWithPropertyTest.java b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/ParentWithPropertyTest.java new file mode 100644 index 00000000..6201d349 --- /dev/null +++ b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/ParentWithPropertyTest.java @@ -0,0 +1,70 @@ +/* + * Copyright 2022 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. + */ +package org.mvndaemon.mvnd.it; + +import java.nio.file.Path; +import javax.inject.Inject; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mvndaemon.mvnd.assertj.TestClientOutput; +import org.mvndaemon.mvnd.client.Client; +import org.mvndaemon.mvnd.junit.MvndTest; +import org.mvndaemon.mvnd.junit.TestParameters; +import org.mvndaemon.mvnd.junit.TestRegistry; +import org.mvndaemon.mvnd.junit.TestUtils; + +@MvndTest(projectDir = "src/test/projects/parent-with-property") +public class ParentWithPropertyTest { + + @Inject + Client client; + + @Inject + TestParameters parameters; + + @Inject + TestRegistry registry; + + @Test + void changeVersion() throws InterruptedException { + final Path parentDir = parameters.getTestDir().resolve("project"); + + /* Build */ + final TestClientOutput output1 = new TestClientOutput(); + client.execute(output1, "clean", "install", "-e").assertSuccess(); + output1.assertContainsMatchingSubsequence("Building parent 1", "Building child 1"); + assertDaemonRegistrySize(1); + + /* Wait, till the instance becomes idle */ + registry.awaitIdle(registry.getAll().get(0).getId()); + + /* Upgrade the parent */ + final Path parentPomPath = parentDir.resolve("pom.xml"); + TestUtils.replace(parentPomPath, "1", "2"); + + /* Build */ + final TestClientOutput output2 = new TestClientOutput(); + client.execute(output2, "clean", "install", "-e").assertSuccess(); + output2.assertContainsMatchingSubsequence("Building parent 2", "Building child 2"); + assertDaemonRegistrySize(1); + } + + private void assertDaemonRegistrySize(int size) { + Assertions.assertThat(registry.getAll().size()) + .as("Daemon registry size should be " + size) + .isEqualTo(size); + } +} diff --git a/integration-tests/src/test/projects/parent-with-property/child/pom.xml b/integration-tests/src/test/projects/parent-with-property/child/pom.xml new file mode 100644 index 00000000..8e394680 --- /dev/null +++ b/integration-tests/src/test/projects/parent-with-property/child/pom.xml @@ -0,0 +1,30 @@ + + + + 4.0.0 + + + org.mvndaemon.mvnd.test.parent-with-property + parent + ${revision} + .. + + + child + diff --git a/integration-tests/src/test/projects/parent-with-property/pom.xml b/integration-tests/src/test/projects/parent-with-property/pom.xml new file mode 100644 index 00000000..28953ef7 --- /dev/null +++ b/integration-tests/src/test/projects/parent-with-property/pom.xml @@ -0,0 +1,34 @@ + + + + 4.0.0 + + org.mvndaemon.mvnd.test.parent-with-property + parent + ${revision} + pom + + + 1 + + + + child + +