mirror of https://github.com/apache/maven.git
[MNG-4791] [regression] POM artifacts passed into MavenProjectBuilder.buildFromRepository() are no longer resolved
o Added IT git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@992078 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f0f98c23ef
commit
a2cba60e95
|
@ -81,6 +81,7 @@ public class IntegrationTestSuite
|
|||
// -------------------------------------------------------------------------------------------------------------
|
||||
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
|
||||
|
||||
suite.addTestSuite( MavenITmng4791ProjectBuilderResolvesRemotePomArtifactTest.class );
|
||||
suite.addTestSuite( MavenITmng4786AntBased21xMojoSupportTest.class );
|
||||
suite.addTestSuite( MavenITmng4781DeploymentToNexusStagingRepoTest.class );
|
||||
suite.addTestSuite( MavenITmng4779MultipleDepsWithVersionRangeFromLocalRepoTest.class );
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
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 org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4791">MNG-4791</a>.
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng4791ProjectBuilderResolvesRemotePomArtifactTest
|
||||
extends AbstractMavenIntegrationTestCase
|
||||
{
|
||||
|
||||
public MavenITmng4791ProjectBuilderResolvesRemotePomArtifactTest()
|
||||
{
|
||||
super( "[2.0.3,3.0-alpha-1),[3.0-beta-1,)" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the project builder resolves the input artifact when building remote POMs if the input artifact
|
||||
* happens to be of type "pom".
|
||||
*/
|
||||
public void testit()
|
||||
throws Exception
|
||||
{
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4791" );
|
||||
|
||||
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
|
||||
verifier.setAutoclean( false );
|
||||
verifier.deleteDirectory( "target" );
|
||||
verifier.deleteArtifacts( "org.apache.maven.its.mng4791" );
|
||||
verifier.getCliOptions().add( "-s" );
|
||||
verifier.getCliOptions().add( "settings.xml" );
|
||||
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() );
|
||||
verifier.executeGoal( "validate" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
Properties props = verifier.loadProperties( "target/pom.properties" );
|
||||
|
||||
assertEquals( "0.1-20100902.190819-1",
|
||||
props.getProperty( "org.apache.maven.its.mng4791:a:pom:0.1-SNAPSHOT.version" ) );
|
||||
String path = props.getProperty( "org.apache.maven.its.mng4791:a:pom:0.1-SNAPSHOT.file" );
|
||||
assertTrue( path, path.endsWith( ".pom" ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
<?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.mng4791</groupId>
|
||||
<artifactId>test</artifactId>
|
||||
<version>0.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Maven Integration Test :: MNG-4791</name>
|
||||
<description>
|
||||
Test that the project builder resolves the input artifact when building remote POMs if the input artifact
|
||||
happens to be of type "pom".
|
||||
</description>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.its.plugins</groupId>
|
||||
<artifactId>maven-it-plugin-project</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>test</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>remote-pom</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.its.mng4791</groupId>
|
||||
<artifactId>a</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<!-- key point here is using type=pom -->
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,39 @@
|
|||
<?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.mng4791</groupId>
|
||||
<artifactId>a</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>MNG-4791</name>
|
||||
<description>PASSED</description>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>maven-core-it</id>
|
||||
<url>file:///${basedir}/repo</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
</project>
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>org.apache.maven.its.mng4791</groupId>
|
||||
<artifactId>a</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<versioning>
|
||||
<snapshot>
|
||||
<timestamp>20100902.190819</timestamp>
|
||||
<buildNumber>1</buildNumber>
|
||||
</snapshot>
|
||||
<lastUpdated>20100902190819</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
|
@ -0,0 +1,55 @@
|
|||
<?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>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>maven-core-it-repo</id>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>maven-core-it-repo</id>
|
||||
<url>@baseurl@/repo</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<checksumPolicy>ignore</checksumPolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>maven-core-it-repo</id>
|
||||
<url>@baseurl@/repo</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<checksumPolicy>ignore</checksumPolicy>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
<activeProfiles>
|
||||
<activeProfile>maven-core-it-repo</activeProfile>
|
||||
</activeProfiles>
|
||||
</settings>
|
|
@ -45,18 +45,20 @@ public abstract class AbstractPomMojo
|
|||
|
||||
protected void dump( Properties props, String key, MavenProject project )
|
||||
{
|
||||
props.setProperty( key + "project.id", project.getId() );
|
||||
if ( project.getName() != null )
|
||||
{
|
||||
props.setProperty( key + "project.name", project.getName() );
|
||||
}
|
||||
if ( project.getDescription() != null )
|
||||
{
|
||||
props.setProperty( key + "project.description", project.getDescription() );
|
||||
}
|
||||
put( props, key + "project.id", project.getId() );
|
||||
put( props, key + "project.name", project.getName() );
|
||||
put( props, key + "project.description", project.getDescription() );
|
||||
if ( project.getArtifact() != null )
|
||||
{
|
||||
props.setProperty( key + "artifact.id", project.getArtifact().getId() );
|
||||
put( props, key + "artifact.id", project.getArtifact().getId() );
|
||||
}
|
||||
}
|
||||
|
||||
protected void put( Properties props, String key, Object value )
|
||||
{
|
||||
if ( value != null )
|
||||
{
|
||||
props.setProperty( key, value.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -104,18 +104,23 @@ public class BuildRemotePomMojo
|
|||
dependency.getVersion(), dependency.getType(),
|
||||
dependency.getClassifier() );
|
||||
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Building " + artifact.getId() );
|
||||
String id = artifact.getId();
|
||||
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Building " + id );
|
||||
|
||||
try
|
||||
{
|
||||
MavenProject project = builder.buildFromRepository( artifact, remoteRepositories, localRepository );
|
||||
|
||||
dump( props, artifact.getId() + ".", project );
|
||||
dump( props, id + ".", project );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
getLog().warn( "Failed to build remote POM for " + artifact.getId(), e );
|
||||
}
|
||||
|
||||
put( props, id + ".file", artifact.getFile() );
|
||||
put( props, id + ".version", artifact.getVersion() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue