Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid caching parent with a version containing a property, fixes #594 #602

Merged
merged 2 commits into from
Mar 3, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public Object get(String groupId, String artifactId, String version, String tag)
}

private ModelCache getDelegate(String version) {
return version.contains("SNAPSHOT") ? reactorCache : globalCache;
return version.contains("SNAPSHOT") || version.contains("${")
? reactorCache : globalCache;
}
}
Original file line number Diff line number Diff line change
@@ -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, "<revision>1</revision>", "<revision>2</revision>");

/* 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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--

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.

-->
<project>

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.mvndaemon.mvnd.test.parent-with-property</groupId>
<artifactId>parent</artifactId>
<version>${revision}</version>
<relativePath>..</relativePath>
</parent>

<artifactId>child</artifactId>
</project>
34 changes: 34 additions & 0 deletions integration-tests/src/test/projects/parent-with-property/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!--

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.

-->
<project>

<modelVersion>4.0.0</modelVersion>

<groupId>org.mvndaemon.mvnd.test.parent-with-property</groupId>
<artifactId>parent</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>

<properties>
<revision>1</revision>
</properties>

<modules>
<module>child</module>
</modules>
</project>