[MNG-3766] toolchains not found in extensions

o Added IT

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@929559 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2010-03-31 14:49:49 +00:00
parent 1d243fcd23
commit 5c898cf7ef
10 changed files with 361 additions and 2 deletions

View File

@ -297,6 +297,7 @@ public class IntegrationTestSuite
suite.addTestSuite( MavenITmng3805ExtensionClassPathOrderingTest.class );
suite.addTestSuite( MavenITmng3796ClassImportInconsistencyTest.class );
suite.addTestSuite( MavenITmng3769ExclusionRelocatedTransdepsTest.class );
suite.addTestSuite( MavenITmng3766ToolchainsFromExtensionTest.class );
suite.addTestSuite( MavenITmng3760BaseUriPropertyTest.class );
suite.addTestSuite( MavenITmng3748BadSettingsXmlTest.class );
suite.addTestSuite( MavenITmng3747PrefixedPathExpressionTest.class );

View File

@ -0,0 +1,66 @@
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-3766">MNG-3766</a>.
*
* @author Benjamin Bentmann
*/
public class MavenITmng3766ToolchainsFromExtensionTest
extends AbstractMavenIntegrationTestCase
{
public MavenITmng3766ToolchainsFromExtensionTest()
{
super( "[3.0-alpha-3,)" );
}
/**
* Test toolchain discovery from build extensions.
*/
public void testit()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3766" );
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.getCliOptions().add( "--toolchains" );
verifier.getCliOptions().add( "toolchains.xml" );
verifier.executeGoal( "initialize" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
verifier.assertFilePresent( "target/tool.properties" );
Properties toolProps = verifier.loadProperties( "target/tool.properties" );
assertEquals( "toolname", toolProps.getProperty( "tool.toolname", "" ) );
}
}

View File

@ -0,0 +1,76 @@
<?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.mng3766</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Maven Integration Test :: MNG-3766</name>
<description>
Test toolchain discovery from build extensions.
</description>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.its</groupId>
<artifactId>core-it-toolchain</artifactId>
<version>2.1-SNAPSHOT</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-toolchain</artifactId>
<version>2.1-SNAPSHOT</version>
<executions>
<execution>
<id>select-toolchain</id>
<phase>validate</phase>
<goals>
<goal>toolchain</goal>
</goals>
<configuration>
<outputFile>target/toolchains.properties</outputFile>
<type>coreit</type>
<selected>0</selected>
</configuration>
</execution>
<execution>
<id>find-tool</id>
<phase>initialize</phase>
<goals>
<goal>find-tool</goal>
</goals>
<configuration>
<outputFile>target/tool.properties</outputFile>
<type>coreit</type>
<tool>toolname</tool>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF8"?>
<!--
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.
-->
<toolchains>
<toolchain>
<type>coreit</type>
</toolchain>
</toolchains>

View File

@ -94,10 +94,17 @@ public class CoreItMojo
getLog().info( "[MAVEN-CORE-IT-LOG] Toolchains in plugin: " + Arrays.asList( tcs ) );
if ( selected >= 0 )
{
if ( selected < tcs.length )
{
ToolchainPrivate toolchain = tcs[selected];
toolchainManager.storeToolchainToBuildContext( toolchain, session );
}
else
{
getLog().warn( "[MAVEN-CORE-IT-LOG] Toolchain #" + selected + " can't be selected, found only " + tcs.length );
}
}
Properties properties = new Properties();

View File

@ -0,0 +1,42 @@
<?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>
<parent>
<artifactId>core-integration-testing</artifactId>
<groupId>org.apache.maven.its</groupId>
<version>2.1-SNAPSHOT</version>
</parent>
<artifactId>core-it-toolchain</artifactId>
<name>Maven Integration Test Toolchain</name>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-toolchain</artifactId>
<version>2.0.10</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,62 @@
package org.apache.maven.coreit.toolchain;
/*
* 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 java.util.Map;
import org.apache.maven.toolchain.Toolchain;
import org.apache.maven.toolchain.ToolchainPrivate;
import org.apache.maven.toolchain.model.ToolchainModel;
/**
* @author Benjamin Bentmann
*/
public class CoreItToolchain
implements Toolchain, ToolchainPrivate
{
private ToolchainModel model;
public CoreItToolchain( ToolchainModel model )
{
this.model = model;
}
public String getType()
{
return "coreit";
}
public String findTool( String toolName )
{
return toolName;
}
public ToolchainModel getModel()
{
return model;
}
public boolean matchesRequirements( Map requirements )
{
return true;
}
}

View File

@ -0,0 +1,49 @@
package org.apache.maven.coreit.toolchain;
/*
* 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.toolchain.MisconfiguredToolchainException;
import org.apache.maven.toolchain.ToolchainFactory;
import org.apache.maven.toolchain.ToolchainPrivate;
import org.apache.maven.toolchain.model.ToolchainModel;
/**
* @author Benjamin Bentmann
*/
public class CoreItToolchainFactory
implements ToolchainFactory
{
public ToolchainPrivate createDefaultToolchain()
{
return null;
}
public ToolchainPrivate createToolchain( ToolchainModel model )
throws MisconfiguredToolchainException
{
if ( model == null )
{
return null;
}
return new CoreItToolchain( model );
}
}

View File

@ -0,0 +1,29 @@
<!--
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.
-->
<component-set>
<components>
<component>
<role>org.apache.maven.toolchain.ToolchainFactory</role>
<role-hint>coreit</role-hint>
<implementation>org.apache.maven.coreit.toolchain.CoreItToolchainFactory</implementation>
<instantiation-strategy>singleton</instantiation-strategy>
</component>
</components>
</component-set>

View File

@ -37,6 +37,7 @@ under the License.
<modules>
<module>core-it-plugins</module>
<module>core-it-component</module>
<module>core-it-toolchain</module>
<module>core-it-wagon</module>
<module>core-it-support-artifacts</module>
<module>maven-it-helper</module>