Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2011-02-11 22:11:07 +0000
committerPascal Rapicault2011-02-11 22:11:07 +0000
commit5d9b0a01b47f08368982f1fffbad818bc58334dc (patch)
tree06a5fd795ca5ab26813043bdcdd41f765990cedc /org.eclipse.m2e.usagedata
parent0137f03b92ce37676c4295db2332b784c222d1cb (diff)
downloadm2e-core-5d9b0a01b47f08368982f1fffbad818bc58334dc.tar.gz
m2e-core-5d9b0a01b47f08368982f1fffbad818bc58334dc.tar.xz
m2e-core-5d9b0a01b47f08368982f1fffbad818bc58334dc.zip
Capture packaging type and plugin ids using UDC infrastructure.
Diffstat (limited to 'org.eclipse.m2e.usagedata')
-rw-r--r--org.eclipse.m2e.usagedata/.classpath7
-rw-r--r--org.eclipse.m2e.usagedata/.gitignore1
-rw-r--r--org.eclipse.m2e.usagedata/.project34
-rw-r--r--org.eclipse.m2e.usagedata/.settings/org.eclipse.m2e.core.prefs5
-rw-r--r--org.eclipse.m2e.usagedata/META-INF/MANIFEST.MF10
-rw-r--r--org.eclipse.m2e.usagedata/META-INF/p2.inf7
-rw-r--r--org.eclipse.m2e.usagedata/build.properties16
-rw-r--r--org.eclipse.m2e.usagedata/plugin.xml17
-rw-r--r--org.eclipse.m2e.usagedata/pom.xml11
-rw-r--r--org.eclipse.m2e.usagedata/src/org/eclipse/m2e/internal/udc/PomImportMonitor.java84
10 files changed, 192 insertions, 0 deletions
diff --git a/org.eclipse.m2e.usagedata/.classpath b/org.eclipse.m2e.usagedata/.classpath
new file mode 100644
index 00000000..288a7808
--- /dev/null
+++ b/org.eclipse.m2e.usagedata/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/org.eclipse.m2e.usagedata/.gitignore b/org.eclipse.m2e.usagedata/.gitignore
new file mode 100644
index 00000000..ea8c4bf7
--- /dev/null
+++ b/org.eclipse.m2e.usagedata/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/org.eclipse.m2e.usagedata/.project b/org.eclipse.m2e.usagedata/.project
new file mode 100644
index 00000000..1fbf11ff
--- /dev/null
+++ b/org.eclipse.m2e.usagedata/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.m2e.usagedata</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.m2e.usagedata/.settings/org.eclipse.m2e.core.prefs b/org.eclipse.m2e.usagedata/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 00000000..56653748
--- /dev/null
+++ b/org.eclipse.m2e.usagedata/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,5 @@
+#Fri Jan 21 15:08:17 EST 2011
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/org.eclipse.m2e.usagedata/META-INF/MANIFEST.MF b/org.eclipse.m2e.usagedata/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..65743acf
--- /dev/null
+++ b/org.eclipse.m2e.usagedata/META-INF/MANIFEST.MF
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.eclipse.m2e.usagedata;singleton:=true
+Bundle-Version: 0.13.0.qualifier
+Require-Bundle: org.eclipse.epp.usagedata.gathering;resolution:=optional,
+ org.eclipse.m2e.core
+Import-Package: org.eclipse.core.runtime
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,
+ JavaSE-1.6
diff --git a/org.eclipse.m2e.usagedata/META-INF/p2.inf b/org.eclipse.m2e.usagedata/META-INF/p2.inf
new file mode 100644
index 00000000..1c9d3929
--- /dev/null
+++ b/org.eclipse.m2e.usagedata/META-INF/p2.inf
@@ -0,0 +1,7 @@
+# We are tweaking the dependency on the UDC collectors
+# so our plugin is always installed by our feature but we don't want to always pull down the UDC bundles itself
+# as it can be annoying for the end user which is why we mark the dependency non greedy.
+# This means that there will be installations where our usagecollector bundle will be installed but not resolved.
+ requires.0.namespace = osgi.bundle
+ requires.0.name = org.eclipse.epp.usagedata.gathering
+ requires.0.greedy = false
diff --git a/org.eclipse.m2e.usagedata/build.properties b/org.eclipse.m2e.usagedata/build.properties
new file mode 100644
index 00000000..6c8a5036
--- /dev/null
+++ b/org.eclipse.m2e.usagedata/build.properties
@@ -0,0 +1,16 @@
+# Copyright (c) 2008-2010 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
+#
+
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .
+jars.compile.order = .
+output.. = target/classes
+source.. = src/
diff --git a/org.eclipse.m2e.usagedata/plugin.xml b/org.eclipse.m2e.usagedata/plugin.xml
new file mode 100644
index 00000000..489f67ea
--- /dev/null
+++ b/org.eclipse.m2e.usagedata/plugin.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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
+-->
+<?eclipse version="3.0"?>
+<plugin>
+ <extension
+ point="org.eclipse.epp.usagedata.gathering.monitors">
+ <monitor
+ class="org.eclipse.m2e.internal.udc.PomImportMonitor">
+ </monitor>
+ </extension>
+</plugin>
diff --git a/org.eclipse.m2e.usagedata/pom.xml b/org.eclipse.m2e.usagedata/pom.xml
new file mode 100644
index 00000000..0e6e1e00
--- /dev/null
+++ b/org.eclipse.m2e.usagedata/pom.xml
@@ -0,0 +1,11 @@
+<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>
+ <parent>
+ <artifactId>org.eclipse.m2e.parent</artifactId>
+ <groupId>org.eclipse.m2e</groupId>
+ <version>0.13.0-SNAPSHOT</version>
+ <relativePath>../org.eclipse.m2e.parent</relativePath>
+ </parent>
+ <artifactId>org.eclipse.m2e.usagedata</artifactId>
+ <packaging>eclipse-plugin</packaging>
+</project> \ No newline at end of file
diff --git a/org.eclipse.m2e.usagedata/src/org/eclipse/m2e/internal/udc/PomImportMonitor.java b/org.eclipse.m2e.usagedata/src/org/eclipse/m2e/internal/udc/PomImportMonitor.java
new file mode 100644
index 00000000..0e87d1c5
--- /dev/null
+++ b/org.eclipse.m2e.usagedata/src/org/eclipse/m2e/internal/udc/PomImportMonitor.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * 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.udc;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.epp.usagedata.internal.gathering.monitors.UsageMonitor;
+import org.eclipse.epp.usagedata.internal.gathering.services.UsageDataService;
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager;
+import org.eclipse.m2e.core.project.IMavenProjectChangedListener;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+import org.eclipse.m2e.core.project.MavenProjectChangedEvent;
+import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
+
+
+@SuppressWarnings("restriction")
+public class PomImportMonitor implements UsageMonitor, IMavenProjectChangedListener {
+
+ private static final String SEPARATOR = ":"; //$NON-NLS-1$
+
+ private static final String PLUGINS = "m2e.plugins"; //$NON-NLS-1$
+
+ private static final String PACKAGING = "m2e.packaging"; //$NON-NLS-1$
+
+ private static final String VERSION = "0.13.0"; //$NON-NLS-1$
+
+ private static final String ID = "org.eclipse.m2e.core"; //$NON-NLS-1$
+
+ private UsageDataService usageDataService;
+
+ private ProjectRegistryManager manager;
+
+ public void startMonitoring(UsageDataService usageDataService) {
+ this.usageDataService = usageDataService;
+ manager = MavenPlugin.getDefault().getMavenProjectManagerImpl();
+ manager.addMavenProjectChangedListener(this);
+ }
+
+ public void stopMonitoring() {
+ usageDataService = null;
+ manager.removeMavenProjectChangedListener(this);
+ }
+
+ public void mavenProjectChanged(MavenProjectChangedEvent[] events, IProgressMonitor monitor) {
+ SubMonitor subMon = SubMonitor.convert(monitor, 2 * events.length);
+ try {
+ for(MavenProjectChangedEvent event : events) {
+ if(monitor.isCanceled()) {
+ return;
+ }
+ if(event.getKind() != MavenProjectChangedEvent.KIND_ADDED) {
+ continue;
+ }
+ IMavenProjectFacade facade = event.getMavenProject();
+ usageDataService.recordEvent(facade.getPackaging(), PACKAGING, facade.getPackaging(), ID, VERSION);
+ subMon.worked(1);
+
+ if(facade.getMojoExecutionMapping() != null) {
+ for(MojoExecutionKey key : facade.getMojoExecutionMapping().keySet()) {
+ usageDataService.recordEvent(
+ key.getGoal() + SEPARATOR + key.getExecutionId() + SEPARATOR + key.getLifecyclePhase(), PLUGINS,
+ key.getGroupId() + SEPARATOR + key.getArtifactId() + SEPARATOR + key.getVersion(), ID, VERSION);
+ }
+ }
+ subMon.worked(1);
+
+ if(subMon.isCanceled()) {
+ return;
+ }
+ }
+ } finally {
+ subMon.done();
+ }
+ }
+}

Back to the top