Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2011-02-23 13:02:19 -0500
committerIgor Fedorenko2011-02-23 13:11:51 -0500
commit4a3ba6acf496dda6d16b53a69b72de35a6c62a95 (patch)
treee91df5a09ade413957a010d34c2513c4cf3c7d01 /org.eclipse.m2e.discovery
parent02e8c75779abfc23c664f77d8e3e600ced9d5ba9 (diff)
downloadm2e-core-4a3ba6acf496dda6d16b53a69b72de35a6c62a95.tar.gz
m2e-core-4a3ba6acf496dda6d16b53a69b72de35a6c62a95.tar.xz
m2e-core-4a3ba6acf496dda6d16b53a69b72de35a6c62a95.zip
335701 discover required m2e extensions during project import
Introduced ability to see project lifecycle mapping configuration as part of import wizard and to check m2e marketplace for extensions that provide support for non-covered mojo executions and unsupported packaging types. This is a proof-of-concept implemenation. UI is completely throw-away code. Backend requires significact work as well. Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
Diffstat (limited to 'org.eclipse.m2e.discovery')
-rw-r--r--org.eclipse.m2e.discovery/.project5
-rw-r--r--org.eclipse.m2e.discovery/.settings/org.eclipse.jdt.core.prefs15
-rw-r--r--org.eclipse.m2e.discovery/.settings/org.eclipse.jdt.ui.prefs5
-rw-r--r--org.eclipse.m2e.discovery/META-INF/MANIFEST.MF4
-rw-r--r--org.eclipse.m2e.discovery/OSGI-INF/component.xml7
-rw-r--r--org.eclipse.m2e.discovery/build.properties3
-rw-r--r--org.eclipse.m2e.discovery/plugin.xml10
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/InstallCatalogItemMappingLabelProvider.java51
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/InstallCatalogItemMavenDiscoveryProposal.java60
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscovery.java68
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscoveryService.java239
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/DiscoveryWizardProposal.java15
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/operation/MavenDiscoveryInstallOperation.java27
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogConfiguration.java10
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogViewer.java26
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenDiscoveryUi.java2
16 files changed, 483 insertions, 64 deletions
diff --git a/org.eclipse.m2e.discovery/.project b/org.eclipse.m2e.discovery/.project
index cadecb2f..994565c0 100644
--- a/org.eclipse.m2e.discovery/.project
+++ b/org.eclipse.m2e.discovery/.project
@@ -25,6 +25,11 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ds.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
diff --git a/org.eclipse.m2e.discovery/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.m2e.discovery/.settings/org.eclipse.jdt.core.prefs
index 0c25e4ea..f819822b 100644
--- a/org.eclipse.m2e.discovery/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.m2e.discovery/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Fri Jan 07 11:00:06 EST 2011
+#Tue Feb 15 22:00:23 EST 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
org.eclipse.jdt.core.builder.duplicateResourceTask=warning
@@ -112,6 +112,7 @@ org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,HIGH
org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME,XXX
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
@@ -122,6 +123,7 @@ org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
@@ -166,10 +168,16 @@ org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert
org.eclipse.jdt.core.formatter.comment.line_length=120
+org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
+org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
+org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
org.eclipse.jdt.core.formatter.compact_else_if=true
org.eclipse.jdt.core.formatter.continuation_indentation=2
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
+org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
@@ -187,6 +195,7 @@ org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
@@ -355,6 +364,8 @@ org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.join_lines_in_comments=true
+org.eclipse.jdt.core.formatter.join_wrapped_lines=true
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
@@ -367,7 +378,9 @@ org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.tabulation.size=2
+org.eclipse.jdt.core.formatter.use_on_off_tags=false
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
org.eclipse.jdt.core.incompatibleJDKLevel=ignore
org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/org.eclipse.m2e.discovery/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.m2e.discovery/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 00000000..06059d58
--- /dev/null
+++ b/org.eclipse.m2e.discovery/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,5 @@
+#Tue Feb 15 22:00:23 EST 2011
+eclipse.preferences.version=1
+formatter_settings_version=12
+org.eclipse.jdt.ui.javadoc=true
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return Returns the ${bare_field_name}.\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} The ${bare_field_name} to set.\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*******************************************************************************&\#13;\n * Copyright (c) 2008 Sonatype, Inc.&\#13;\n * All rights reserved. This program and the accompanying materials&\#13;\n * are made available under the terms of the Eclipse Public License v1.0&\#13;\n * which accompanies this distribution, and is available at&\#13;\n * http\://www.eclipse.org/legal/epl-v10.html&\#13;\n *******************************************************************************/&\#13;\n</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * ${type_name}\n *\n * @author ${user}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="false" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\nMavenLogger.log(${exception_var});</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method ${enclosing_method}\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
diff --git a/org.eclipse.m2e.discovery/META-INF/MANIFEST.MF b/org.eclipse.m2e.discovery/META-INF/MANIFEST.MF
index b83bd429..62109529 100644
--- a/org.eclipse.m2e.discovery/META-INF/MANIFEST.MF
+++ b/org.eclipse.m2e.discovery/META-INF/MANIFEST.MF
@@ -20,7 +20,8 @@ Require-Bundle: org.eclipse.equinox.p2.ui.discovery,
org.eclipse.equinox.p2.core,
org.eclipse.equinox.p2.metadata,
org.eclipse.m2e.core.ui;bundle-version="[0.13.0,0.14.0)",
- org.slf4j.api;bundle-version="1.5.11"
+ org.slf4j.api;bundle-version="1.5.11",
+ org.eclipse.m2e.maven.runtime;bundle-version="[0.13.0,0.14.0)"
Export-Package: org.eclipse.m2e.internal.discovery;x-internal:=true,
org.eclipse.m2e.internal.discovery.handlers;x-internal:=true,
org.eclipse.m2e.internal.discovery.markers;x-internal:=true,
@@ -38,3 +39,4 @@ Import-Package: org.apache.maven.model,
org.eclipse.equinox.p2.ui
Bundle-Activator: org.eclipse.m2e.internal.discovery.DiscoveryActivator
Bundle-ActivationPolicy: lazy
+Service-Component: OSGI-INF/component.xml
diff --git a/org.eclipse.m2e.discovery/OSGI-INF/component.xml b/org.eclipse.m2e.discovery/OSGI-INF/component.xml
new file mode 100644
index 00000000..37e8d22e
--- /dev/null
+++ b/org.eclipse.m2e.discovery/OSGI-INF/component.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.m2e.internal.discovery.MavenDiscoveryService">
+ <implementation class="org.eclipse.m2e.internal.discovery.MavenDiscoveryService"/>
+ <service>
+ <provide interface="org.eclipse.m2e.core.internal.lifecycle.discovery.IMavenDisovery"/>
+ </service>
+</scr:component>
diff --git a/org.eclipse.m2e.discovery/build.properties b/org.eclipse.m2e.discovery/build.properties
index 98e4203d..bd455d4b 100644
--- a/org.eclipse.m2e.discovery/build.properties
+++ b/org.eclipse.m2e.discovery/build.properties
@@ -18,4 +18,5 @@ bin.includes = .,\
src/,\
plugin.xml,\
plugin.properties,\
- icons/
+ icons/,\
+ OSGI-INF/
diff --git a/org.eclipse.m2e.discovery/plugin.xml b/org.eclipse.m2e.discovery/plugin.xml
index 8c0c6aea..ed8c5a2f 100644
--- a/org.eclipse.m2e.discovery/plugin.xml
+++ b/org.eclipse.m2e.discovery/plugin.xml
@@ -39,4 +39,14 @@
markerType="org.eclipse.m2e.core.maven2Problem.lifecycleMapping">
</markerResolutionGenerator>
</extension>
+ <extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.eclipse.m2e.internal.discovery.InstallCatalogItemMavenDiscoveryProposal"
+ class="org.eclipse.m2e.internal.discovery.InstallCatalogItemMappingLabelProvider">
+ <adapter
+ type="org.eclipse.m2e.core.ui.internal.lifecyclemapping.ILifecycleMappingLabelProvider">
+ </adapter>
+ </factory>
+ </extension>
</plugin>
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/InstallCatalogItemMappingLabelProvider.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/InstallCatalogItemMappingLabelProvider.java
new file mode 100644
index 00000000..49ae0bcb
--- /dev/null
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/InstallCatalogItemMappingLabelProvider.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Sonatype, Inc.
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.m2e.internal.discovery;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.m2e.core.ui.internal.lifecyclemapping.ILifecycleMappingLabelProvider;
+
+
+@SuppressWarnings({"restriction", "unchecked", "rawtypes"})
+public class InstallCatalogItemMappingLabelProvider implements ILifecycleMappingLabelProvider, IAdapterFactory {
+
+ private final InstallCatalogItemMavenDiscoveryProposal proposal;
+
+ /**
+ * Factory instance constructor
+ */
+ public InstallCatalogItemMappingLabelProvider() {
+ this(null);
+ }
+
+ public InstallCatalogItemMappingLabelProvider(InstallCatalogItemMavenDiscoveryProposal proposal) {
+ this.proposal = proposal;
+ }
+
+ public String getMavenText() {
+ return ""; //$NON-NLS-1$
+ }
+
+ public String getEclipseMappingText() {
+ return "INSTALL " + proposal.getCatalogItem().getName();
+ }
+
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if(adapterType.isAssignableFrom(ILifecycleMappingLabelProvider.class)
+ && adaptableObject instanceof InstallCatalogItemMavenDiscoveryProposal) {
+ return new InstallCatalogItemMappingLabelProvider((InstallCatalogItemMavenDiscoveryProposal) adaptableObject);
+ }
+ return null;
+ }
+
+ public Class[] getAdapterList() {
+ return new Class[] {ILifecycleMappingLabelProvider.class};
+ }
+
+}
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/InstallCatalogItemMavenDiscoveryProposal.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/InstallCatalogItemMavenDiscoveryProposal.java
new file mode 100644
index 00000000..9e6c3797
--- /dev/null
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/InstallCatalogItemMavenDiscoveryProposal.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Sonatype, Inc.
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.m2e.internal.discovery;
+
+import org.eclipse.equinox.internal.p2.discovery.model.CatalogItem;
+import org.eclipse.m2e.core.internal.lifecycle.discovery.IMavenDiscoveryProposal;
+
+
+/**
+ * InstallIUMavenDiscoveryProposal
+ *
+ * @author igor
+ */
+@SuppressWarnings("restriction")
+public class InstallCatalogItemMavenDiscoveryProposal implements IMavenDiscoveryProposal {
+
+ private final CatalogItem item;
+
+ public InstallCatalogItemMavenDiscoveryProposal(CatalogItem item) {
+ this.item = item;
+ }
+
+ public CatalogItem getCatalogItem() {
+ return item;
+ }
+
+ @Override
+ public String toString() {
+ return item.getDescription();
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = item.getSiteUrl().hashCode();
+ hash = 17 * hash + item.getInstallableUnits().hashCode();
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if(obj == this) {
+ return true;
+ }
+
+ if(!(obj instanceof InstallCatalogItemMavenDiscoveryProposal)) {
+ return false;
+ }
+
+ InstallCatalogItemMavenDiscoveryProposal other = (InstallCatalogItemMavenDiscoveryProposal) obj;
+
+ return item.getSiteUrl().equals(other.item.getSiteUrl())
+ && item.getInstallableUnits().equals(other.item.getInstallableUnits());
+ }
+}
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscovery.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscovery.java
index e77995a8..3fb0aca7 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscovery.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscovery.java
@@ -11,26 +11,38 @@
package org.eclipse.m2e.internal.discovery;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import org.apache.maven.plugin.MojoExecution;
+import org.codehaus.plexus.util.IOUtil;
import org.eclipse.equinox.internal.p2.discovery.Catalog;
import org.eclipse.equinox.internal.p2.discovery.DiscoveryCore;
import org.eclipse.equinox.internal.p2.discovery.compatibility.RemoteBundleDiscoveryStrategy;
+import org.eclipse.equinox.internal.p2.discovery.model.CatalogItem;
import org.eclipse.equinox.internal.p2.discovery.model.Tag;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.m2e.core.internal.lifecycle.LifecycleMappingFactory;
+import org.eclipse.m2e.core.internal.lifecycle.model.LifecycleMappingMetadataSource;
+import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
import org.eclipse.m2e.internal.discovery.wizards.MavenCatalogConfiguration;
+import org.eclipse.m2e.internal.discovery.wizards.MavenCatalogViewer;
import org.eclipse.m2e.internal.discovery.wizards.MavenDiscoveryWizard;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.internal.Workbench;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@SuppressWarnings("restriction")
public class MavenDiscovery {
+ private static final Logger log = LoggerFactory.getLogger(MavenDiscovery.class);
public static final Tag NO_RESTART_TAG = new Tag("norestart", "norestart"); //$NON-NLS-1$//$NON-NLS-2$
@@ -48,7 +60,7 @@ public class MavenDiscovery {
launchWizard(shell, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
}
- public static void launchWizard(final Collection<String> packagingTypes, final Collection<MojoExecution> mojos,
+ public static void launchWizard(final Collection<String> packagingTypes, final Collection<MojoExecutionKey> mojos,
final Collection<String> lifecycleIds, final Collection<String> configuratorIds) {
final Display display = Workbench.getInstance().getDisplay();
display.asyncExec(new Runnable() {
@@ -58,16 +70,9 @@ public class MavenDiscovery {
});
}
- public static void launchWizard(Shell shell, Collection<String> packagingTypes, Collection<MojoExecution> mojos,
+ public static void launchWizard(Shell shell, Collection<String> packagingTypes, Collection<MojoExecutionKey> mojos,
Collection<String> lifecycleIds, Collection<String> configuratorIds) {
- Catalog catalog = new Catalog();
- catalog.setEnvironment(DiscoveryCore.createEnvironment());
- catalog.setVerifyUpdateSiteAvailability(false);
-
- // look for remote descriptor
- RemoteBundleDiscoveryStrategy remoteDiscoveryStrategy = new RemoteBundleDiscoveryStrategy();
- remoteDiscoveryStrategy.setDirectoryUrl(PATH);
- catalog.getDiscoveryStrategies().add(remoteDiscoveryStrategy);
+ Catalog catalog = getCatalog();
// Build the list of tags to show in the Wizard header
List<Tag> tags = new ArrayList<Tag>(3);
@@ -99,4 +104,45 @@ public class MavenDiscovery {
WizardDialog dialog = new WizardDialog(shell, wizard);
dialog.open();
}
+
+ public static Catalog getCatalog() {
+ Catalog catalog = new Catalog();
+ catalog.setEnvironment(DiscoveryCore.createEnvironment());
+ catalog.setVerifyUpdateSiteAvailability(false);
+
+ // look for remote descriptor
+ RemoteBundleDiscoveryStrategy remoteDiscoveryStrategy = new RemoteBundleDiscoveryStrategy();
+ remoteDiscoveryStrategy.setDirectoryUrl(PATH);
+ catalog.getDiscoveryStrategies().add(remoteDiscoveryStrategy);
+ return catalog;
+ }
+
+ public static LifecycleMappingMetadataSource getLifecycleMappingMetadataSource(CatalogItem ci) {
+ try {
+ URL url = MavenCatalogViewer.getLifecycleMappingMetadataSourceURL(ci);
+ InputStream is = url.openStream();
+ try {
+ return LifecycleMappingFactory.createLifecycleMappingMetadataSource(is);
+ } finally {
+ IOUtil.close(is);
+ }
+ } catch(FileNotFoundException e) {
+ log.warn("CatalogItem {} does not contain lifecycle mapping metadata", ci.getId()); //$NON-NLS-1$
+ } catch(Exception e) {
+ log.warn(NLS.bind(Messages.MavenCatalogViewer_Error_loading_lifecycle, ci.getId()), e);
+ }
+ return null;
+ }
+
+ /*
+ * Restart is required when one or more CatalogItem lacks the norestart tag.
+ */
+ public static boolean requireRestart(Iterable<CatalogItem> catalogItems) {
+ for(CatalogItem item : catalogItems) {
+ if(!item.hasTag(NO_RESTART_TAG)) {
+ return true;
+ }
+ }
+ return false;
+ }
}
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscoveryService.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscoveryService.java
new file mode 100644
index 00000000..a5a34a47
--- /dev/null
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscoveryService.java
@@ -0,0 +1,239 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Sonatype, Inc.
+ * 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.m2e.internal.discovery;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.IdentityHashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.execution.MavenExecutionRequest;
+import org.apache.maven.plugin.MojoExecution;
+import org.apache.maven.project.MavenProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.equinox.internal.p2.discovery.Catalog;
+import org.eclipse.equinox.internal.p2.discovery.model.CatalogItem;
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.embedder.IMaven;
+import org.eclipse.m2e.core.internal.lifecycle.LifecycleMappingFactory;
+import org.eclipse.m2e.core.internal.lifecycle.LifecycleMappingResult;
+import org.eclipse.m2e.core.internal.lifecycle.MappingMetadataSource;
+import org.eclipse.m2e.core.internal.lifecycle.discovery.ILifecycleMappingElementKey;
+import org.eclipse.m2e.core.internal.lifecycle.discovery.IMavenDiscoveryProposal;
+import org.eclipse.m2e.core.internal.lifecycle.discovery.IMavenDisovery;
+import org.eclipse.m2e.core.internal.lifecycle.discovery.MojoExecutionMappingConfiguration;
+import org.eclipse.m2e.core.internal.lifecycle.discovery.PackagingTypeMappingConfiguration;
+import org.eclipse.m2e.core.internal.lifecycle.model.LifecycleMappingMetadata;
+import org.eclipse.m2e.core.internal.lifecycle.model.LifecycleMappingMetadataSource;
+import org.eclipse.m2e.core.internal.lifecycle.model.PluginExecutionMetadata;
+import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
+import org.eclipse.m2e.internal.discovery.operation.MavenDiscoveryInstallOperation;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
+
+
+@SuppressWarnings({"restriction", "rawtypes"})
+public class MavenDiscoveryService implements IMavenDisovery, ServiceFactory {
+
+ private final boolean factory;
+
+ //private Catalog catalog;
+
+ private IdentityHashMap<CatalogItem, LifecycleMappingMetadataSource> items;
+
+ public MavenDiscoveryService() {
+ this(true);
+ }
+
+ public MavenDiscoveryService(boolean factory) {
+ this.factory = factory;
+ }
+
+ public Map<ILifecycleMappingElementKey, List<IMavenDiscoveryProposal>> discover(MavenProject mavenProject,
+ List<MojoExecution> mojoExecutions, List<IMavenDiscoveryProposal> preselected, IProgressMonitor monitor)
+ throws CoreException {
+
+ if(items == null) {
+ items = new IdentityHashMap<CatalogItem, LifecycleMappingMetadataSource>();
+
+ Catalog catalog = MavenDiscovery.getCatalog();
+ IStatus status = catalog.performDiscovery(monitor);
+
+ if(!status.isOK()) {
+ // XXX log and/or throw something heavy at the caller
+ return null;
+ }
+
+ for(CatalogItem item : catalog.getItems()) {
+ LifecycleMappingMetadataSource metadataSource = MavenDiscovery.getLifecycleMappingMetadataSource(item);
+ if(metadataSource != null) {
+ addCatalogItem(item, metadataSource);
+ }
+ }
+ }
+
+ Map<ILifecycleMappingElementKey, List<IMavenDiscoveryProposal>> proposals = new LinkedHashMap<ILifecycleMappingElementKey, List<IMavenDiscoveryProposal>>();
+
+ MavenPlugin mavenPlugin = MavenPlugin.getDefault();
+ IMaven maven = mavenPlugin.getMaven();
+
+ MavenExecutionRequest request = maven.createExecutionRequest(monitor); // TODO this ignores workspace dependencies
+
+ List<CatalogItem> selectedItems = toCatalogItems(preselected);
+ List<LifecycleMappingMetadataSource> selectedSources = toMetadataSources(preselected);
+
+ for(Map.Entry<CatalogItem, LifecycleMappingMetadataSource> itemEntry : items.entrySet()) {
+ CatalogItem item = itemEntry.getKey();
+ LifecycleMappingMetadataSource src = itemEntry.getValue();
+
+ boolean preselectItem = false;
+ for(CatalogItem selectedItem : selectedItems) {
+ if(selectedItem.getSiteUrl().equals(item.getSiteUrl())
+ && selectedItem.getInstallableUnits().equals(item.getInstallableUnits())) {
+ preselectItem = true;
+ break;
+ }
+ }
+
+ if(src != null) {
+ src.setSource(item);
+
+ LifecycleMappingResult mappingResult = new LifecycleMappingResult();
+
+ List<LifecycleMappingMetadataSource> sources = new ArrayList<LifecycleMappingMetadataSource>(selectedSources);
+ if(!preselectItem) {
+ sources.add(src);
+ }
+
+ List<MappingMetadataSource> metadataSources = LifecycleMappingFactory.getProjectMetadataSources(request,
+ mavenProject, sources, monitor);
+
+ LifecycleMappingFactory.calculateEffectiveLifecycleMappingMetadata(mappingResult, metadataSources,
+ mavenProject, mojoExecutions);
+
+ LifecycleMappingMetadata lifecycleMappingMetadata = mappingResult.getLifecycleMappingMetadata();
+ if(lifecycleMappingMetadata != null) {
+ IMavenDiscoveryProposal proposal = getProposal(lifecycleMappingMetadata.getSource());
+ if(proposal != null) {
+ put(proposals, new PackagingTypeMappingConfiguration.Key(mavenProject.getPackaging()), proposal);
+ }
+ }
+
+ for(Map.Entry<MojoExecutionKey, List<PluginExecutionMetadata>> entry : mappingResult.getMojoExecutionMapping()
+ .entrySet()) {
+ if(entry.getValue() != null) {
+ for(PluginExecutionMetadata executionMapping : entry.getValue()) {
+ IMavenDiscoveryProposal proposal = getProposal(executionMapping.getSource());
+ if(proposal != null) {
+ put(proposals, new MojoExecutionMappingConfiguration.Key(entry.getKey()), proposal);
+ }
+ // TODO match eclipse extensions provided by the catalog item
+ // User Story.
+ // Project pom.xml explicitly specifies lifecycle mapping strategy implementation,
+ // but the implementation is not currently installed. As a user I expect m2e to search
+ // marketplace for the implementation and offer installation if available
+ }
+ }
+ }
+ }
+ }
+
+ return proposals;
+ }
+
+ public void addCatalogItem(CatalogItem item, LifecycleMappingMetadataSource metadataSource) {
+ if(items == null) {
+ // for tests
+ items = new IdentityHashMap<CatalogItem, LifecycleMappingMetadataSource>();
+ }
+ items.put(item, metadataSource);
+ }
+
+ private IMavenDiscoveryProposal getProposal(LifecycleMappingMetadataSource src) {
+ if(src == null) {
+ return null;
+ }
+ if(src.getSource() instanceof CatalogItem) {
+ return new InstallCatalogItemMavenDiscoveryProposal((CatalogItem) src.getSource());
+ }
+ return null;
+ }
+
+ private List<LifecycleMappingMetadataSource> toMetadataSources(List<IMavenDiscoveryProposal> proposals) {
+ List<LifecycleMappingMetadataSource> sources = new ArrayList<LifecycleMappingMetadataSource>();
+ for(IMavenDiscoveryProposal proposal : proposals) {
+ if(proposal instanceof InstallCatalogItemMavenDiscoveryProposal) {
+ CatalogItem catalogItem = ((InstallCatalogItemMavenDiscoveryProposal) proposal).getCatalogItem();
+ LifecycleMappingMetadataSource source = MavenDiscovery.getLifecycleMappingMetadataSource(catalogItem);
+ source.setSource(catalogItem);
+ sources.add(source);
+ }
+ }
+ return sources;
+ }
+
+ private void put(Map<ILifecycleMappingElementKey, List<IMavenDiscoveryProposal>> allproposals,
+ ILifecycleMappingElementKey requirement, IMavenDiscoveryProposal proposal) {
+
+ List<IMavenDiscoveryProposal> proposals = allproposals.get(requirement);
+ if(proposals == null) {
+ proposals = new ArrayList<IMavenDiscoveryProposal>();
+ allproposals.put(requirement, proposals);
+ }
+
+ if(!proposals.contains(proposal)) {
+ proposals.add(proposal);
+ }
+ }
+
+ public void implement(List<IMavenDiscoveryProposal> proposals, IProgressMonitor monitor) {
+ List<CatalogItem> items = toCatalogItems(proposals);
+
+ MavenDiscoveryInstallOperation op = new MavenDiscoveryInstallOperation(items, false);
+ try {
+ op.run(monitor);
+ } catch(InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch(InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ private List<CatalogItem> toCatalogItems(List<IMavenDiscoveryProposal> proposals) {
+ List<CatalogItem> items = new ArrayList<CatalogItem>();
+ for(IMavenDiscoveryProposal proposal : proposals) {
+ if(proposal instanceof InstallCatalogItemMavenDiscoveryProposal) {
+ items.add(((InstallCatalogItemMavenDiscoveryProposal) proposal).getCatalogItem());
+ }
+ }
+ return items;
+ }
+
+ public boolean isRestartRequired(List<IMavenDiscoveryProposal> proposals, IProgressMonitor monitor) {
+ return MavenDiscovery.requireRestart(toCatalogItems(proposals));
+ }
+
+ public Object getService(Bundle bundle, ServiceRegistration registration) {
+ return new MavenDiscoveryService(false); // not a factory instance
+ }
+
+ public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
+ }
+
+}
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/DiscoveryWizardProposal.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/DiscoveryWizardProposal.java
index e04bf4a7..ec41ed73 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/DiscoveryWizardProposal.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/DiscoveryWizardProposal.java
@@ -15,14 +15,13 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import org.apache.maven.model.Plugin;
-import org.apache.maven.plugin.MojoExecution;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.m2e.core.core.IMavenConstants;
+import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
import org.eclipse.m2e.internal.discovery.MavenDiscovery;
import org.eclipse.m2e.internal.discovery.MavenDiscoveryIcons;
import org.eclipse.m2e.internal.discovery.Messages;
@@ -76,7 +75,7 @@ public class DiscoveryWizardProposal extends WorkbenchMarkerResolution {
public void run(IMarker[] markers, IProgressMonitor monitor) {
List<String> lifecycleIds = new ArrayList<String>();
List<String> packagingTypes = new ArrayList<String>();
- List<MojoExecution> mojos = new ArrayList<MojoExecution>();
+ List<MojoExecutionKey> mojos = new ArrayList<MojoExecutionKey>();
List<String> configuratorIds = new ArrayList<String>();
for(IMarker marker : markers) {
String type = marker.getAttribute(IMavenConstants.MARKER_ATTR_EDITOR_HINT, null);
@@ -93,7 +92,7 @@ public class DiscoveryWizardProposal extends WorkbenchMarkerResolution {
MavenDiscovery.launchWizard(packagingTypes, mojos, lifecycleIds, configuratorIds);
}
- private MojoExecution getMojoExecution(IMarker marker) {
+ private MojoExecutionKey getMojoExecution(IMarker marker) {
// TODO Which of these are actually required?
String groupId = marker.getAttribute(IMavenConstants.MARKER_ATTR_GROUP_ID, null);
String artifactId = marker.getAttribute(IMavenConstants.MARKER_ATTR_ARTIFACT_ID, null);
@@ -102,13 +101,7 @@ public class DiscoveryWizardProposal extends WorkbenchMarkerResolution {
String goal = marker.getAttribute(IMavenConstants.MARKER_ATTR_GOAL, null);
String lifecyclePhase = marker.getAttribute(IMavenConstants.MARKER_ATTR_LIFECYCLE_PHASE, null);
if(goal != null && executionId != null && artifactId != null && groupId != null) {
- Plugin plugin = new Plugin();
- plugin.setArtifactId(artifactId);
- plugin.setGroupId(groupId);
- plugin.setVersion(version);
- MojoExecution mojoExecution = new MojoExecution(plugin, goal, executionId);
- mojoExecution.setLifecyclePhase(lifecyclePhase);
- return mojoExecution;
+ return new MojoExecutionKey(groupId, artifactId, version, goal, lifecyclePhase, executionId);
}
return null;
}
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/operation/MavenDiscoveryInstallOperation.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/operation/MavenDiscoveryInstallOperation.java
index 29725ce7..fca24091 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/operation/MavenDiscoveryInstallOperation.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/operation/MavenDiscoveryInstallOperation.java
@@ -25,6 +25,8 @@ import org.eclipse.equinox.internal.p2.ui.discovery.operations.DiscoveryInstallO
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.operations.ProvisioningJob;
import org.eclipse.equinox.p2.operations.ProvisioningSession;
+import org.eclipse.equinox.p2.query.IQuery;
+import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.m2e.internal.discovery.MavenDiscovery;
import org.eclipse.m2e.internal.discovery.Messages;
@@ -41,9 +43,13 @@ public class MavenDiscoveryInstallOperation extends DiscoveryInstallOperation {
private List<CatalogItem> installableConnectors;
private ProvisioningSession session;
- public MavenDiscoveryInstallOperation(List<CatalogItem> installableConnectors) {
+
+ private final boolean restart;
+
+ public MavenDiscoveryInstallOperation(List<CatalogItem> installableConnectors, boolean restart) {
super(installableConnectors);
this.installableConnectors = installableConnectors;
+ this.restart = restart;
this.session = ProvisioningUI.getDefaultUI().getSession();
}
@@ -57,7 +63,7 @@ public class MavenDiscoveryInstallOperation extends DiscoveryInstallOperation {
checkCancelled(monitor);
final RestartInstallOperation installOperation = createAndResolve(monitor.newChild(50), ius, new URI[0],
- requireRestart(installableConnectors));
+ restart && MavenDiscovery.requireRestart(installableConnectors));
checkCancelled(monitor);
@@ -77,18 +83,6 @@ public class MavenDiscoveryInstallOperation extends DiscoveryInstallOperation {
}
/*
- * Restart is required when one or more CatalogItem lacks the norestart tag.
- */
- public static boolean requireRestart(Iterable<CatalogItem> catalogItems) {
- for(CatalogItem item : catalogItems) {
- if(!item.hasTag(MavenDiscovery.NO_RESTART_TAG)) {
- return true;
- }
- }
- return false;
- }
-
- /*
* Create a RestartInstallOperation and resolve
*/
private RestartInstallOperation createAndResolve(IProgressMonitor monitor, final IInstallableUnit[] ius,
@@ -113,4 +107,9 @@ public class MavenDiscoveryInstallOperation extends DiscoveryInstallOperation {
throw new OperationCanceledException();
}
}
+
+ @Override
+ protected IQuery<IInstallableUnit> createInstalledIUsQuery() {
+ return QueryUtil.createIUAnyQuery();
+ }
}
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogConfiguration.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogConfiguration.java
index 6a6201a5..e0232ce3 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogConfiguration.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogConfiguration.java
@@ -15,8 +15,8 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
-import org.apache.maven.plugin.MojoExecution;
import org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogConfiguration;
+import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
@SuppressWarnings("restriction")
@@ -24,7 +24,7 @@ public class MavenCatalogConfiguration extends CatalogConfiguration {
private Set<String> selectedPackagingTypes;
- private Set<MojoExecution> selectedMojos;
+ private Set<MojoExecutionKey> selectedMojos;
private Set<String> selectedLifecycleIds;
@@ -38,7 +38,7 @@ public class MavenCatalogConfiguration extends CatalogConfiguration {
return selectedConfiguratorIds;
}
- public Collection<MojoExecution> getSelectedMojos() {
+ public Collection<MojoExecutionKey> getSelectedMojos() {
return selectedMojos;
}
@@ -60,9 +60,9 @@ public class MavenCatalogConfiguration extends CatalogConfiguration {
/*
* Set the mojos that should be selected in the UI
*/
- public void setSelectedMojos(Collection<MojoExecution> mojos) {
+ public void setSelectedMojos(Collection<MojoExecutionKey> mojos) {
if(selectedMojos == null) {
- selectedMojos = new HashSet<MojoExecution>(mojos);
+ selectedMojos = new HashSet<MojoExecutionKey>(mojos);
} else {
selectedMojos.addAll(mojos);
}
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogViewer.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogViewer.java
index 2929989c..4257a6c7 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogViewer.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogViewer.java
@@ -14,7 +14,6 @@ package org.eclipse.m2e.internal.discovery.wizards;
import java.net.URL;
import java.util.Collection;
-import org.apache.maven.plugin.MojoExecution;
import org.eclipse.equinox.internal.p2.discovery.Catalog;
import org.eclipse.equinox.internal.p2.discovery.model.CatalogItem;
import org.eclipse.equinox.internal.p2.discovery.model.Tag;
@@ -22,20 +21,18 @@ import org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogConfiguration
import org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogViewer;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.window.IShellProvider;
-import org.eclipse.m2e.core.internal.lifecycle.LifecycleMappingFactory;
import org.eclipse.m2e.core.internal.lifecycle.model.LifecycleMappingMetadata;
import org.eclipse.m2e.core.internal.lifecycle.model.LifecycleMappingMetadataSource;
import org.eclipse.m2e.core.internal.lifecycle.model.PluginExecutionMetadata;
+import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
import org.eclipse.m2e.internal.discovery.MavenDiscovery;
-import org.eclipse.m2e.internal.discovery.Messages;
-import org.eclipse.osgi.util.NLS;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings("restriction")
public class MavenCatalogViewer extends CatalogViewer {
- private static final Logger log = LoggerFactory.getLogger(MavenCatalogViewer.class);
+ public static final Logger log = LoggerFactory.getLogger(MavenCatalogViewer.class);
private static final String CONFIGURATOR_PREFIX = "configurator:"; //$NON-NLS-1$
@@ -56,7 +53,7 @@ public class MavenCatalogViewer extends CatalogViewer {
final MavenCatalogConfiguration config = (MavenCatalogConfiguration) getConfiguration();
final Collection<String> selectedPackagingTypes = config.getSelectedPackagingTypes();
- final Collection<MojoExecution> selectedMojos = config.getSelectedMojos();
+ final Collection<MojoExecutionKey> selectedMojos = config.getSelectedMojos();
final Collection<String> selectedLifecycleIds = config.getSelectedLifecycleIds();
final Collection<String> selectedConfiguratorIds = config.getSelectedConfiguratorIds();
@@ -66,7 +63,7 @@ public class MavenCatalogViewer extends CatalogViewer {
for(CatalogItem ci : getCatalog().getItems()) {
boolean selected = false;
- LifecycleMappingMetadataSource src = getLifecycleMappingMetadataSource(ci);
+ LifecycleMappingMetadataSource src = MavenDiscovery.getLifecycleMappingMetadataSource(ci);
if(src != null) {
for(String packagingType : selectedPackagingTypes) {
if(hasPackaging(src, packagingType)) {
@@ -78,7 +75,7 @@ public class MavenCatalogViewer extends CatalogViewer {
if(selected) {
continue;
}
- for(MojoExecution mojoExecution : selectedMojos) {
+ for(MojoExecutionKey mojoExecution : selectedMojos) {
if(matchesFilter(src, mojoExecution)) {
selected = true;
select(ci);
@@ -119,7 +116,7 @@ public class MavenCatalogViewer extends CatalogViewer {
ci.addTag(MavenDiscovery.APPLICABLE_TAG);
}
- private static boolean matchesFilter(LifecycleMappingMetadataSource src, MojoExecution mojoExecution) {
+ private static boolean matchesFilter(LifecycleMappingMetadataSource src, MojoExecutionKey mojoExecution) {
for(PluginExecutionMetadata p : src.getPluginExecutions()) {
if(p.getFilter().match(mojoExecution)) {
return true;
@@ -128,16 +125,7 @@ public class MavenCatalogViewer extends CatalogViewer {
return false;
}
- private LifecycleMappingMetadataSource getLifecycleMappingMetadataSource(CatalogItem ci) {
- try {
- return LifecycleMappingFactory.createLifecycleMappingMetadataSource(getLifecycleMappingMetadataSourceURL(ci));
- } catch(Exception e) {
- log.warn(NLS.bind(Messages.MavenCatalogViewer_Error_loading_lifecycle, ci.getId()), e);
- return null;
- }
- }
-
- private static URL getLifecycleMappingMetadataSourceURL(CatalogItem ci) {
+ public static URL getLifecycleMappingMetadataSourceURL(CatalogItem ci) {
return ci.getSource().getResource(PATH + ci.getId() + EXT);
}
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenDiscoveryUi.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenDiscoveryUi.java
index f55dc509..b7e56449 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenDiscoveryUi.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenDiscoveryUi.java
@@ -50,7 +50,7 @@ public abstract class MavenDiscoveryUi {
public static boolean install(List<CatalogItem> descriptors, IRunnableContext context) {
try {
- IRunnableWithProgress runner = new MavenDiscoveryInstallOperation(descriptors);
+ IRunnableWithProgress runner = new MavenDiscoveryInstallOperation(descriptors, true);
context.run(true, true, runner);
} catch (InvocationTargetException e) {
IStatus status = new Status(IStatus.ERROR, DiscoveryActivator.PLUGIN_ID, NLS.bind(

Back to the top