Merge pull request #189 from hgschmie/mng-7529

[MNG-7529] Integration test for MNG-7529
This commit is contained in:
Henning Schmiedehausen 2022-08-26 10:34:29 -07:00 committed by GitHub
commit fac10d2c91
19 changed files with 406 additions and 0 deletions

View File

@ -106,6 +106,7 @@ public class IntegrationTestSuite
// Tests that don't run stable and need to be fixed
// -------------------------------------------------------------------------------------------------------------
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
suite.addTestSuite( MavenITmng7529VersionRangeRepositorySelection.class );
suite.addTestSuite( MavenITmng7443ConsistencyOfOptionalProjectsAndProfilesTest.class );
suite.addTestSuite( MavenITmng7353CliGoalInvocationTest.class );
suite.addTestSuite( MavenITmng7504NotWarnUnsupportedReportPluginsTest.class );

View File

@ -0,0 +1,57 @@
package org.apache.maven.it;
/*
* 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.
*/
import java.io.File;
import java.util.Properties;
import org.apache.maven.it.util.ResourceExtractor;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-7529">MNG-7529</a>.
*/
public class MavenITmng7529VersionRangeRepositorySelection
extends AbstractMavenIntegrationTestCase {
public MavenITmng7529VersionRangeRepositorySelection() {
super("(3.8.6,)");
}
/**
* Test dependency resolution from a version range using multiple remote repositories
* with snapshot or release enabled.
*
* @throws Exception in case of failure
*/
public void testit()
throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-7529");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifacts("org.apache.maven.its.mng7529");
verifier.addCliOption("--settings");
verifier.addCliOption("settings.xml");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties());
verifier.executeGoal("validate");
verifier.verifyErrorFreeLog();
verifier.resetStreams();
}
}

View File

@ -0,0 +1,3 @@
*.pom text eol=lf
maven-metadata.xml text eol=lf

View File

@ -0,0 +1,62 @@
<?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>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng7529</groupId>
<artifactId>test</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>Maven Integration Test :: MNG-7529</name>
<description>
Verify that artifact ranges are resolved to the right release repository.
</description>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng7529</groupId>
<artifactId>a</artifactId>
<version>(0.0,]</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>mng-7529-version-range-repository-selection-plugin</artifactId>
<version>2.1-SNAPSHOT</version>
<executions>
<execution>
<id>resolve</id>
<phase>validate</phase>
<goals>
<goal>resolve</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,3 @@
*.pom text eol=lf
maven-metadata.xml text eol=lf

View File

@ -0,0 +1 @@
d532fcb4ba249192671e9954b80422819ce72679

View File

@ -0,0 +1,28 @@
<?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>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng7529</groupId>
<artifactId>a</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
</project>

View File

@ -0,0 +1 @@
e231c56d8ec5e15fa40147933ece7335cb450b80

View File

@ -0,0 +1 @@
d532fcb4ba249192671e9954b80422819ce72679

View File

@ -0,0 +1,29 @@
<?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>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng7529</groupId>
<artifactId>a</artifactId>
<version>1.1</version>
<packaging>jar</packaging>
</project>

View File

@ -0,0 +1 @@
2463dfbdb7f0a1efbb1163e39dfed1f5a4a8bdc5

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?><metadata>
<groupId>org.apache.maven.its.mng7529</groupId>
<artifactId>a</artifactId>
<version>1.0</version>
<versioning>
<release>1.1</release>
<versions>
<version>1.0</version>
<version>1.1</version>
</versions>
<lastUpdated>20220820180700</lastUpdated>
</versioning>
</metadata>

View File

@ -0,0 +1 @@
1879cdd62495339b931a092a7e899b2dce39b826

View File

@ -0,0 +1,61 @@
<?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>
<!-- <mirrors>-->
<!-- <mirror>-->
<!-- <id>maven-core-it</id>-->
<!-- <url>@baseurl@/repo</url>-->
<!-- <mirrorOf>central</mirrorOf>-->
<!-- </mirror>-->
<!-- </mirrors>-->
<profiles>
<profile>
<id>maven-core-it-repo</id>
<repositories>
<repository>
<id>maven-core-it-snapshots</id>
<url>@baseurl@/repo</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<checksumPolicy>ignore</checksumPolicy>
</snapshots>
</repository>
<repository>
<id>maven-core-it</id>
<url>@baseurl@/repo</url>
<releases>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>maven-core-it-repo</activeProfile>
</activeProfiles>
</settings>

View File

@ -0,0 +1,66 @@
<?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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>maven-it-plugins</artifactId>
<groupId>org.apache.maven.its.plugins</groupId>
<version>2.1-SNAPSHOT</version>
</parent>
<artifactId>mng-7529-version-range-repository-selection-plugin</artifactId>
<packaging>maven-plugin</packaging>
<properties>
<maven-version>3.6.0</maven-version>
</properties>
<name>Maven IT Plugin :: mng-7529 plugin</name>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>${maven-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>${maven-version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,77 @@
package org.apache.maven.its.mng7529.plugin;
/*
* 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.
*/
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.DefaultDependencyResolutionRequest;
import org.apache.maven.project.DefaultProjectBuildingRequest;
import org.apache.maven.project.DependencyResolutionRequest;
import org.apache.maven.project.DependencyResolutionResult;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectDependenciesResolver;
/**
* Attempts to resolve a single artifact from dependencies with the project dependency resolver,
* and logs the results for the Verifier to look at.
*/
@Mojo( name = "resolve", requiresDependencyResolution = ResolutionScope.NONE )
public class ResolveMojo
extends AbstractMojo
{
@Parameter( defaultValue = "${project}", readonly = true, required = true )
private MavenProject project;
@Parameter( defaultValue = "${session}", readonly = true, required = true )
private MavenSession mavenSession;
@Component
private ProjectDependenciesResolver dependencyResolver;
public void execute()
throws MojoExecutionException
{
try
{
DefaultProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(
mavenSession.getProjectBuildingRequest() );
buildingRequest.setRemoteRepositories( project.getRemoteArtifactRepositories() );
DependencyResolutionRequest request = new DefaultDependencyResolutionRequest();
request.setMavenProject( project );
request.setRepositorySession( buildingRequest.getRepositorySession() );
DependencyResolutionResult result = dependencyResolver.resolve( request );
getLog().info( "Resolution successful, resolved ok" );
}
catch ( Exception e )
{
getLog().error( "Resolution failed, could not resolve ranged dependency"
+ " (you hit MNG-7529)" );
}
}
}

View File

@ -84,6 +84,7 @@ under the License.
<module>mng5805-plugin-dep</module>
<module>mng5958-extension</module>
<module>mng6759-plugin-resolves-project-dependencies</module>
<module>mng7529-plugin</module>
</modules>
<distributionManagement>