From c00f0b141850d1076515dffa117012c894cf9da5 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Mon, 31 Aug 2009 13:03:37 +0000 Subject: [PATCH] [MNG-4332] [regression] Default plugin executions contributed by packaging execute after executions from plugin management o Added IT git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@809571 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/maven/it/IntegrationTestSuite.java | 1 + ...ng4332DefaultPluginExecutionOrderTest.java | 64 +++++++++++++++ .../src/test/resources/mng-4332/pom.xml | 78 +++++++++++++++++++ .../maven/plugin/coreit/ResourcesMojo.java | 33 +++++++- 4 files changed, 174 insertions(+), 2 deletions(-) create mode 100644 its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4332DefaultPluginExecutionOrderTest.java create mode 100644 its/core-it-suite/src/test/resources/mng-4332/pom.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 53c03bcc1e..c213332bbf 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 @@ -86,6 +86,7 @@ public class IntegrationTestSuite // suite.addTestSuite( MavenIT0109ReleaseUpdateTest.class ); // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137 + suite.addTestSuite( MavenITmng4332DefaultPluginExecutionOrderTest.class ); suite.addTestSuite( MavenITmng4331DependencyCollectionTest.class ); suite.addTestSuite( MavenITmng4328PrimitiveMojoParameterConfigurationTest.class ); suite.addTestSuite( MavenITmng4327ExcludeForkingMojoFromForkedLifecycleTest.class ); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4332DefaultPluginExecutionOrderTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4332DefaultPluginExecutionOrderTest.java new file mode 100644 index 0000000000..3e8c3555a9 --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4332DefaultPluginExecutionOrderTest.java @@ -0,0 +1,64 @@ +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.Arrays; +import java.util.List; + +/** + * This is a test set for MNG-4332. + * + * @author Benjamin Bentmann + */ +public class MavenITmng4332DefaultPluginExecutionOrderTest + extends AbstractMavenIntegrationTestCase +{ + + public MavenITmng4332DefaultPluginExecutionOrderTest() + { + super( ALL_MAVEN_VERSIONS ); + } + + /** + * Verify that default plugin executions contributed by the packaging are executed before user-defined + * executions from the POM's build section, regardless whether the executions are defined in the regular + * plugins section or the plugin management section. + */ + public void testit() + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4332" ); + + Verifier verifier = new Verifier( testDir.getAbsolutePath() ); + verifier.setAutoclean( false ); + verifier.deleteDirectory( "target" ); + verifier.executeGoal( "process-resources" ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + List lines = verifier.loadLines( "target/resources-resources.txt", "UTF-8" ); + assertEquals( Arrays.asList( new String[] { "default", "test-1", "test-2" } ), lines ); + } + +} diff --git a/its/core-it-suite/src/test/resources/mng-4332/pom.xml b/its/core-it-suite/src/test/resources/mng-4332/pom.xml new file mode 100644 index 0000000000..9ecc3526a1 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4332/pom.xml @@ -0,0 +1,78 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng4332 + test + 0.1 + jar + + Maven Integration Test :: MNG-4332 + + Verify that default plugin executions contributed by the packaging are executed before user-defined + executions from the POM's build section, regardless whether the executions are defined in the regular + plugins section or the plugin management section. + + + + + + + maven-resources-plugin + 0.1-stub-SNAPSHOT + + + test-1 + + resources + + + test-1 + + + + + + + + + maven-resources-plugin + + default + + + + test-2 + + resources + + + test-2 + + + + + + + + diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-resources-plugin/src/main/java/org/apache/maven/plugin/coreit/ResourcesMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-resources-plugin/src/main/java/org/apache/maven/plugin/coreit/ResourcesMojo.java index fa049bc283..29c8b721a9 100644 --- a/its/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-resources-plugin/src/main/java/org/apache/maven/plugin/coreit/ResourcesMojo.java +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-resources-plugin/src/main/java/org/apache/maven/plugin/coreit/ResourcesMojo.java @@ -25,7 +25,9 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.project.MavenProject; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStreamWriter; /** * Creates a text file in the project base directory. @@ -56,6 +58,14 @@ public class ResourcesMojo */ private String pathname = "target/resources-resources.txt"; + /** + * An optional message line to write to the output file (using UTF-8 encoding). If given, the output file will be + * opened in append mode. + * + * @parameter + */ + private String message; + /** * Runs this mojo. * @@ -82,8 +92,27 @@ public class ResourcesMojo try { - outputFile.getParentFile().mkdirs(); - outputFile.createNewFile(); + outputFile.getParentFile().mkdirs(); + + if ( message != null && message.length() > 0 ) + { + getLog().info( "[MAVEN-CORE-IT-LOG] " + message ); + + OutputStreamWriter writer = new OutputStreamWriter( new FileOutputStream( outputFile, true ), "UTF-8" ); + try + { + writer.write( message ); + writer.write( "\n" ); + } + finally + { + writer.close(); + } + } + else + { + outputFile.createNewFile(); + } } catch ( IOException e ) {