diff --git a/its/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java b/its/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java index df69ec2236..ac59441cca 100644 --- a/its/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java +++ b/its/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java @@ -65,6 +65,7 @@ public class IntegrationTestSuite * a fail fast technique as well. */ + suite.addTestSuite( MNG3498Test.class ); suite.addTestSuite( MavenITmng3485OverrideWagonExtensionTest.class ); suite.addTestSuite( MavenITmng3473PluginReportCrash.class ); suite.addTestSuite( MavenITmng3428PluginDescriptorArtifactsIncompleteTest.class ); diff --git a/its/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MNG3498Test.java b/its/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MNG3498Test.java new file mode 100644 index 0000000000..74efe1f87d --- /dev/null +++ b/its/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MNG3498Test.java @@ -0,0 +1,70 @@ +/* + * 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. + */ + +package org.apache.maven.integrationtests; + +import org.apache.maven.it.Verifier; +import org.apache.maven.it.util.ResourceExtractor; + +import java.io.File; + +/** + * This is a test set for MNG-3498. + * + * @todo Fill in a better description of what this test verifies! + * + * @author Brian Fox + * @author jdcasey + * + */ +public class MNG3498Test + extends AbstractMavenIntegrationTestCase +{ +// public MNG3498Test() +// throws InvalidVersionSpecificationException +// { +// super( "(2.0.8,)" ); // only test in 2.0.9+ +// } + + public void testitMNG3498 () + throws Exception + { + // The testdir is computed from the location of this + // file. + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3498" ); + + File pluginDir = new File( testDir, "maven-mng3498-plugin" ); + File projectDir = new File( testDir, "mng-3498-project" ); + + Verifier verifier = new Verifier( pluginDir.getAbsolutePath() ); + verifier.deleteArtifact( "org.apache.maven.its.mng3498", "maven-mng3498-plugin", "1", "pom" ); + + verifier.executeGoal( "install" ); + + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + verifier = new Verifier( projectDir.getAbsolutePath() ); + + verifier.executeGoal( "validate" ); + + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + } +} diff --git a/its/core-integration-tests/src/test/resources/mng-3498/maven-mng3498-plugin/pom.xml b/its/core-integration-tests/src/test/resources/mng-3498/maven-mng3498-plugin/pom.xml new file mode 100644 index 0000000000..a55c31b464 --- /dev/null +++ b/its/core-integration-tests/src/test/resources/mng-3498/maven-mng3498-plugin/pom.xml @@ -0,0 +1,43 @@ + + + + + 4.0.0 + org.apache.maven.its.mng3498 + maven-mng3498-plugin + maven-plugin + 1 + maven-mng3498-plugin Maven Mojo + http://maven.apache.org + + + org.apache.maven + maven-plugin-api + 2.0 + + + junit + junit + 3.8.1 + test + + + diff --git a/its/core-integration-tests/src/test/resources/mng-3498/maven-mng3498-plugin/src/main/java/plugin/CheckMojo.java b/its/core-integration-tests/src/test/resources/mng-3498/maven-mng3498-plugin/src/main/java/plugin/CheckMojo.java new file mode 100644 index 0000000000..94bdf24c70 --- /dev/null +++ b/its/core-integration-tests/src/test/resources/mng-3498/maven-mng3498-plugin/src/main/java/plugin/CheckMojo.java @@ -0,0 +1,62 @@ +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed 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. + */ + +package plugin; + +import org.apache.maven.plugin.Mojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.logging.Log; + +import java.io.File; + +/** + * @goal check + * @phase validate + * @execute goal="touch" + */ +public class CheckMojo + implements Mojo +{ + + /** + * @parameter default-value="${project.build.directory}/touch.txt" + * @required + */ + private File touchFile; + + private Log log; + + public void execute() + throws MojoExecutionException, MojoFailureException + { + if ( !touchFile.exists() ) + { + throw new MojoExecutionException( "Touch file: " + touchFile + " has not been generated by forked mojo 'touch'." ); + } + } + + public Log getLog() + { + return log; + } + + public void setLog( Log log ) + { + this.log = log; + } + +} diff --git a/its/core-integration-tests/src/test/resources/mng-3498/maven-mng3498-plugin/src/main/java/plugin/TouchMojo.java b/its/core-integration-tests/src/test/resources/mng-3498/maven-mng3498-plugin/src/main/java/plugin/TouchMojo.java new file mode 100644 index 0000000000..8748b3d067 --- /dev/null +++ b/its/core-integration-tests/src/test/resources/mng-3498/maven-mng3498-plugin/src/main/java/plugin/TouchMojo.java @@ -0,0 +1,79 @@ +package plugin; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed 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.io.File; +import java.io.FileWriter; +import java.io.IOException; + +/** + * Goal which touches a timestamp file. + * + * @goal touch + */ +public class TouchMojo + extends AbstractMojo +{ + /** + * Location of the file. + * @parameter expression="${project.build.directory}" + * @required + */ + private File outputDirectory; + + public void execute() + throws MojoExecutionException + { + File f = outputDirectory; + + if ( !f.exists() ) + { + f.mkdirs(); + } + + File touch = new File( f, "touch.txt" ); + + FileWriter w = null; + try + { + w = new FileWriter( touch ); + + w.write( "touch.txt" ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Error creating file " + touch, e ); + } + finally + { + if ( w != null ) + { + try + { + w.close(); + } + catch ( IOException e ) + { + // ignore + } + } + } + } +} diff --git a/its/core-integration-tests/src/test/resources/mng-3498/mng-3498-project/pom.xml b/its/core-integration-tests/src/test/resources/mng-3498/mng-3498-project/pom.xml new file mode 100644 index 0000000000..a3ecb01f25 --- /dev/null +++ b/its/core-integration-tests/src/test/resources/mng-3498/mng-3498-project/pom.xml @@ -0,0 +1,47 @@ + + + + + 4.0.0 + org.apache.maven.its.mng3498 + mng-3498-project + jar + 1 + + + + + ${project.groupId} + maven-mng3498-plugin + 1 + + + check + validate + + check + + + + + + + diff --git a/its/core-integration-tests/src/test/resources/mng-3498/readme.txt b/its/core-integration-tests/src/test/resources/mng-3498/readme.txt new file mode 100644 index 0000000000..37979d0c1f --- /dev/null +++ b/its/core-integration-tests/src/test/resources/mng-3498/readme.txt @@ -0,0 +1,13 @@ +Tests mojos that fork to another mojo inside the same plugin. + +To run, execute the following steps: + +1. Build the plugin: + + cd plugin + mvn clean install + +2. Build the test project: + + cd project + mvn validte