mirror of https://github.com/apache/maven.git
[MNG-4246] plugin resolution failures during pom-less execution (like archetype:generate)
o Strengthened existing IT for MNG-3099 which is just about the same issue git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@795346 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7f25ba33bc
commit
643384ce2d
|
@ -23,82 +23,44 @@ import org.apache.maven.it.Verifier;
|
||||||
import org.apache.maven.it.util.ResourceExtractor;
|
import org.apache.maven.it.util.ResourceExtractor;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a sample integration test. The IT tests typically
|
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3099">MNG-3099</a>.
|
||||||
* operate by having a sample project in the
|
|
||||||
* /src/test/resources folder along with a junit test like
|
|
||||||
* this one. The junit test uses the verifier (which uses
|
|
||||||
* the invoker) to invoke a new instance of Maven on the
|
|
||||||
* project in the resources folder. It then checks the
|
|
||||||
* results. This is a non-trivial example that shows two
|
|
||||||
* phases. See more information inline in the code.
|
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
|
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class MavenITmng3099SettingsProfilesWithNoPomTest
|
public class MavenITmng3099SettingsProfilesWithNoPomTest
|
||||||
extends AbstractMavenIntegrationTestCase
|
extends AbstractMavenIntegrationTestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
public MavenITmng3099SettingsProfilesWithNoPomTest()
|
public MavenITmng3099SettingsProfilesWithNoPomTest()
|
||||||
{
|
{
|
||||||
super( "(2.0.8,)" ); // 2.0.9+
|
super( "(2.0.8,)" ); // 2.0.9+
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testitMNG3099 ()
|
/**
|
||||||
|
* Verify that (active) profiles from the settings are effective even if no POM is in use (e.g archetype:create).
|
||||||
|
* In more detail, this means the plugin can be resolved from the repositories given in the settings and the plugin
|
||||||
|
* can access properties defined by the profiles.
|
||||||
|
*/
|
||||||
|
public void testit()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
// The testdir is computed from the location of this
|
|
||||||
// file.
|
|
||||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3099" );
|
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3099" );
|
||||||
|
|
||||||
File plugin = new File( testDir, "plugin" );
|
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
|
||||||
|
verifier.setAutoclean( false );
|
||||||
Verifier verifier;
|
verifier.deleteDirectory( "target" );
|
||||||
|
verifier.deleteArtifacts( "org.apache.maven.its.mng3099" );
|
||||||
verifier = new Verifier( plugin.getAbsolutePath() );
|
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() );
|
||||||
|
verifier.getCliOptions().add( "-s" );
|
||||||
verifier.executeGoal( "install" );
|
verifier.getCliOptions().add( "settings.xml" );
|
||||||
|
verifier.executeGoal( "org.apache.maven.its.mng3099:maven-mng3099-plugin:0.1:touch" );
|
||||||
/*
|
verifier.verifyErrorFreeLog();
|
||||||
* Reset the streams before executing the verifier
|
|
||||||
* again.
|
|
||||||
*/
|
|
||||||
verifier.resetStreams();
|
verifier.resetStreams();
|
||||||
|
|
||||||
verifier = new Verifier( testDir.getAbsolutePath() );
|
verifier.assertFilePresent( "target/PASSED.txt" );
|
||||||
|
verifier.assertFileNotPresent( "target/touch.txt" );
|
||||||
/*
|
|
||||||
* Use the settings for this test, which contains the profile we're looking for.
|
|
||||||
*/
|
|
||||||
List cliOptions = new ArrayList();
|
|
||||||
cliOptions.add( "-s" );
|
|
||||||
cliOptions.add( "\"" + new File( testDir, "settings.xml" ).getAbsolutePath() + "\"" );
|
|
||||||
|
|
||||||
verifier.setCliOptions( cliOptions );
|
|
||||||
|
|
||||||
verifier.setAutoclean( false );
|
|
||||||
verifier.executeGoal( "org.apache.maven.its.mng3099:maven-mng3099-plugin:1:profile-props" );
|
|
||||||
|
|
||||||
|
|
||||||
List lines = verifier.loadFile( new File( testDir, "log.txt" ), false );
|
|
||||||
boolean found = false;
|
|
||||||
for ( Iterator it = lines.iterator(); it.hasNext(); )
|
|
||||||
{
|
|
||||||
String line = (String) it.next();
|
|
||||||
if ( line.indexOf( "local-profile-prop=local-profile-prop-value" ) > -1 )
|
|
||||||
{
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !found )
|
|
||||||
{
|
|
||||||
fail( "Profile-injected property value: local-profile-prop-value was not found in log output." );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<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/maven-v4_0_0.xsd">
|
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<groupId>org.apache.maven.its.mng3099</groupId>
|
|
||||||
<artifactId>maven-mng3099-plugin</artifactId>
|
|
||||||
<version>1</version>
|
|
||||||
<packaging>maven-plugin</packaging>
|
|
||||||
|
|
||||||
<name>maven-mng3099-plugin</name>
|
|
||||||
<description>Tests properties injected as a result of active profiles in the user settings file.</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.maven</groupId>
|
|
||||||
<artifactId>maven-plugin-api</artifactId>
|
|
||||||
<version>2.0.7</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.maven</groupId>
|
|
||||||
<artifactId>maven-project</artifactId>
|
|
||||||
<version>2.0.7</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -1,40 +0,0 @@
|
||||||
package org.apache.maven.its.mng3099;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2001-2005 The Apache Software Foundation.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import org.apache.maven.plugin.AbstractMojo;
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests MNG-3099.
|
|
||||||
*
|
|
||||||
* @goal profile-props
|
|
||||||
* @requiresProject false
|
|
||||||
*/
|
|
||||||
public final class MNG3099Mojo extends AbstractMojo {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @parameter expression="${local-profile-prop}"
|
|
||||||
*/
|
|
||||||
private String localProfileProp;
|
|
||||||
|
|
||||||
|
|
||||||
public void execute() throws MojoExecutionException {
|
|
||||||
|
|
||||||
this.getLog().info("local-profile-prop=" + this.localProfileProp);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
This IT checks that profiles which are brought in from settings files (and which are activated via activeProfiles) are present even if no POM is in use.
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<metadata>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<name>Maven Integration Test Plugin :: Touch</name>
|
||||||
|
<prefix>mng3099</prefix>
|
||||||
|
<artifactId>maven-mng3099-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</metadata>
|
Binary file not shown.
|
@ -0,0 +1,69 @@
|
||||||
|
<?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/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>org.apache.maven.its.mng3099</groupId>
|
||||||
|
<artifactId>maven-mng3099-plugin</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
<packaging>maven-plugin</packaging>
|
||||||
|
|
||||||
|
<name>Maven Integration Test Plugin :: Touch</name>
|
||||||
|
<description>
|
||||||
|
A test plugin that creates an empty file.
|
||||||
|
</description>
|
||||||
|
<inceptionYear>2009</inceptionYear>
|
||||||
|
|
||||||
|
<distributionManagement>
|
||||||
|
<repository>
|
||||||
|
<id>maven-core-it</id>
|
||||||
|
<url>file:///${basedir}/repo</url>
|
||||||
|
</repository>
|
||||||
|
</distributionManagement>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.test.skip>true</maven.test.skip>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven</groupId>
|
||||||
|
<artifactId>maven-plugin-api</artifactId>
|
||||||
|
<version>2.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>.</directory>
|
||||||
|
<includes>
|
||||||
|
<include>pom.xml</include>
|
||||||
|
<include>src/**</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<metadata>
|
||||||
|
<groupId>org.apache.maven.its.mng3099</groupId>
|
||||||
|
<artifactId>maven-mng3099-plugin</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
<versioning>
|
||||||
|
<latest>0.1</latest>
|
||||||
|
<release>0.1</release>
|
||||||
|
<versions>
|
||||||
|
<version>0.1</version>
|
||||||
|
</versions>
|
||||||
|
<lastUpdated>20090718111552</lastUpdated>
|
||||||
|
</versioning>
|
||||||
|
</metadata>
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<settings
|
||||||
|
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Verify that (active) profiles from the settings are effective even if no POM is in use (e.g archetype:create).
|
||||||
|
In more detail, this means the plugin can be resolved from the repositories given in the settings and the plugin
|
||||||
|
can access properties defined by the profiles.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>local-profile</id>
|
||||||
|
<properties>
|
||||||
|
<touch.outputFile>target/PASSED.txt</touch.outputFile>
|
||||||
|
</properties>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>maven-core-it</id>
|
||||||
|
<url>@baseurl@/repo</url>
|
||||||
|
<releases>
|
||||||
|
<checksumPolicy>ignore</checksumPolicy>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>maven-core-it</id>
|
||||||
|
<url>@baseurl@/repo</url>
|
||||||
|
<releases>
|
||||||
|
<checksumPolicy>ignore</checksumPolicy>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
<activeProfiles>
|
||||||
|
<activeProfile>local-profile</activeProfile>
|
||||||
|
</activeProfiles>
|
||||||
|
|
||||||
|
</settings>
|
|
@ -1,20 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<settings
|
|
||||||
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
|
|
||||||
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>local-profile</id>
|
|
||||||
<properties>
|
|
||||||
<local-profile-prop>local-profile-prop-value</local-profile-prop>
|
|
||||||
</properties>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
|
|
||||||
<activeProfiles>
|
|
||||||
<activeProfile>local-profile</activeProfile>
|
|
||||||
</activeProfiles>
|
|
||||||
|
|
||||||
</settings>
|
|
Loading…
Reference in New Issue