-
Notifications
You must be signed in to change notification settings - Fork 72
[#12288] Backport ITs for settings.xml profile -> LRM property propagation #428
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
168 changes: 168 additions & 0 deletions
168
.../src/test/java/org/apache/maven/it/MavenITgh12288SettingsProfileAetherPropertiesTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,168 @@ | ||
| /* | ||
| * 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.it; | ||
|
|
||
| import java.io.File; | ||
| import java.io.IOException; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.util.Comparator; | ||
|
|
||
| import org.apache.maven.shared.verifier.Verifier; | ||
| import org.apache.maven.shared.verifier.util.ResourceExtractor; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| /** | ||
| * Integration tests proving that {@code aether.*} properties declared in the | ||
| * {@code <properties>} block of a {@code settings.xml} profile are honored | ||
| * by the resolver at local repository manager initialization, regardless of | ||
| * which settings.xml-only activation channel was used. | ||
| * | ||
| * <p>Two activation channels are covered: | ||
| * <ul> | ||
| * <li>{@code <activation><activeByDefault>true</activeByDefault></activation>} | ||
| * on the profile itself;</li> | ||
| * <li>{@code <activeProfiles><activeProfile>...</activeProfile></activeProfiles>} | ||
| * at the top of {@code settings.xml}.</li> | ||
| * </ul> | ||
| * | ||
| * <p>In both cases the same profile sets: | ||
| * <pre> | ||
| * aether.enhancedLocalRepository.split = true | ||
| * aether.enhancedLocalRepository.localPrefix = it-custom-prefix | ||
| * </pre> | ||
| * and the test asserts that {@code mvn install} writes the installed pom | ||
| * under {@code <localRepo>/it-custom-prefix/<groupId-path>/...} rather | ||
| * than the flat or default-split layout. | ||
| * | ||
| * <p>A third test ({@code testActiveByDefaultDeactivatedViaCli}) guards | ||
| * that {@code -P !profileId} still deactivates an {@code <activeByDefault>} | ||
| * profile, so its {@code <properties>} are NOT merged into the resolver | ||
| * session config. | ||
| * | ||
| * <p>Backport target: requires the fix from apache/maven PR #12333 to be | ||
| * present in the running Maven 3.10.x build. | ||
| */ | ||
| public class MavenITgh12288SettingsProfileAetherPropertiesTest extends AbstractMavenIntegrationTestCase { | ||
|
|
||
| public MavenITgh12288SettingsProfileAetherPropertiesTest() { | ||
| super("[3.10.0-SNAPSHOT,)"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testActiveByDefaultProfile() throws Exception { | ||
| runAndAssertCustomPrefix("settings-active-by-default.xml"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testActiveProfilesList() throws Exception { | ||
| runAndAssertCustomPrefix("settings-active-profiles-list.xml"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testActiveByDefaultDeactivatedViaCli() throws Exception { | ||
| File testDir = | ||
| ResourceExtractor.simpleExtractResources(getClass(), "/gh-12288-settings-profile-aether-properties"); | ||
|
|
||
| Verifier verifier = newVerifier(testDir.getAbsolutePath()); | ||
| verifier.setAutoclean(false); | ||
| verifier.setLogFileName("log-deactivation.txt"); | ||
| verifier.deleteDirectory("target"); | ||
| verifier.deleteArtifacts("org.apache.maven.its.settings.profile.aether"); | ||
|
|
||
| File customPrefixSubtree = new File(verifier.getLocalRepository(), "it-custom-prefix"); | ||
| deleteRecursivelyIfExists(customPrefixSubtree); | ||
|
|
||
| verifier.addCliArgument("--settings"); | ||
| verifier.addCliArgument("settings-active-by-default.xml"); | ||
| verifier.addCliArgument("-P!aether-split-via-settings"); | ||
| verifier.addCliArgument("install"); | ||
| verifier.execute(); | ||
| verifier.verifyErrorFreeLog(); | ||
|
|
||
| String localRepo = verifier.getLocalRepository(); | ||
| String gavRelativePath = "org/apache/maven/its/settings/profile/aether/test-artifact/1.0/test-artifact-1.0.pom"; | ||
| File flatLayout = new File(localRepo, gavRelativePath); | ||
| File customPrefix = new File(localRepo, "it-custom-prefix/" + gavRelativePath); | ||
|
|
||
| assertTrue( | ||
| "Expected artifact at flat layout (profile deactivated via -P !), but not found at " + flatLayout, | ||
| flatLayout.exists()); | ||
|
|
||
| assertFalse( | ||
| "Found artifact at custom prefix " + customPrefix + " - deactivation via -P ! was ignored.", | ||
| customPrefix.exists()); | ||
| } | ||
|
|
||
| private void runAndAssertCustomPrefix(String settingsFile) throws Exception { | ||
| File testDir = | ||
| ResourceExtractor.simpleExtractResources(getClass(), "/gh-12288-settings-profile-aether-properties"); | ||
|
|
||
| Verifier verifier = newVerifier(testDir.getAbsolutePath()); | ||
| verifier.setAutoclean(false); | ||
| verifier.deleteDirectory("target"); | ||
| verifier.deleteArtifacts("org.apache.maven.its.settings.profile.aether"); | ||
|
|
||
| File customPrefixSubtree = new File(verifier.getLocalRepository(), "it-custom-prefix"); | ||
| deleteRecursivelyIfExists(customPrefixSubtree); | ||
|
|
||
| verifier.addCliArgument("--settings"); | ||
| verifier.addCliArgument(settingsFile); | ||
| verifier.addCliArgument("install"); | ||
| verifier.execute(); | ||
| verifier.verifyErrorFreeLog(); | ||
|
|
||
| String localRepo = verifier.getLocalRepository(); | ||
| String gavRelativePath = "org/apache/maven/its/settings/profile/aether/test-artifact/1.0/test-artifact-1.0.pom"; | ||
|
|
||
| File expectedAtCustomPrefix = new File(localRepo, "it-custom-prefix/" + gavRelativePath); | ||
| File flatLayout = new File(localRepo, gavRelativePath); | ||
| File defaultSplitPrefix = new File(localRepo, "installed/" + gavRelativePath); | ||
|
|
||
| assertTrue( | ||
| "Expected install to use custom localPrefix 'it-custom-prefix' from " | ||
| + settingsFile | ||
| + ", but artifact not found at " | ||
| + expectedAtCustomPrefix, | ||
| expectedAtCustomPrefix.exists()); | ||
|
|
||
| assertFalse( | ||
| "Found artifact at flat layout " | ||
| + flatLayout | ||
| + " - indicates the settings.xml profile properties did not reach the resolver" | ||
| + " session config in time for LRM init.", | ||
| flatLayout.exists()); | ||
|
|
||
| assertFalse( | ||
| "Found artifact at default split-LRM prefix " | ||
| + defaultSplitPrefix | ||
| + " - indicates split=true was honored but localPrefix was silently dropped.", | ||
| defaultSplitPrefix.exists()); | ||
| } | ||
|
|
||
| private static void deleteRecursivelyIfExists(File dir) throws IOException { | ||
| if (!dir.exists()) { | ||
| return; | ||
| } | ||
| Path root = dir.toPath(); | ||
| try (java.util.stream.Stream<Path> walk = Files.walk(root)) { | ||
| walk.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
core-it-suite/src/test/resources/gh-12288-settings-profile-aether-properties/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. | ||
| --> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <groupId>org.apache.maven.its.settings.profile.aether</groupId> | ||
| <artifactId>test-artifact</artifactId> | ||
| <version>1.0</version> | ||
| <packaging>pom</packaging> | ||
|
|
||
| <name>Maven Integration Test :: Settings Profile Aether Properties</name> | ||
| <description>Minimal project for proving that aether.enhancedLocalRepository.* | ||
| properties set in an active-by-default settings.xml profile are honored | ||
| by the resolver at local repository manager initialization.</description> | ||
| </project> |
33 changes: 33 additions & 0 deletions
33
...test/resources/gh-12288-settings-profile-aether-properties/settings-active-by-default.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <?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. | ||
| --> | ||
| <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"> | ||
| <profiles> | ||
| <profile> | ||
| <id>aether-split-via-settings</id> | ||
| <activation> | ||
| <activeByDefault>true</activeByDefault> | ||
| </activation> | ||
| <properties> | ||
| <aether.enhancedLocalRepository.split>true</aether.enhancedLocalRepository.split> | ||
| <aether.enhancedLocalRepository.localPrefix>it-custom-prefix</aether.enhancedLocalRepository.localPrefix> | ||
| </properties> | ||
| </profile> | ||
| </profiles> | ||
| </settings> |
33 changes: 33 additions & 0 deletions
33
...t/resources/gh-12288-settings-profile-aether-properties/settings-active-profiles-list.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <?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. | ||
| --> | ||
| <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"> | ||
| <activeProfiles> | ||
| <activeProfile>aether-split-via-settings</activeProfile> | ||
| </activeProfiles> | ||
| <profiles> | ||
| <profile> | ||
| <id>aether-split-via-settings</id> | ||
| <properties> | ||
| <aether.enhancedLocalRepository.split>true</aether.enhancedLocalRepository.split> | ||
| <aether.enhancedLocalRepository.localPrefix>it-custom-prefix</aether.enhancedLocalRepository.localPrefix> | ||
| </properties> | ||
| </profile> | ||
| </profiles> | ||
| </settings> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spotless expects different line wrapping here. CI shows the expected format is:
Running
mvn spotless:applywill fix this and the other violation automatically.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both items addressed in a2f8f8a:
mvn spotless:applystraightened out the line wrapping inMavenITgh12288SettingsProfileAetherPropertiesTestand the fixturepom.xml<description>.TestSuiteOrderingnow registersMavenITgh12288SettingsProfileAetherPropertiesTest.Thanks for the courtesy patch — applied verbatim for the IT-class formatting bit (
git apply) and letspotless:applyhandle thepom.xmldescription rewrap. CI green across the matrix.