Permalink
Browse files

377359 better suport custom tycho-p2-plugin:p2-metadata mojo executions

Only execute p2-metadata goal for known supported project
packaging types (eclipse-plugin, eclipse-test-plugin and
eclipse-feature) and silently ignore all other projects.
This allows binding of tycho-p2-plugin:p2-metadata goal in
parent project.

Introduced new <defaultP2Metadata> configuration parameter that
can be used to disable p2 metadata generation goal bound to
project default lifecycle. This is a workaround for a Maven core
limitation that does not allow explicit ordering of goals bound
to project default lifecycle and goals specified via explicit
pom.xml configuration.

Change-Id: Ic7faf742d5b44572cdbf3c5b6f64f3d931292b86
Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
  • Loading branch information...
1 parent d9d43d8 commit f27f2b25a8ec01971d8c5ac0a3822228280d78e1 @ifedorenko ifedorenko committed Apr 22, 2012
View
6 tycho-maven-plugin/src/main/resources/META-INF/plexus/components.xml
@@ -32,7 +32,7 @@
</test>
<package>
org.eclipse.tycho:tycho-packaging-plugin:${project.version}:package-plugin,
- org.eclipse.tycho:tycho-p2-plugin:${project.version}:p2-metadata
+ org.eclipse.tycho:tycho-p2-plugin:${project.version}:p2-metadata-default
</package>
<integration-test></integration-test>
<install>
@@ -94,7 +94,7 @@
<test></test>
<package>
org.eclipse.tycho:tycho-packaging-plugin:${project.version}:package-plugin,
- org.eclipse.tycho:tycho-p2-plugin:${project.version}:p2-metadata
+ org.eclipse.tycho:tycho-p2-plugin:${project.version}:p2-metadata-default
</package>
<integration-test>
org.eclipse.tycho:tycho-surefire-plugin:${project.version}:test
@@ -148,7 +148,7 @@
</generate-resources>
<package>
org.eclipse.tycho:tycho-packaging-plugin:${project.version}:package-feature,
- org.eclipse.tycho:tycho-p2-plugin:${project.version}:p2-metadata,
+ org.eclipse.tycho:tycho-p2-plugin:${project.version}:p2-metadata-default,
org.eclipse.tycho:tycho-p2-plugin:${project.version}:feature-p2-metadata
</package>
<install>
View
37 ...-p2/tycho-p2-plugin/src/main/java/org/eclipse/tycho/plugins/p2/P2MetadataDefaultMojo.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Sonatype Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sonatype Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tycho.plugins.p2;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * P2 metadata generation goal bound to default artifact build lifecycle. For explicit binding use
+ * p2-metadata goal. The idea is to avoid double p2 metadata generation for projects that generate
+ * additional artifacts or post process standard artifacts using custom goals bound to package
+ * phase.
+ *
+ * @goal p2-metadata-default
+ */
+public class P2MetadataDefaultMojo extends P2MetadataMojo {
+
+ /**
+ * @parameter default-value="true"
+ */
+ private boolean defaultP2Metadata;
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ if (defaultP2Metadata) {
+ super.execute();
+ }
+ }
+}
View
11 tycho-p2/tycho-p2-plugin/src/main/java/org/eclipse/tycho/plugins/p2/P2MetadataMojo.java
@@ -24,6 +24,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -62,6 +63,14 @@
/** @component */
private EquinoxServiceFactory equinox;
+ /**
+ * Project types which this plugin supports.
+ *
+ * @parameter
+ */
+ private List<String> supportedProjectTypes = Arrays.asList("eclipse-plugin", "eclipse-test-plugin",
+ "eclipse-feature");
+
private P2Generator p2;
public void execute() throws MojoExecutionException, MojoFailureException {
@@ -80,7 +89,7 @@ protected P2Generator getP2Generator() {
}
protected void attachP2Metadata() throws MojoExecutionException {
- if (!attachP2Metadata) {
+ if (!attachP2Metadata || !supportedProjectTypes.contains(project.getPackaging())) {
return;
}

0 comments on commit f27f2b2

Please sign in to comment.