You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2009/02/19 18:48:23 UTC
svn commit: r745944 - in /maven/core-integration-testing/trunk:
core-it-suite/src/test/java/org/apache/maven/it/
core-it-suite/src/test/resources/bootstrap/
core-it-suite/src/test/resources/mng-3714/
core-it-suite/src/test/resources/mng-3714/src/ core-...
Author: brett
Date: Thu Feb 19 17:48:20 2009
New Revision: 745944
URL: http://svn.apache.org/viewvc?rev=745944&view=rev
Log:
[MNG-3714] add integration test for a command line option for toolchains
Added:
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3714ToolchainsCliOptionTest.java (with props)
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3714/
- copied from r745915, maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-0557/
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3714/toolchains.xml (with props)
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-toolchain/ (props changed)
- copied from r745905, maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-touch/
Removed:
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3714/settings.xml
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3714/src/
Modified:
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/bootstrap/pom.xml
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3714/pom.xml
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-toolchain/pom.xml
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/pom.xml
Added: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3714ToolchainsCliOptionTest.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3714ToolchainsCliOptionTest.java?rev=745944&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3714ToolchainsCliOptionTest.java (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3714ToolchainsCliOptionTest.java Thu Feb 19 17:48:20 2009
@@ -0,0 +1,79 @@
+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.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3714">MNG-3714</a>.
+ *
+ * @author Brett Porter
+ * @version $Id: MavenITmng0557UserSettingsCliOptionTest.java 744504 2009-02-14 14:49:27Z brett $
+ */
+public class MavenITmng3714ToolchainsCliOptionTest
+ extends AbstractMavenIntegrationTestCase
+{
+ public MavenITmng3714ToolchainsCliOptionTest()
+ {
+ super( "[2.1.0,)" );
+ }
+
+ /**
+ * Test --toolchains CLI option
+ */
+ public void testitMNG3714()
+ throws Exception
+ {
+ File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3714" );
+ File javaHome = new File( testDir, "javaHome" );
+ javaHome.mkdirs();
+
+ Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+ Properties properties = verifier.newDefaultFilterProperties();
+ properties.setProperty( "@javaHome@", javaHome.getAbsolutePath() );
+
+ verifier.filterFile( "toolchains.xml", "toolchains.xml", "UTF-8", properties );
+
+ verifier.setAutoclean( false );
+ verifier.deleteDirectory( "target" );
+ List cliOptions = new ArrayList();
+ cliOptions.add( "--toolchains toolchains.xml" );
+ verifier.setCliOptions( cliOptions );
+ verifier.executeGoal( "org.apache.maven.its.plugins:maven-it-plugin-toolchain:toolchain" );
+ verifier.verifyErrorFreeLog();
+ verifier.resetStreams();
+
+ verifier.assertFilePresent( "target/toolchains.properties" );
+ Properties results = verifier.loadProperties( "target/toolchains.properties" );
+ String tool = results.getProperty( "tool.1" );
+ if ( tool.endsWith( ".exe" ) )
+ {
+ tool = tool.substring( 0, tool.length() - 4 );
+ }
+ assertEquals( new File( javaHome, "bin/javac" ).getAbsolutePath(), tool );
+ }
+
+}
Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3714ToolchainsCliOptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/bootstrap/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/bootstrap/pom.xml?rev=745944&r1=745943&r2=745944&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/bootstrap/pom.xml (original)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/bootstrap/pom.xml Thu Feb 19 17:48:20 2009
@@ -232,6 +232,12 @@
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
+ <artifactId>maven-it-plugin-toolchain</artifactId>
+ <version>${itPluginVersion}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-uses-properties</artifactId>
<version>${itPluginVersion}</version>
<scope>runtime</scope>
Modified: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3714/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3714/pom.xml?rev=745944&r1=745915&r2=745944&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3714/pom.xml (original)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3714/pom.xml Thu Feb 19 17:48:20 2009
@@ -1,19 +1,16 @@
<project>
<modelVersion>4.0.0</modelVersion>
- <name>Maven Integration Test :: it0044</name>
- <groupId>org.apache.maven.its.it0044</groupId>
- <artifactId>maven-it-it0044</artifactId>
- <description>Test --settings CLI option</description>
+ <name>Maven Integration Test :: MNG-3714</name>
+ <groupId>org.apache.maven.its.mng3714</groupId>
+ <artifactId>maven-it-mng3714</artifactId>
+ <description>Test --toolchains CLI option</description>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
- <artifactId>maven-it-plugin-touch</artifactId>
+ <artifactId>maven-it-plugin-toolchain</artifactId>
<version>2.1-SNAPSHOT</version>
- <configuration>
- <pluginItem>${test}</pluginItem>
- </configuration>
</plugin>
</plugins>
</build>
Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3714/toolchains.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3714/toolchains.xml?rev=745944&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3714/toolchains.xml (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3714/toolchains.xml Thu Feb 19 17:48:20 2009
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF8"?>
+
+<toolchains>
+ <toolchain>
+ <type>jdk</type>
+ <provides>
+ <version>1.5</version>
+ <vendor>sun</vendor>
+ <id>default</id>
+ </provides>
+ <configuration>
+ <jdkHome>@javaHome@</jdkHome>
+ </configuration>
+ </toolchain>
+</toolchains>
+
Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3714/toolchains.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-toolchain/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Feb 19 17:48:20 2009
@@ -0,0 +1,7 @@
+target
+*.iml
+.classpath
+.project
+.settings
+target-eclipse
+bin
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-toolchain/
------------------------------------------------------------------------------
svn:mergeinfo =
Modified: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-toolchain/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-toolchain/pom.xml?rev=745944&r1=745905&r2=745944&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-toolchain/pom.xml (original)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-toolchain/pom.xml Thu Feb 19 17:48:20 2009
@@ -28,11 +28,10 @@
<version>2.1-SNAPSHOT</version>
</parent>
- <artifactId>maven-it-plugin-touch</artifactId>
+ <artifactId>maven-it-plugin-toolchain</artifactId>
<packaging>maven-plugin</packaging>
- <name>Maven Integration Test Plugin :: Touch</name>
- <inceptionYear>2001</inceptionYear>
+ <name>Maven Integration Test Plugin :: Toolchain</name>
<dependencies>
<dependency>
@@ -42,18 +41,8 @@
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- <version>2.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-artifact</artifactId>
- <version>2.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-archiver</artifactId>
- <version>2.0</version>
+ <artifactId>maven-toolchain</artifactId>
+ <version>2.0.10</version>
</dependency>
</dependencies>
</project>
Modified: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java?rev=745944&r1=745905&r2=745944&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java (original)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java Thu Feb 19 17:48:20 2009
@@ -19,138 +19,93 @@
* under the License.
*/
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
-
import java.io.File;
-import java.io.FileWriter;
+import java.io.FileOutputStream;
import java.io.IOException;
-import java.util.Map;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.toolchain.MisconfiguredToolchainException;
+import org.apache.maven.toolchain.ToolchainManagerPrivate;
+import org.apache.maven.toolchain.ToolchainPrivate;
+import org.codehaus.plexus.util.IOUtil;
/**
- * @goal touch
- *
- * @phase process-sources
- *
- * @description Goal which cleans the build
+ * @goal toolchain
+ * @phase validate
*/
public class CoreItMojo
extends AbstractMojo
{
/**
- * @parameter expression="${project}"
- */
- private MavenProject project;
-
- /**
- * @parameter expression="${project.build.directory}"
- * @required
- */
- private String outputDirectory;
-
- /** Test setting of plugin-artifacts on the PluginDescriptor instance.
- * @parameter expression="${plugin.artifactMap}"
- * @required
- */
- private Map pluginArtifacts;
-
- /**
- * @parameter expression="target/test-basedir-alignment"
- */
- private File basedirAlignmentDirectory;
-
- /**
- * @parameter alias="pluginFile"
+ * @component
*/
- private String pluginItem = "foo";
+ private ToolchainManagerPrivate toolchainManager;
/**
- * @parameter
+ * The path to the output file for the properties.
+ *
+ * @parameter expression="${toolchain.outputFile}" default-value="${project.build.directory}/toolchains.properties"
*/
- private String goalItem = "bar";
+ private File outputFile;
/**
- * @parameter expression="${artifactToFile}"
+ * @parameter default-value="jdk"
*/
- private String artifactToFile;
+ private String type;
/**
- * @parameter expression="${fail}"
+ * @parameter default-value="javac"
*/
- private boolean fail = false;
+ private String tool;
public void execute()
throws MojoExecutionException
{
- if ( fail )
+ ToolchainPrivate[] tcs;
+ try
{
- throw new MojoExecutionException( "Failing per \'fail\' parameter (specified in pom or system properties)" );
+ tcs = toolchainManager.getToolchainsForType( type );
}
-
- touch( new File( outputDirectory ), "touch.txt" );
-
- // This parameter should be aligned to the basedir as the parameter type is specified
- // as java.io.File
-
- if ( !basedirAlignmentDirectory.isAbsolute() )
+ catch ( MisconfiguredToolchainException e )
{
- throw new MojoExecutionException( "basedirAlignmentDirectory not aligned" );
+ throw new MojoExecutionException( e.getMessage(), e );
}
- touch( basedirAlignmentDirectory, "touch.txt" );
-
- File outDir = new File( outputDirectory );
-
- // Test parameter setting
- if ( pluginItem != null )
- {
- touch( outDir, pluginItem );
- }
+ getLog().info( "Toolchain in compiler-plugin: " + Arrays.asList( tcs ) );
- if ( goalItem != null )
- {
- touch( outDir, goalItem );
- }
+ Properties properties = new Properties();
- if ( artifactToFile != null )
+ int count = 1;
+ for ( Iterator i = Arrays.asList( tcs ).iterator(); i.hasNext(); count++ )
{
- Artifact artifact = (Artifact) pluginArtifacts.get( artifactToFile );
-
- File artifactFile = artifact.getFile();
+ ToolchainPrivate toolchain = (ToolchainPrivate) i.next();
- String filename = artifactFile.getAbsolutePath().replace('/', '_').replace(':', '_') + ".txt";
-
- touch( outDir, filename );
+ String foundTool = toolchain.findTool( tool );
+ if ( foundTool != null )
+ {
+ properties.setProperty( "tool." + count, foundTool );
+ }
}
- project.getBuild().setFinalName( "coreitified" );
- }
-
- private void touch( File dir, String file )
- throws MojoExecutionException
- {
+ OutputStream out = null;
try
{
- if ( !dir.exists() )
- {
- dir.mkdirs();
- }
-
- File touch = new File( dir, file );
-
- getLog().info( "Touching file: " + touch.getAbsolutePath() );
-
- FileWriter w = new FileWriter( touch );
-
- w.write( file );
-
- w.close();
+ outputFile.getParentFile().mkdirs();
+ out = new FileOutputStream( outputFile );
+ properties.store( out, "MAVEN-CORE-IT-LOG" );
}
catch ( IOException e )
{
- throw new MojoExecutionException( "Error touching file", e );
+ throw new MojoExecutionException( e.getMessage(), e );
+ }
+ finally
+ {
+ IOUtil.close( out );
}
}
}
Modified: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/pom.xml?rev=745944&r1=745943&r2=745944&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/pom.xml (original)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/pom.xml Thu Feb 19 17:48:20 2009
@@ -51,6 +51,7 @@
<module>maven-it-plugin-project-interpolation</module>
<module>maven-it-plugin-setter</module>
<module>maven-it-plugin-site</module>
+ <module>maven-it-plugin-toolchain</module>
<module>maven-it-plugin-touch</module>
<module>maven-it-plugin-uses-properties</module>
<module>maven-it-plugin-uses-wagon</module>