From 5c898cf7efcb2ec966e52fe91fa6c22d81172662 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Wed, 31 Mar 2010 14:49:49 +0000 Subject: [PATCH] [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 --- .../apache/maven/it/IntegrationTestSuite.java | 1 + ...nITmng3766ToolchainsFromExtensionTest.java | 66 ++++++++++++++++ .../src/test/resources/mng-3766/pom.xml | 76 +++++++++++++++++++ .../test/resources/mng-3766/toolchains.xml | 26 +++++++ .../maven/plugin/coreit/CoreItMojo.java | 11 ++- its/core-it-support/core-it-toolchain/pom.xml | 42 ++++++++++ .../coreit/toolchain/CoreItToolchain.java | 62 +++++++++++++++ .../toolchain/CoreItToolchainFactory.java | 49 ++++++++++++ .../resources/META-INF/plexus/components.xml | 29 +++++++ its/core-it-support/pom.xml | 1 + 10 files changed, 361 insertions(+), 2 deletions(-) create mode 100644 its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3766ToolchainsFromExtensionTest.java create mode 100644 its/core-it-suite/src/test/resources/mng-3766/pom.xml create mode 100644 its/core-it-suite/src/test/resources/mng-3766/toolchains.xml create mode 100644 its/core-it-support/core-it-toolchain/pom.xml create mode 100644 its/core-it-support/core-it-toolchain/src/main/java/org/apache/maven/coreit/toolchain/CoreItToolchain.java create mode 100644 its/core-it-support/core-it-toolchain/src/main/java/org/apache/maven/coreit/toolchain/CoreItToolchainFactory.java create mode 100644 its/core-it-support/core-it-toolchain/src/main/resources/META-INF/plexus/components.xml diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java index 4960c67322..90261b9ea7 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java @@ -297,6 +297,7 @@ public static Test suite() 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 ); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3766ToolchainsFromExtensionTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3766ToolchainsFromExtensionTest.java new file mode 100644 index 0000000000..c08ea8a15f --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3766ToolchainsFromExtensionTest.java @@ -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 MNG-3766. + * + * @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", "" ) ); + } + +} diff --git a/its/core-it-suite/src/test/resources/mng-3766/pom.xml b/its/core-it-suite/src/test/resources/mng-3766/pom.xml new file mode 100644 index 0000000000..e9219ba4c8 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-3766/pom.xml @@ -0,0 +1,76 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng3766 + test + 1.0-SNAPSHOT + + Maven Integration Test :: MNG-3766 + + Test toolchain discovery from build extensions. + + + + + + org.apache.maven.its + core-it-toolchain + 2.1-SNAPSHOT + + + + + org.apache.maven.its.plugins + maven-it-plugin-toolchain + 2.1-SNAPSHOT + + + select-toolchain + validate + + toolchain + + + target/toolchains.properties + coreit + 0 + + + + find-tool + initialize + + find-tool + + + target/tool.properties + coreit + toolname + + + + + + + diff --git a/its/core-it-suite/src/test/resources/mng-3766/toolchains.xml b/its/core-it-suite/src/test/resources/mng-3766/toolchains.xml new file mode 100644 index 0000000000..303e8f1a39 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-3766/toolchains.xml @@ -0,0 +1,26 @@ + + + + + + + coreit + + diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java index 23b98542ae..9c1a9bd8aa 100644 --- a/its/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java @@ -95,8 +95,15 @@ public void execute() if ( selected >= 0 ) { - ToolchainPrivate toolchain = tcs[selected]; - toolchainManager.storeToolchainToBuildContext( toolchain, session ); + 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(); diff --git a/its/core-it-support/core-it-toolchain/pom.xml b/its/core-it-support/core-it-toolchain/pom.xml new file mode 100644 index 0000000000..f89cff9069 --- /dev/null +++ b/its/core-it-support/core-it-toolchain/pom.xml @@ -0,0 +1,42 @@ + + + + + + 4.0.0 + + + core-integration-testing + org.apache.maven.its + 2.1-SNAPSHOT + + + core-it-toolchain + + Maven Integration Test Toolchain + + + + org.apache.maven + maven-toolchain + 2.0.10 + + + diff --git a/its/core-it-support/core-it-toolchain/src/main/java/org/apache/maven/coreit/toolchain/CoreItToolchain.java b/its/core-it-support/core-it-toolchain/src/main/java/org/apache/maven/coreit/toolchain/CoreItToolchain.java new file mode 100644 index 0000000000..9bc51e81a6 --- /dev/null +++ b/its/core-it-support/core-it-toolchain/src/main/java/org/apache/maven/coreit/toolchain/CoreItToolchain.java @@ -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; + } + +} diff --git a/its/core-it-support/core-it-toolchain/src/main/java/org/apache/maven/coreit/toolchain/CoreItToolchainFactory.java b/its/core-it-support/core-it-toolchain/src/main/java/org/apache/maven/coreit/toolchain/CoreItToolchainFactory.java new file mode 100644 index 0000000000..62bd828b45 --- /dev/null +++ b/its/core-it-support/core-it-toolchain/src/main/java/org/apache/maven/coreit/toolchain/CoreItToolchainFactory.java @@ -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 ); + } + +} diff --git a/its/core-it-support/core-it-toolchain/src/main/resources/META-INF/plexus/components.xml b/its/core-it-support/core-it-toolchain/src/main/resources/META-INF/plexus/components.xml new file mode 100644 index 0000000000..3a31c50c1c --- /dev/null +++ b/its/core-it-support/core-it-toolchain/src/main/resources/META-INF/plexus/components.xml @@ -0,0 +1,29 @@ + + + + + + org.apache.maven.toolchain.ToolchainFactory + coreit + org.apache.maven.coreit.toolchain.CoreItToolchainFactory + singleton + + + diff --git a/its/core-it-support/pom.xml b/its/core-it-support/pom.xml index 22df415ea1..37dfe3c28f 100644 --- a/its/core-it-support/pom.xml +++ b/its/core-it-support/pom.xml @@ -37,6 +37,7 @@ under the License. core-it-plugins core-it-component + core-it-toolchain core-it-wagon core-it-support-artifacts maven-it-helper