From 082688dccb8e1efebe0346c98b539dd98f595523 Mon Sep 17 00:00:00 2001 From: Anton Tanasenko Date: Mon, 20 Apr 2015 00:50:37 +0300 Subject: [PATCH] MNG-5805: Custom packaging types: configuring DefaultLifecycleMapping mojo executions --- .../apache/maven/it/IntegrationTestSuite.java | 1 + ...avenITmng5805PkgTypeMojoConfiguration.java | 43 +++++++++++++++ .../extension/pom.xml | 30 ++++++++++ .../resources/META-INF/plexus/components.xml | 53 ++++++++++++++++++ .../plugin-dep/pom.xml | 30 ++++++++++ .../apache/maven/its/mng5805/TestClass1.java | 5 ++ .../plugin/pom.xml | 55 +++++++++++++++++++ .../maven/its/mng5805/plugin/TestMojo.java | 51 +++++++++++++++++ .../project/pom.xml | 40 ++++++++++++++ 9 files changed, 308 insertions(+) create mode 100644 core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5805PkgTypeMojoConfiguration.java create mode 100644 core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/extension/pom.xml create mode 100644 core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/extension/src/main/resources/META-INF/plexus/components.xml create mode 100644 core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/plugin-dep/pom.xml create mode 100644 core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/plugin-dep/src/main/java/org/apache/maven/its/mng5805/TestClass1.java create mode 100644 core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/plugin/pom.xml create mode 100644 core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/plugin/src/main/java/org/apache/maven/its/mng5805/plugin/TestMojo.java create mode 100644 core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/project/pom.xml diff --git a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java index 98e575296..662b30b77 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java @@ -106,6 +106,7 @@ public static Test suite() // ------------------------------------------------------------------------------------------------------------- // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137 + suite.addTestSuite( MavenITmng5805PkgTypeMojoConfiguration.class ); suite.addTestSuite( MavenITmng5783PluginDependencyFiltering.class ); suite.addTestSuite( MavenITmng5774ConfigurationProcessorsTest.class ); suite.addTestSuite( MavenITmng5771CoreExtensionsTest.class ); diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5805PkgTypeMojoConfiguration.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5805PkgTypeMojoConfiguration.java new file mode 100644 index 000000000..b0dec8d54 --- /dev/null +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5805PkgTypeMojoConfiguration.java @@ -0,0 +1,43 @@ +package org.apache.maven.it; + +import java.io.File; + +import org.apache.maven.it.util.ResourceExtractor; + +public class MavenITmng5805PkgTypeMojoConfiguration + extends AbstractMavenIntegrationTestCase +{ + + public MavenITmng5805PkgTypeMojoConfiguration() + { + super( "(3.3.2,)" ); + } + + public void testPkgTypeMojoConfiguration() + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5805-pkg-type-mojo-configuration" ); + + Verifier verifier; + + verifier = newVerifier( new File( testDir, "extension" ).getAbsolutePath() ); + verifier.executeGoal( "install" ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + verifier = newVerifier( new File( testDir, "plugin" ).getAbsolutePath() ); + verifier.executeGoal( "install" ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + verifier = newVerifier( new File( testDir, "plugin-dep" ).getAbsolutePath() ); + verifier.executeGoal( "install" ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + verifier = newVerifier( new File( testDir, "project" ).getAbsolutePath() ); + verifier.executeGoal( "validate" ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + } +} diff --git a/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/extension/pom.xml b/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/extension/pom.xml new file mode 100644 index 000000000..d3bda34b5 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/extension/pom.xml @@ -0,0 +1,30 @@ + + + + + + 4.0.0 + + mng-5805-pkg-type-mojo-configuration + mng-5805-pkg-type-mojo-configuration-extension + 0.1 + jar + diff --git a/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/extension/src/main/resources/META-INF/plexus/components.xml b/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/extension/src/main/resources/META-INF/plexus/components.xml new file mode 100644 index 000000000..2bf810d49 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/extension/src/main/resources/META-INF/plexus/components.xml @@ -0,0 +1,53 @@ + + + + + + org.apache.maven.lifecycle.mapping.LifecycleMapping + mng5805 + org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping + + + + default + + + + + + mng-5805-pkg-type-mojo-configuration:mng-5805-pkg-type-mojo-configuration-plugin:0.1:test + + + org.apache.maven.its.mng5805.TestClass1 + + + + org.apache.maven.its.mng5805 + plugin-dep + 0.1 + + + + + + + + + + + + + org.apache.maven.artifact.handler.ArtifactHandler + mng5805 + + org.apache.maven.artifact.handler.DefaultArtifactHandler + + + zip + mng5805 + mng5805 + + + + + diff --git a/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/plugin-dep/pom.xml b/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/plugin-dep/pom.xml new file mode 100644 index 000000000..b64012566 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/plugin-dep/pom.xml @@ -0,0 +1,30 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng5805 + plugin-dep + 0.1 + + diff --git a/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/plugin-dep/src/main/java/org/apache/maven/its/mng5805/TestClass1.java b/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/plugin-dep/src/main/java/org/apache/maven/its/mng5805/TestClass1.java new file mode 100644 index 000000000..e20a23c57 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/plugin-dep/src/main/java/org/apache/maven/its/mng5805/TestClass1.java @@ -0,0 +1,5 @@ +package org.apache.maven.its.mng5805; + +public class TestClass1 { + +} diff --git a/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/plugin/pom.xml b/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/plugin/pom.xml new file mode 100644 index 000000000..6a301316c --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/plugin/pom.xml @@ -0,0 +1,55 @@ + + + + + + 4.0.0 + + mng-5805-pkg-type-mojo-configuration + mng-5805-pkg-type-mojo-configuration-plugin + 0.1 + maven-plugin + + + 3.3.1 + + + + + org.apache.maven + maven-plugin-api + ${maven-version} + provided + + + org.apache.maven + maven-model + ${maven-version} + provided + + + org.apache.maven + maven-core + ${maven-version} + provided + + + diff --git a/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/plugin/src/main/java/org/apache/maven/its/mng5805/plugin/TestMojo.java b/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/plugin/src/main/java/org/apache/maven/its/mng5805/plugin/TestMojo.java new file mode 100644 index 000000000..b4e4e7129 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/plugin/src/main/java/org/apache/maven/its/mng5805/plugin/TestMojo.java @@ -0,0 +1,51 @@ +package org.apache.maven.its.mng5805.plugin; + +/* + * 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.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; + +/** + * @goal test + */ +public class TestMojo + extends AbstractMojo +{ + /** + * @parameter default-value="org.apache.maven.its.mng5805.DoesNotExist" + */ + private String className; + + public void execute() + throws MojoExecutionException + { + + getLog().info( "CLASS_NAME=" + className ); + + try + { + Class.forName( className ); + } + catch (ClassNotFoundException e) + { + throw new MojoExecutionException( e.getMessage(), e ); + } + } +} diff --git a/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/project/pom.xml b/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/project/pom.xml new file mode 100644 index 000000000..bcc913196 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5805-pkg-type-mojo-configuration/project/pom.xml @@ -0,0 +1,40 @@ + + + + + + 4.0.0 + + mng-5805-pkg-type-mojo-configuration + mng-5805-pkg-type-mojo-configuration-project + 0.1 + mng5805 + + + + + mng-5805-pkg-type-mojo-configuration + mng-5805-pkg-type-mojo-configuration-extension + 0.1 + + + +