mirror of https://github.com/apache/maven.git
o Deleted maven-it-plugin-generate-envar-properties which is superceded by maven-it-plugin-configuration
git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@718762 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cea4f6a175
commit
9f591c1482
|
@ -25,6 +25,7 @@ import org.apache.maven.it.util.ResourceExtractor;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
public class MavenIT0090Test
|
public class MavenIT0090Test
|
||||||
extends AbstractMavenIntegrationTestCase
|
extends AbstractMavenIntegrationTestCase
|
||||||
|
@ -37,14 +38,18 @@ public class MavenIT0090Test
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/it0090" );
|
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/it0090" );
|
||||||
|
|
||||||
Verifier verifier = new Verifier( testDir.getAbsolutePath(), true );
|
Verifier verifier = new Verifier( testDir.getAbsolutePath(), true );
|
||||||
Map envVars = new HashMap();
|
Map envVars = new HashMap();
|
||||||
envVars.put( "MAVEN_TEST_ENVAR", "MAVEN_TEST_ENVAR_VALUE" );
|
envVars.put( "MAVEN_TEST_ENVAR", "MAVEN_TEST_ENVAR_VALUE" );
|
||||||
verifier.executeGoal( "test", envVars );
|
verifier.setAutoclean( false );
|
||||||
verifier.assertFilePresent( "target/mojo-generated.properties" );
|
verifier.deleteDirectory( "target" );
|
||||||
|
verifier.executeGoal( "validate", envVars );
|
||||||
verifier.verifyErrorFreeLog();
|
verifier.verifyErrorFreeLog();
|
||||||
verifier.resetStreams();
|
verifier.resetStreams();
|
||||||
|
|
||||||
|
Properties props = verifier.loadProperties( "target/env.properties" );
|
||||||
|
assertEquals( "MAVEN_TEST_ENVAR_VALUE", props.getProperty( "stringParam" ) );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -119,12 +119,6 @@ under the License.
|
||||||
<version>${itPluginVersion}</version>
|
<version>${itPluginVersion}</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.maven.its.plugins</groupId>
|
|
||||||
<artifactId>maven-it-plugin-generate-envar-properties</artifactId>
|
|
||||||
<version>${itPluginVersion}</version>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.its.plugins</groupId>
|
<groupId>org.apache.maven.its.plugins</groupId>
|
||||||
<artifactId>maven-it-plugin-generate-properties</artifactId>
|
<artifactId>maven-it-plugin-generate-properties</artifactId>
|
||||||
|
|
|
@ -1,58 +1,52 @@
|
||||||
|
<?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>
|
<project>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<name>Maven Integration Test :: it0090</name>
|
|
||||||
<groupId>org.apache.maven.its.it0090</groupId>
|
<groupId>org.apache.maven.its.it0090</groupId>
|
||||||
<artifactId>maven-it-it0090</artifactId>
|
<artifactId>maven-it-it0090</artifactId>
|
||||||
<description>Test that ensures that envars are interpolated correctly into plugin
|
|
||||||
configurations.</description>
|
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
|
|
||||||
<repositories>
|
<name>Maven Integration Test :: it0090</name>
|
||||||
<repository>
|
<description>
|
||||||
<id>test-plugins</id>
|
Test that ensures that envars are interpolated correctly into plugin
|
||||||
<url>http://people.apache.org/repo/m2-snapshot-repository/</url>
|
configurations.
|
||||||
<releases><enabled>false</enabled></releases>
|
</description>
|
||||||
<snapshots><enabled>true</enabled></snapshots>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
<pluginRepositories>
|
|
||||||
<pluginRepository>
|
|
||||||
<id>test-plugins</id>
|
|
||||||
<url>http://people.apache.org/repo/m2-snapshot-repository/</url>
|
|
||||||
<releases><enabled>false</enabled></releases>
|
|
||||||
<snapshots><enabled>true</enabled></snapshots>
|
|
||||||
</pluginRepository>
|
|
||||||
</pluginRepositories>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<version>3.8.1</version>
|
|
||||||
<type>jar</type>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<build>
|
<build>
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.its.plugins</groupId>
|
<groupId>org.apache.maven.its.plugins</groupId>
|
||||||
<artifactId>maven-it-plugin-generate-envar-properties</artifactId>
|
<artifactId>maven-it-plugin-configuration</artifactId>
|
||||||
<version>2.1-SNAPSHOT</version>
|
<version>2.1-SNAPSHOT</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>process-resources</phase>
|
<phase>validate</phase>
|
||||||
<configuration>
|
<configuration>
|
||||||
<mavenTestEnvar>${env.MAVEN_TEST_ENVAR}</mavenTestEnvar>
|
<propertiesFile>target/env.properties</propertiesFile>
|
||||||
|
<stringParam>${env.MAVEN_TEST_ENVAR}</stringParam>
|
||||||
</configuration>
|
</configuration>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>generate-envar-properties</goal>
|
<goal>config</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
# When we want to test the filtering of envars
|
|
||||||
maven.test.envar=${env.MAVEN_TEST_ENVAR}
|
|
|
@ -1,35 +0,0 @@
|
||||||
package org.apache.maven.it0090;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
|
|
||||||
public class PomInterpolationTest
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
private String basedir;
|
|
||||||
|
|
||||||
protected void setUp()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
basedir = System.getProperty( "basedir" );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testProjectBuildDirectoryAfterForMojoExecution()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Properties testProperties = new Properties();
|
|
||||||
|
|
||||||
File testPropertiesFile = new File( basedir, "target/mojo-generated.properties" );
|
|
||||||
|
|
||||||
assertTrue( testPropertiesFile.exists() );
|
|
||||||
|
|
||||||
testProperties.load( new FileInputStream( testPropertiesFile ) );
|
|
||||||
|
|
||||||
File projectBuildDirectory = new File( basedir, "target" );
|
|
||||||
|
|
||||||
assertEquals( testProperties.getProperty( "maven.test.envar" ), "MAVEN_TEST_ENVAR_VALUE" );
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
<?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>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<artifactId>maven-it-plugins</artifactId>
|
|
||||||
<groupId>org.apache.maven.its.plugins</groupId>
|
|
||||||
<version>2.1-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>maven-it-plugin-generate-envar-properties</artifactId>
|
|
||||||
<packaging>maven-plugin</packaging>
|
|
||||||
|
|
||||||
<name>Maven Integration Test Plugin :: Envar</name>
|
|
||||||
<inceptionYear>2006</inceptionYear>
|
|
||||||
|
|
||||||
<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>
|
|
||||||
</project>
|
|
|
@ -1,71 +0,0 @@
|
||||||
package org.apache.maven.plugin.coreit;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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.plugin.AbstractMojo;
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interpolate some envars that are embedded in the POM and make sure they pass through
|
|
||||||
* the system.
|
|
||||||
*
|
|
||||||
* @goal generate-envar-properties
|
|
||||||
*/
|
|
||||||
public class InterpolatedEnvarConfigurationMojo
|
|
||||||
extends AbstractMojo
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @parameter expression="${basedir}"
|
|
||||||
*/
|
|
||||||
private String basedir;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @parameter expression="${mavenTestEnvar}"
|
|
||||||
*/
|
|
||||||
private String mavenTestEnvar;
|
|
||||||
|
|
||||||
public void execute()
|
|
||||||
throws MojoExecutionException
|
|
||||||
{
|
|
||||||
if ( mavenTestEnvar == null )
|
|
||||||
{
|
|
||||||
throw new MojoExecutionException( "The mavenTestEnvar field should not be null! You must run this using the maven-core-it scripts! ");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Properties mojoGeneratedPropeties = new Properties();
|
|
||||||
|
|
||||||
mojoGeneratedPropeties.put( "maven.test.envar", mavenTestEnvar );
|
|
||||||
|
|
||||||
FileOutputStream fos = new FileOutputStream( new File( basedir, "target/mojo-generated.properties" ) );
|
|
||||||
|
|
||||||
mojoGeneratedPropeties.store( fos, "# Properties generated by the execution of a mojo that uses interpolated envar values." );
|
|
||||||
}
|
|
||||||
catch( Exception e )
|
|
||||||
{
|
|
||||||
getLog().error( "Error creating mojo generated properties.", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -44,7 +44,6 @@ under the License.
|
||||||
<module>maven-it-plugin-expression</module>
|
<module>maven-it-plugin-expression</module>
|
||||||
<module>maven-it-plugin-file</module>
|
<module>maven-it-plugin-file</module>
|
||||||
<module>maven-it-plugin-fork</module>
|
<module>maven-it-plugin-fork</module>
|
||||||
<module>maven-it-plugin-generate-envar-properties</module>
|
|
||||||
<module>maven-it-plugin-generate-properties</module>
|
<module>maven-it-plugin-generate-properties</module>
|
||||||
<module>maven-it-plugin-no-project</module>
|
<module>maven-it-plugin-no-project</module>
|
||||||
<module>maven-it-plugin-packaging</module>
|
<module>maven-it-plugin-packaging</module>
|
||||||
|
|
Loading…
Reference in New Issue