Author: ifedorenko
Date: Thu Apr 17 15:06:59 2014
New Revision: 1588273
URL: http://svn.apache.org/r1588273
Log:
MPLUGIN-264 made supported packaging types configurable
Added:
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/invoker.properties
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/pom.xml
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/src/
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/src/main/
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/src/main/java/
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/src/main/java/org/
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/src/main/java/org/apache/
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/src/main/java/org/apache/maven/
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/src/main/java/org/apache/maven/plugin/
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/src/main/java/org/apache/maven/plugin/coreit/
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/verify.groovy
Modified:
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
Added:
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/invoker.properties
URL:
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/invoker.properties?rev=1588273&view=auto
==============================================================================
---
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/invoker.properties
(added)
+++
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/invoker.properties
Thu Apr 17 15:06:59 2014
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.goals.1 = clean install
Added: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/pom.xml
URL:
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/pom.xml?rev=1588273&view=auto
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/pom.xml
(added)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/pom.xml
Thu Apr 17 15:06:59 2014
@@ -0,0 +1,102 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.packaging-jar</groupId>
+ <artifactId>packaging-jar</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>Maven Integration Test :: packaging-jar</name>
+ <description>
+ Test plugin-plugin can be enabled for projects with alternative packaging
types,
+ "jar" in this particular case.
+ </description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>2.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>3.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>@project.version@</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+ <packagingTypes>
+ <packaging>jar</packaging>
+ </packagingTypes>
+ </configuration>
+ <executions>
+ <execution>
+ <id>mojo-descriptor</id>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>help-goal</id>
+ <goals>
+ <goal>helpmojo</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added:
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java?rev=1588273&view=auto
==============================================================================
---
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
(added)
+++
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
Thu Apr 17 15:06:59 2014
@@ -0,0 +1,35 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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;
+import org.apache.maven.plugins.annotations.Mojo;
+
+/**
+ * @deprecated Don't use!
+ */
+@Mojo( name = "first" )
+public class FirstMojo
+ extends AbstractMojo
+{
+
+ public void execute()
+ throws MojoExecutionException
+ {
+ }
+
+}
Added:
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/verify.groovy
URL:
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/verify.groovy?rev=1588273&view=auto
==============================================================================
---
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/verify.groovy
(added)
+++
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/packaging-jar/verify.groovy
Thu Apr 17 15:06:59 2014
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+File descriptorFile = new File( basedir,
"target/classes/META-INF/maven/plugin.xml" );
+assert descriptorFile.isFile()
+
+def pluginDescriptor = new XmlParser().parse( descriptorFile );
+
+def mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "first" }[0]
+
+assert mojo.goal.text() == 'first'
+assert mojo.implementation.text() == 'org.apache.maven.plugin.coreit.FirstMojo'
+assert mojo.language.text() == 'java'
+
+return true;
Modified:
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java?rev=1588273&r1=1588272&r2=1588273&view=diff
==============================================================================
---
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
(original)
+++
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
Thu Apr 17 15:06:59 2014
@@ -38,6 +38,7 @@ import org.apache.maven.tools.plugin.sca
import org.codehaus.plexus.util.ReaderFactory;
import java.io.File;
+import java.util.Arrays;
import java.util.List;
import java.util.Set;
@@ -145,6 +146,14 @@ public abstract class AbstractGeneratorM
protected ArtifactRepository local;
/**
+ * Maven plugin packaging types. Default is single "maven-plugin".
+ *
+ * @since 3.3
+ */
+ @Parameter
+ protected List<String> packagingTypes = Arrays.asList( "maven-plugin" );
+
+ /**
* @return the output directory where files will be generated.
*/
protected abstract File getOutputDirectory();
@@ -160,8 +169,9 @@ public abstract class AbstractGeneratorM
public void execute()
throws MojoExecutionException
{
- if ( !"maven-plugin".equals( project.getPackaging() ) )
+ if ( !packagingTypes.contains( project.getPackaging() ) )
{
+ getLog().warn( "Unsupported packaging type " +
project.getPackaging() + ", execution skipped" );
return;
}
if ( skip )