o Decoupled from alias and default-value where not necessary

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@723978 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2008-12-06 13:20:22 +00:00
parent 6e587051f1
commit f36f13f50d
10 changed files with 97 additions and 9 deletions

View File

@ -50,9 +50,6 @@ public class MavenIT0043Test
File child2 = new File( testDir, "test" );
verifier = new Verifier( child2.getAbsolutePath() );
Properties systemProperties = new Properties();
systemProperties.put( "expression.expressions", "project/repositories,project/pluginRepositories" );
verifier.setSystemProperties( systemProperties );
verifier.setCliOptions( Collections.singletonList( "-s settings.xml" ) );
verifier.executeGoal( "org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval" );
verifier.verifyErrorFreeLog();

View File

@ -39,7 +39,11 @@ public class MavenIT0075Test
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/it0075" );
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "sub1/target" );
verifier.deleteDirectory( "sub2/target" );
Properties systemProperties = new Properties();
systemProperties.put( "expression.outputFile", "target/expression.properties" );
systemProperties.put( "activate", "anything" );
verifier.setSystemProperties( systemProperties );
verifier.executeGoal( "org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval" );

View File

@ -39,8 +39,11 @@ public class MavenITmng2136ActiveByDefaultProfileTest
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2136" );
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
Properties systemProperties = new Properties();
systemProperties.put( "expression.outputFile", new File( testDir, "target/expression.properties" ).getPath() );
systemProperties.put( "expression.expressions", "project/properties" );
verifier.setSystemProperties( systemProperties );
verifier.executeGoal( "org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval" );

View File

@ -28,4 +28,17 @@ under the License.
<name>Maven Integration Test :: it0043 setup</name>
<description>Preparation project with non-overriden URL to central for plugin download.</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-expression</artifactId>
<version>2.1-SNAPSHOT</version>
<configuration>
<outputFile>target/expression.properties</outputFile>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -44,4 +44,21 @@ under the License.
<url>file:///${basedir}/target/maven-core-it0043-repo</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-expression</artifactId>
<version>2.1-SNAPSHOT</version>
<configuration>
<outputFile>target/expression.properties</outputFile>
<expressions>
<expression>project/repositories</expression>
<expression>project/pluginRepositories</expression>
</expressions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -48,7 +48,7 @@ under the License.
<goal>config</goal>
</goals>
<configuration>
<outputFile>target/dist.properties</outputFile>
<propertiesFile>target/dist.properties</propertiesFile>
<listParam>
<!-- Get the distro repo, just like the Maven Deploy Plugin would do -->
<listParam>${project.distributionManagementArtifactRepository}</listParam>

View File

@ -51,7 +51,6 @@ public class InstanceofMojo
* The path to the properties file used to track the results of the instanceof tests.
*
* @parameter expression="${clsldr.instanceofPropertiesFile}"
* default-value="${project.build.directory}/instanceof.properties"
*/
private File instanceofPropertiesFile;

View File

@ -65,11 +65,38 @@ public class ConfigMojo
* The path to the properties file into which to save the mojo configuration. Unlike all the other parameters, this
* parameter features both a default value and an alias.
*
* @parameter alias="outputFile"
* expression="${config.propertiesFile} default-value="${project.build.directory}/config.properties"
* @parameter expression="${config.propertiesFile}
*/
private File propertiesFile;
/**
* A parameter with an alias.
*
* @parameter alias="aliasParamLegacy"
*/
private String aliasParam;
/**
* A parameter with a constant default value.
*
* @parameter default-value="maven-core-it"
*/
private String defaultParam;
/**
* A parameter with a default value using multiple expressions.
*
* @parameter default-value="${project.groupId}:${project.artifactId}:${project.version}"
*/
private String defaultParamWithExpression;
/**
* A parameter that combines all of the annotations.
*
* @parameter alias="fullyAnnotatedParam" expression="${config.aliasDefaultExpressionParam}" default-value="test"
*/
private String aliasDefaultExpressionParam;
/**
* A simple parameter of type {@link java.lang.Boolean}.
*
@ -168,6 +195,13 @@ public class ConfigMojo
*/
private String[] stringParams;
/**
* An array parameter of component type {@link java.io.File}.
*
* @parameter
*/
private File[] fileParams;
/**
* A collection parameter of type {@link java.util.List}.
*
@ -276,6 +310,10 @@ public class ConfigMojo
* injected by Maven.
*/
dumpValue( props, "propertiesFile", propertiesFile );
dumpValue( props, "aliasParam", aliasParam );
dumpValue( props, "defaultParam", defaultParam );
dumpValue( props, "defaultParamWithExpression", defaultParamWithExpression );
dumpValue( props, "aliasDefaultExpressionParam", aliasDefaultExpressionParam );
dumpValue( props, "booleanParam", booleanParam );
dumpValue( props, "byteParam", byteParam );
dumpValue( props, "shortParam", shortParam );
@ -290,6 +328,7 @@ public class ConfigMojo
dumpValue( props, "urlParam", urlParam );
dumpValue( props, "uriParam", uriParam );
dumpValue( props, "stringParams", stringParams );
dumpValue( props, "fileParams", fileParams );
dumpValue( props, "listParam", listParam );
dumpValue( props, "setParam", setParam );
dumpValue( props, "mapParam", mapParam );

View File

@ -63,12 +63,20 @@ public class EvalMojo
extends AbstractMojo
{
/**
* The project's base directory, used for manual path translation.
*
* @parameter default-value="${basedir}"
* @readonly
*/
private File basedir;
/**
* The path to the output file for the properties with the expression values. For each expression given by the
* parameter {@link #expressions} an similar named properties key will be used to save the expression value. If an
* expression evaluated to <code>null</code>, there will be no corresponding key in the properties file.
*
* @parameter expression="${expression.outputFile}" default-value="${project.build.directory}/expression.properties"
* @parameter expression="${expression.outputFile}"
*/
private File outputFile;
@ -132,6 +140,14 @@ public class EvalMojo
throw new MojoFailureException( "Path name for output file has not been specified" );
}
/*
* NOTE: We don't want to test path translation here.
*/
if ( !outputFile.isAbsolute() )
{
outputFile = new File( basedir, outputFile.getPath() ).getAbsoluteFile();
}
getLog().info( "[MAVEN-CORE-IT-LOG] Creating output file: " + outputFile );
Properties expressionProperties = new Properties();

View File

@ -50,7 +50,7 @@ public abstract class AbstractLogMojo
/**
* The path to the output file, relative to the current working directory.
*
* @parameter expression="${log.logFile}" default-value="target/it.log" alias="outputFile"
* @parameter expression="${log.logFile}"
*/
private File logFile;