geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sppa...@apache.org
Subject svn commit: r382498 - in /geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-emf-plugin: pom.xml src/main/java/org/apache/emf/plugin/LaunchOSGIMojo.java src/main/java/org/apache/emf/plugin/XSDImporterMojo.java
Date Thu, 02 Mar 2006 20:12:18 GMT
Author: sppatel
Date: Thu Mar  2 12:12:17 2006
New Revision: 382498

URL: http://svn.apache.org/viewcvs?rev=382498&view=rev
Log:
launch eclipse app support

Added:
    geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-emf-plugin/src/main/java/org/apache/emf/plugin/LaunchOSGIMojo.java
Modified:
    geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-emf-plugin/pom.xml
    geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-emf-plugin/src/main/java/org/apache/emf/plugin/XSDImporterMojo.java

Modified: geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-emf-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-emf-plugin/pom.xml?rev=382498&r1=382497&r2=382498&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-emf-plugin/pom.xml (original)
+++ geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-emf-plugin/pom.xml Thu Mar
 2 12:12:17 2006
@@ -24,22 +24,7 @@
     </dependency>
     <dependency>
       <groupId>org.eclipse.plugins</groupId>
-      <artifactId>org.eclipse.xsd.ecore.importer</artifactId>
-      <version>2.1.0</version>
-    </dependency>
-    <dependency>
-      <groupId>org.eclipse.plugins</groupId>
-      <artifactId>org.eclipse.core.runtime</artifactId>
-      <version>3.1.2</version>
-    </dependency>
-    <dependency>
-      <groupId>org.eclipse.plugins</groupId>
-      <artifactId>org.eclipse.emf.importer</artifactId>
-      <version>2.1.0</version>
-    </dependency>
-    <dependency>
-      <groupId>eclipse</groupId>
-      <artifactId>startup</artifactId>
+      <artifactId>org.eclipse.osgi</artifactId>
       <version>3.1.2</version>
     </dependency>
   </dependencies>

Added: geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-emf-plugin/src/main/java/org/apache/emf/plugin/LaunchOSGIMojo.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-emf-plugin/src/main/java/org/apache/emf/plugin/LaunchOSGIMojo.java?rev=382498&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-emf-plugin/src/main/java/org/apache/emf/plugin/LaunchOSGIMojo.java
(added)
+++ geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-emf-plugin/src/main/java/org/apache/emf/plugin/LaunchOSGIMojo.java
Thu Mar  2 12:12:17 2006
@@ -0,0 +1,93 @@
+/**
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ *  Licensed 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.
+ */
+package org.apache.emf.plugin;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Arrays;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.eclipse.core.runtime.adaptor.EclipseStarter;
+
+abstract public class LaunchOSGIMojo extends AbstractMojo {
+
+	/**
+	 * @parameter expression="${settings.localRepository}/eclipse/eclipse"
+	 */
+	protected File eclipseHome;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.maven.plugin.Mojo#execute()
+	 */
+	public void execute() throws MojoExecutionException, MojoFailureException {
+
+		if (!eclipseHome.exists())
+			throw new MojoFailureException("Eclipse installation not available");
+
+		URL osgi = findOSGI();
+		if (osgi == null) {
+			throw new MojoFailureException("OSGI bundle not found");
+		}
+
+		System.setProperty(EclipseStarter.PROP_CONSOLE_LOG, "true");
+		System.setProperty(EclipseStarter.PROP_CLEAN, "true");
+		System.setProperty(EclipseStarter.PROP_INSTALL_AREA, eclipseHome.getAbsolutePath());
+		System.setProperty(EclipseStarter.PROP_FRAMEWORK, osgi.toExternalForm());
+		System.setProperty("eclipse.application", getApplicationID());
+
+		String[] args = getArguments();
+		if (args == null)
+			args = new String[]{};
+			
+		getLog().debug(Arrays.asList(args).toString());
+		
+		try {
+			EclipseStarter.run(args, null);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	protected abstract String getApplicationID();
+
+	protected abstract String[] getArguments();
+
+	protected URL findOSGI() {
+		File bundleDir = new File(eclipseHome.getAbsoluteFile()
+				+ File.separator + "plugins");
+		if (bundleDir.isDirectory()) {
+			File[] bundles = bundleDir.listFiles(new FilenameFilter() {
+				public boolean accept(File dir, String name) {
+					return name.startsWith("org.eclipse.osgi_");
+				}
+			});
+			if (bundles.length > 0)
+				try {
+					return bundles[0].toURL();
+				} catch (MalformedURLException e) {
+					e.printStackTrace();
+				}
+		}
+		return null;
+	}
+
+}

Modified: geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-emf-plugin/src/main/java/org/apache/emf/plugin/XSDImporterMojo.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-emf-plugin/src/main/java/org/apache/emf/plugin/XSDImporterMojo.java?rev=382498&r1=382497&r2=382498&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-emf-plugin/src/main/java/org/apache/emf/plugin/XSDImporterMojo.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-emf-plugin/src/main/java/org/apache/emf/plugin/XSDImporterMojo.java
Thu Mar  2 12:12:17 2006
@@ -1,4 +1,5 @@
 package org.apache.emf.plugin;
+
 /**
  * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
  *
@@ -17,15 +18,12 @@
 import java.io.File;
 import java.util.Map;
 
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.eclipse.xsd.ecore.importer.XSDImporterApplication;
-
 /**
- * @goal xsd2Java
+ * @goal xsd2java
  */
-public class XSDImporterMojo extends AbstractMojo {
+public class XSDImporterMojo extends LaunchOSGIMojo {
+
+	public static final String APPLICATION_ID = "org.eclipse.xsd.ecore.importer.XSD2GenModel";
 
 	/**
 	 * @parameter
@@ -33,38 +31,52 @@
 	protected Map packageMap;
 
 	/**
-	 * @paramter
-	 * @required
+	 * @parameter
+	 * 
+	 */
+	protected File schema;
+
+	/**
+	 * @parameter
+	 * 
 	 */
 	protected File genModel;
 
 	/**
-	 * @paramter
-	 * @required
+	 * @parameter
+	 * 
 	 */
 	protected File project;
 
 	/**
-	 * @paramter
-	 * @required
+	 * @parameter
+	 * 
 	 */
 	protected String projectId;
 
 	/**
-	 * @paramter
-	 * @required
+	 * @parameter
+	 * 
 	 */
 	protected String type;
 
-	XSDImporterApplication application;
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.maven.plugin.Mojo#execute()
+	/* (non-Javadoc)
+	 * @see org.apache.emf.plugin.LaunchOSGIMojo#getArguments()
 	 */
-	public void execute() throws MojoExecutionException, MojoFailureException {
-
+	protected String[] getArguments() {
+		return null;
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.apache.emf.plugin.LaunchOSGIMojo#getApplicationID()
+	 */
+	protected String getApplicationID() {
+		return APPLICATION_ID;
+	}
+
+	protected StringBuffer processParameters() {
+		StringBuffer buffer = new StringBuffer();
+		return buffer;
 	}
 
 }



Mime
View raw message