Bug 354145 - Provide a Tycho plugin for code generation

- add generate application.

Change-Id: Ieec75478bcb6a06784ce068b56ce083e361fbd0a
Signed-off-by: atischenko <tischenko@montages.com>
diff --git a/plugins/org.eclipse.gmf.codegen.xtend.ui/src/org/eclipse/gmf/codegen/xtend/ui/handlers/GeneratorWithXtend2.java b/plugins/org.eclipse.gmf.codegen.xtend.ui/src/org/eclipse/gmf/codegen/xtend/ui/handlers/GeneratorWithXtend2.java
index 617627a..de4877a 100644
--- a/plugins/org.eclipse.gmf.codegen.xtend.ui/src/org/eclipse/gmf/codegen/xtend/ui/handlers/GeneratorWithXtend2.java
+++ b/plugins/org.eclipse.gmf.codegen.xtend.ui/src/org/eclipse/gmf/codegen/xtend/ui/handlers/GeneratorWithXtend2.java
@@ -3,6 +3,7 @@
 import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
 import org.eclipse.gmf.codegen.util.Generator;
 import org.eclipse.gmf.common.UnexpectedBehaviourException;
+import org.eclipse.gmf.internal.common.codegen.CodeFormatterFactory;
 
 public class GeneratorWithXtend2 extends Generator {
 
@@ -13,7 +14,11 @@
 	}
 
 	public GeneratorWithXtend2(GenEditorGenerator genModel, CodegenEmittersWithXtend2 codegenEmitters) {
-		super(genModel, codegenEmitters);
+		this(genModel, codegenEmitters, CodeFormatterFactory.DEFAULT);
+	}
+
+	public GeneratorWithXtend2(GenEditorGenerator genModel, CodegenEmittersWithXtend2 codegenEmitters, CodeFormatterFactory codeFormatterFactory) {
+		super(genModel, codegenEmitters, codeFormatterFactory);
 		myEmitters = codegenEmitters;
 	}
 
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/Generator.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/Generator.java
index cad5783..63589f6 100644
--- a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/Generator.java
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/Generator.java
@@ -85,6 +85,7 @@
 import org.eclipse.gmf.codegen.gmfgen.StandardPreferencePages;
 import org.eclipse.gmf.codegen.gmfgen.TypeLinkModelFacet;
 import org.eclipse.gmf.common.UnexpectedBehaviourException;
+import org.eclipse.gmf.internal.common.codegen.CodeFormatterFactory;
 import org.eclipse.gmf.internal.common.codegen.GeneratorBase;
 import org.eclipse.gmf.internal.common.codegen.JavaClassEmitter;
 import org.eclipse.gmf.internal.common.codegen.TextEmitter;
@@ -113,14 +114,23 @@
 		this(genModel, emitters, new BinaryEmitters());
 	}
 
+	public Generator(GenEditorGenerator genModel, CodegenEmitters emitters, CodeFormatterFactory codeFormatterFactory) {
+		this(genModel, emitters, new BinaryEmitters(), codeFormatterFactory);
+	}
+
 	public Generator(GenEditorGenerator genModel, CodegenEmitters emitters, BinaryEmitters binaryEmitters) { 
+		this(genModel, emitters, binaryEmitters, CodeFormatterFactory.DEFAULT);
+	}
+
+	public Generator(GenEditorGenerator genModel, CodegenEmitters emitters, BinaryEmitters binaryEmitters, CodeFormatterFactory codeFormatterFactory) {
+		super(codeFormatterFactory);
 		assert genModel != null && emitters != null;
 		myEditorGen = genModel;
 		myDiagram = genModel.getDiagram();
 		myEmitters = emitters;
 		myBinaryEmmiters = binaryEmitters;
 	}
-	
+
 	@Override
 	protected TextMerger createMergeService() {
 		TextMerger service = myEmitters.createMergeService();
diff --git a/plugins/org.eclipse.gmf.common/META-INF/MANIFEST.MF b/plugins/org.eclipse.gmf.common/META-INF/MANIFEST.MF
index 12b72f1..ce72d7c 100644
--- a/plugins/org.eclipse.gmf.common/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.gmf.common/META-INF/MANIFEST.MF
@@ -8,7 +8,7 @@
  org.eclipse.gmf.common.codegen,
  org.eclipse.gmf.internal.codegen.dispatch;x-friends:="org.eclipse.gmf.codegen,org.eclipse.gmf.graphdef.codegen,org.eclipse.gmf.codegen.lite",
  org.eclipse.gmf.internal.common;x-friends:="org.eclipse.gmf.codegen.edit,org.eclipse.gmf.graphdef.edit,org.eclipse.gmf.map.edit,org.eclipse.gmf.tooldef.edit,org.eclipse.gmf.bridge.trace,org.eclipse.gmf.bridge.ui,org.eclipse.gmf.bridge,org.eclipse.gmf.tests,org.eclipse.gmf.bridge.ui.dashboard,org.eclipse.gmf.codegen.ui,org.eclipse.gmf.codegen.lite.ui,org.eclipse.gmf.codegen,org.eclipse.gmf.map,org.eclipse.gmf.graphdef,org.eclipse.gmf.tooldef",
- org.eclipse.gmf.internal.common.codegen;x-friends:="org.eclipse.gmf.codegen,org.eclipse.gmf.graphdef.codegen,org.eclipse.gmf.bridge,org.eclipse.gmf.codegen.lite,org.eclipse.gmf.tests,org.eclipse.gmf.codegen.ui,org.eclipse.gmf.codegen.lite.ui,org.eclipse.gmf.tests.lite,org.eclipse.gmf.graphdef.codegen.ui,org.eclipse.gmf.codegen.xtend.ui",
+ org.eclipse.gmf.internal.common.codegen;x-friends:="org.eclipse.gmf.codegen,org.eclipse.gmf.graphdef.codegen,org.eclipse.gmf.bridge,org.eclipse.gmf.codegen.lite,org.eclipse.gmf.tests,org.eclipse.gmf.codegen.ui,org.eclipse.gmf.codegen.lite.ui,org.eclipse.gmf.tests.lite,org.eclipse.gmf.graphdef.codegen.ui,org.eclipse.gmf.codegen.xtend.ui, org.eclipse.gmf.tooling.codegen.launcher",
  org.eclipse.gmf.internal.common.migrate;x-friends:="org.eclipse.gmf.codegen.ui,org.eclipse.gmf.tests,org.eclipse.gmf.codegen,org.eclipse.gmf.map,org.eclipse.gmf.bridge.ui,org.eclipse.gmf.graphdef",
  org.eclipse.gmf.internal.common.reconcile;x-friends:="org.eclipse.gmf.tests,org.eclipse.gmf.codegen,org.eclipse.gmf.bridge.ui",
  org.eclipse.gmf.internal.common.ui
diff --git a/plugins/org.eclipse.gmf.common/src/org/eclipse/gmf/internal/common/codegen/CodeFormatterFactory.java b/plugins/org.eclipse.gmf.common/src/org/eclipse/gmf/internal/common/codegen/CodeFormatterFactory.java
new file mode 100644
index 0000000..6551cb9
--- /dev/null
+++ b/plugins/org.eclipse.gmf.common/src/org/eclipse/gmf/internal/common/codegen/CodeFormatterFactory.java
@@ -0,0 +1,19 @@
+package org.eclipse.gmf.internal.common.codegen;
+
+import org.eclipse.jdt.core.ToolFactory;
+import org.eclipse.jdt.core.formatter.CodeFormatter;
+
+public interface CodeFormatterFactory {
+
+	public final CodeFormatterFactory DEFAULT = new NullFormatterFactory();
+
+	public CodeFormatter createCodeFormatter();
+
+	static class NullFormatterFactory implements CodeFormatterFactory {
+
+		public CodeFormatter createCodeFormatter() {
+			return ToolFactory.createCodeFormatter(null);
+		}
+	}
+
+}
diff --git a/plugins/org.eclipse.gmf.common/src/org/eclipse/gmf/internal/common/codegen/GeneratorBase.java b/plugins/org.eclipse.gmf.common/src/org/eclipse/gmf/internal/common/codegen/GeneratorBase.java
index 9c27136..bf3bb5a 100644
--- a/plugins/org.eclipse.gmf.common/src/org/eclipse/gmf/internal/common/codegen/GeneratorBase.java
+++ b/plugins/org.eclipse.gmf.common/src/org/eclipse/gmf/internal/common/codegen/GeneratorBase.java
@@ -52,7 +52,6 @@
 import org.eclipse.jdt.core.IPackageFragmentRoot;
 import org.eclipse.jdt.core.JavaCore;
 import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.ToolFactory;
 import org.eclipse.jdt.core.formatter.CodeFormatter;
 import org.eclipse.jface.text.Document;
 import org.eclipse.jface.text.IDocument;
@@ -66,6 +65,8 @@
 
 	private CodeFormatter myCodeFormatter;
 
+	private final CodeFormatterFactory myCodeFormatterFactory;
+
 	private OrganizeImportsPostprocessor myImportsPostprocessor;
 
 	private IProgressMonitor myProgress = new NullProgressMonitor();
@@ -88,6 +89,11 @@
 	protected abstract void setupProgressMonitor();
 
 	public GeneratorBase() {
+		this(CodeFormatterFactory.DEFAULT);
+	}
+
+	public GeneratorBase(CodeFormatterFactory codeFormatterFactory) {
+		myCodeFormatterFactory = codeFormatterFactory;
 		myExceptions = new LinkedList<IStatus>();
 	}
 
@@ -529,7 +535,7 @@
 
 	private CodeFormatter getCodeFormatter() {
 		if (myCodeFormatter == null) {
-			myCodeFormatter = ToolFactory.createCodeFormatter(null);
+			myCodeFormatter = myCodeFormatterFactory.createCodeFormatter();
 		}
 		return myCodeFormatter;
 	}
diff --git a/plugins/org.eclipse.gmf.tooling.codegen.launcher/.classpath b/plugins/org.eclipse.gmf.tooling.codegen.launcher/.classpath
new file mode 100644
index 0000000..ad32c83
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.codegen.launcher/.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/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.gmf.tooling.codegen.launcher/.gitignore b/plugins/org.eclipse.gmf.tooling.codegen.launcher/.gitignore
new file mode 100644
index 0000000..e7bff1c
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.codegen.launcher/.gitignore
@@ -0,0 +1 @@
+/bin

diff --git a/plugins/org.eclipse.gmf.tooling.codegen.launcher/.project b/plugins/org.eclipse.gmf.tooling.codegen.launcher/.project
new file mode 100644
index 0000000..4850a6d
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.codegen.launcher/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.eclipse.gmf.tooling.codegen.launcher</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>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.gmf.tooling.codegen.launcher/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.gmf.tooling.codegen.launcher/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..c537b63
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.codegen.launcher/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/plugins/org.eclipse.gmf.tooling.codegen.launcher/META-INF/MANIFEST.MF b/plugins/org.eclipse.gmf.tooling.codegen.launcher/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..f740d99
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.codegen.launcher/META-INF/MANIFEST.MF
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.gmf.tooling.codegen.launcher;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: %providerName
+Bundle-Activator: org.eclipse.gmf.tooling.codegen.launcher.Activator
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.ui.workbench,
+ org.eclipse.pde.launching,
+ org.eclipse.debug.core,
+ org.eclipse.gmf.common,
+ org.eclipse.gmf.codegen,
+ org.eclipse.jdt.core,
+ org.eclipse.gmf.codegen.xtend.ui
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
+
diff --git a/plugins/org.eclipse.gmf.tooling.codegen.launcher/about.html b/plugins/org.eclipse.gmf.tooling.codegen.launcher/about.html
new file mode 100644
index 0000000..968a06f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.codegen.launcher/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

+<html xmlns="http://www.w3.org/1999/xhtml">

+<head>

+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>

+<title>About</title>

+</head>

+<body lang="EN-US">

+<h2>About This Content</h2>

+ 

+<p>June 5, 2007</p>	

+<h3>License</h3>

+

+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;).  Unless otherwise 

+indicated below, the Content is provided to you under the terms and conditions of the

+Eclipse Public License Version 1.0 (&quot;EPL&quot;).  A copy of the EPL is available 

+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.

+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>

+

+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 

+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may

+apply to your use of any object code in the Content.  Check the Redistributor's license that was 

+provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise

+indicated below, the terms and conditions of the EPL still apply to any source code in the Content

+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>

+

+</body>

+</html>
\ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.tooling.codegen.launcher/build.properties b/plugins/org.eclipse.gmf.tooling.codegen.launcher/build.properties
new file mode 100644
index 0000000..30b2fc4
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.codegen.launcher/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.properties,\
+               plugin.xml
diff --git a/plugins/org.eclipse.gmf.tooling.codegen.launcher/plugin.properties b/plugins/org.eclipse.gmf.tooling.codegen.launcher/plugin.properties
new file mode 100644
index 0000000..52207d4
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.codegen.launcher/plugin.properties
@@ -0,0 +1,12 @@
+###############################################################################
+# Copyright (c) 2013 Montages AG, 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:
+#     Montages AG - initial API and implementation
+###############################################################################
+pluginName=GMF Tooling Generation via Eclipse Application
+providerName=Eclipse Modeling Project
\ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.tooling.codegen.launcher/plugin.xml b/plugins/org.eclipse.gmf.tooling.codegen.launcher/plugin.xml
new file mode 100644
index 0000000..73fc80d
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.codegen.launcher/plugin.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+	<extension point="org.eclipse.core.runtime.applications" id="GMFGenerateApplication"> 
+		<application visible="true"> 
+			<run class="org.eclipse.gmf.tooling.codegen.launcher.GMFGenerateApplication">
+			</run>
+		</application>
+	</extension>
+</plugin>
diff --git a/plugins/org.eclipse.gmf.tooling.codegen.launcher/pom.xml b/plugins/org.eclipse.gmf.tooling.codegen.launcher/pom.xml
new file mode 100644
index 0000000..ff0beb4
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.codegen.launcher/pom.xml
@@ -0,0 +1,42 @@
+<!--
+ * Copyright (c) 2012 Montages AG
+ *  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
+ *  
+-->
+<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.eclipse.gmf-tooling.plugins</groupId>
+	<artifactId>org.eclipse.gmf.tooling.codegen.launcher</artifactId>
+	<version>1.0.0-SNAPSHOT</version>
+	<packaging>eclipse-plugin</packaging>
+
+	<parent>
+		<groupId>org.eclipse.gmf-tooling</groupId>
+		<artifactId>plugins</artifactId>
+		<version>3.0.0-SNAPSHOT</version>
+		<relativePath>../</relativePath>
+	</parent>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.eclipse.tycho</groupId>
+				<artifactId>tycho-source-plugin</artifactId>
+				<version>${tycho-version}</version>
+				<executions>
+					<execution>
+						<id>attach-source</id>
+						<goals>
+							<goal>plugin-source</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+
+</project>
\ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/Activator.java b/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/Activator.java
new file mode 100644
index 0000000..9ea6b65
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/Activator.java
@@ -0,0 +1,62 @@
+package org.eclipse.gmf.tooling.codegen.launcher;

+

+import org.eclipse.core.runtime.IStatus;

+import org.eclipse.core.runtime.Status;

+import org.eclipse.ui.plugin.AbstractUIPlugin;

+import org.osgi.framework.BundleContext;

+

+/**

+ * The activator class controls the plug-in life cycle

+ */

+public class Activator extends AbstractUIPlugin {

+

+	// The plug-in ID

+	public static final String PLUGIN_ID = "org.eclipse.gmf.tooling.launcher"; //$NON-NLS-1$

+

+	// The shared instance

+	private static Activator plugin;

+

+	private static BundleContext myBundleContext;

+	/**

+	 * The constructor

+	 */

+	public Activator() {

+	}

+

+	/*

+	 * (non-Javadoc)

+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)

+	 */

+	public void start(BundleContext context) throws Exception {

+		super.start(context);

+		plugin = this;

+		myBundleContext = context;

+	}

+

+	/*

+	 * (non-Javadoc)

+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)

+	 */

+	public void stop(BundleContext context) throws Exception {

+		myBundleContext = null;

+		plugin = null;

+		super.stop(context);

+	}

+

+	/**

+	 * Returns the shared instance

+	 *

+	 * @return the shared instance

+	 */

+	public static Activator getDefault() {

+		return plugin;

+	}

+

+	public static BundleContext getContext() {

+		return myBundleContext;

+	}

+

+	public void error(Exception e) {

+		getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, null, e));

+	}

+}

diff --git a/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/ArgumentsParser.java b/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/ArgumentsParser.java
new file mode 100644
index 0000000..d51ad17
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/ArgumentsParser.java
@@ -0,0 +1,158 @@
+package org.eclipse.gmf.tooling.codegen.launcher;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.rmi.UnexpectedException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.equinox.app.IApplicationContext;
+
+
+public class ArgumentsParser {
+
+	private String myGMFProjectLocation, myResourceLocation, myGenerateProject, myFormatter, myCustomEmitter, myCustomEmitterBundleName;
+
+	private List<String> myRelatedProjects;
+
+	private boolean myShouldUseConsole;
+
+	public String getGMFGENProjectLocation() {
+		return myGMFProjectLocation;
+	}
+
+	public String getGMFGENResourceLocation() {
+		return myResourceLocation;
+	}
+
+	public String getGenerateProjectLocation() {
+		return myGenerateProject;
+	}
+
+	public List<String> getRelatedProjects() {
+		return myRelatedProjects;
+	}
+
+	public String getFormatter() {
+		return myFormatter;
+	}
+
+	public boolean shouldTrace() {
+		return myShouldUseConsole;
+	}
+
+	public String getCustomEmitterClassName() {
+		return myCustomEmitter;
+	}
+
+	public String getCustomEmitterBundleName() {
+		return myCustomEmitterBundleName;
+	}
+
+	public ArgumentsParser(IApplicationContext context) throws UnexpectedException {
+		parsArguments(context);
+	}
+
+	private void parsArguments(IApplicationContext context) throws UnexpectedException {
+		String[] args = (String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS);
+		if (args != null) {
+			List<String> argList = Arrays.asList(args);
+
+			String generationProperties = getPathValueFromArgs(argList, GMFLauncherConstants.KEY_GENERATION_PROPERTIES);
+			Properties prop = new Properties();
+			InputStream input = null;
+
+			try {
+				File propertiesFile = new File(generationProperties);
+				input = new FileInputStream(propertiesFile);
+
+				prop.load(input);
+
+
+			} catch (IOException ex) {
+				throw new RuntimeException(ex);
+			} finally {
+				if (input != null) {
+					try {
+						input.close();
+					} catch (IOException e) {
+						throw new RuntimeException(e);
+					}
+				}
+			}
+
+			myRelatedProjects = getRelatedProjects(prop);
+			myGMFProjectLocation = getRequiredPathValueFromParoperties(prop, GMFLauncherConstants.PROPERTY_GMFGEN_PROJECT_LOCATION);
+			myResourceLocation = getRequiredPathValueFromParoperties(prop, GMFLauncherConstants.PROPERTY_GMFGEN_MODEL);
+			myGenerateProject = getRequiredPathValueFromParoperties(prop, GMFLauncherConstants.PROPERTY_GENERATE_PROJECT_LOCATION);
+			myFormatter = getPathValueFromParoperties(prop, GMFLauncherConstants.PROPERTY_FORMATTER, false);
+			myShouldUseConsole = getBooleanValue(prop,GMFLauncherConstants.PROPERTY_TRACE);
+			myCustomEmitter = prop.getProperty(GMFLauncherConstants.PROPERTY_CUSTOM_EMITTER, null);
+			myCustomEmitterBundleName = prop.getProperty(GMFLauncherConstants.PROPERTY_CUSTOM_EMITTER_BUNDLE, null);
+		}
+	}
+
+	private String getPathValueFromArgs(List<String> argList, String key) throws UnexpectedException {
+		for (Iterator<String> it = argList.iterator(); it.hasNext();) {
+			String arg = it.next();
+			if (!arg.equals(key)) {
+				continue;
+			}
+			if (!it.hasNext()) {
+				throw new UnexpectedException("Value for key:" + key + " is not setted");
+			}
+			String value = it.next();
+			if (isKey(value)) {
+				throw new UnexpectedException("Value for key:" + key + " is not setted");
+			}
+			if (false == new Path(value).isValidPath(value)) {
+				throw new UnexpectedException("Value:" + value + " for key:" + key + " is not path");
+			}
+			return value;
+		}
+		throw new UnexpectedException("Key " + key + " is not setted");
+	}
+
+	private String getRequiredPathValueFromParoperties(Properties props, String key) throws UnexpectedException {
+		return getPathValueFromParoperties(props, key, true);
+	}
+
+	private String getPathValueFromParoperties(Properties props, String key, boolean required) throws UnexpectedException {
+		String value = props.getProperty(key);
+		if (value == null || value.isEmpty()) {
+			if (required) {
+				throw new UnexpectedException("Value:" + value + " for property:" + key + " is not path");
+			} else {
+				return null;
+			}
+		}
+		if (false == new Path(value).isValidPath(value)) {
+			throw new UnexpectedException("Value:" + value + " for property:" + key + " is not path");
+		}
+		return value;
+	}
+	
+	private List<String> getRelatedProjects(Properties props) throws UnexpectedException {
+		String value = props.getProperty(GMFLauncherConstants.PROPERTY_RELATED_PROJECTS);
+		if (value == null || value.isEmpty()) {
+			return Collections.emptyList();
+		}
+		String[] relatedProjects = value.split(",");
+		return Arrays.asList(relatedProjects);
+	}
+
+	private boolean getBooleanValue(Properties props, String key) {
+		String value = props.getProperty(key);
+		return Boolean.parseBoolean(value);
+	}
+
+	private boolean isKey(String value) {
+		return value != null && value.startsWith("-");
+	}
+}
diff --git a/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/GMFGenerateApplication.java b/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/GMFGenerateApplication.java
new file mode 100644
index 0000000..793a4d2
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/GMFGenerateApplication.java
@@ -0,0 +1,130 @@
+package org.eclipse.gmf.tooling.codegen.launcher;
+
+import java.lang.reflect.Constructor;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.equinox.app.IApplication;
+import org.eclipse.equinox.app.IApplicationContext;
+import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
+import org.eclipse.gmf.codegen.xtend.ui.handlers.CodegenEmittersWithXtend2;
+import org.eclipse.gmf.codegen.xtend.ui.handlers.GeneratorWithXtend2;
+import org.eclipse.gmf.internal.common.codegen.CodeFormatterFactory;
+import org.eclipse.gmf.internal.common.codegen.GeneratorBase;
+import org.eclipse.gmf.tooling.codegen.launcher.utils.GMFGeneratorUtil;
+import org.eclipse.gmf.tooling.codegen.launcher.utils.SerializedCodeFormatterFactory;
+import org.eclipse.gmf.tooling.codegen.launcher.utils.WorkspaceHelper;
+import org.osgi.framework.Bundle;
+
+public class GMFGenerateApplication implements IApplication {
+
+	private WorkspaceHelper myWorkspaceHelper;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
+	 */
+	@Override
+	public Object start(IApplicationContext context) throws Exception {
+		myWorkspaceHelper = new WorkspaceHelper();
+		ArgumentsParser runnerArguments = null;
+		try {
+			runnerArguments = new ArgumentsParser(context);
+
+			List<String> projectsToImport = new LinkedList<String>(runnerArguments.getRelatedProjects());
+			projectsToImport.add(runnerArguments.getGMFGENProjectLocation());
+			initWorkspace(projectsToImport);
+
+			GenEditorGenerator editorGen = GMFGeneratorUtil.loadEditorGen(runnerArguments.getGMFGENProjectLocation(), runnerArguments.getGMFGENResourceLocation());
+
+			initPluginProject(runnerArguments.getGenerateProjectLocation(), editorGen.getPluginDirectory());
+
+			CodegenEmittersWithXtend2 emitters = getCodegenEmitters(editorGen, runnerArguments.getCustomEmitterBundleName(), runnerArguments.getCustomEmitterClassName());
+			CodeFormatterFactory codeFormatterFactory = loadFormatter(runnerArguments.getFormatter());
+
+			GeneratorBase generator = new GeneratorWithXtend2(editorGen, emitters, codeFormatterFactory);
+
+			generator.run(new NullProgressMonitor());
+		} catch (Exception e) {
+			Activator.getDefault().error(e);
+			if (runnerArguments != null && runnerArguments.shouldTrace()) {
+				e.printStackTrace();
+			}
+			throw e;
+		}
+		return IApplicationContext.EXIT_ASYNC_RESULT;
+	}
+
+	private void initPluginProject(String filesystemLocation, String gmfgenPluginDirectory) throws CoreException {
+		String pluginProjectName = new Path(gmfgenPluginDirectory).segment(0);
+		IPath location = new Path(filesystemLocation);
+		if (!location.lastSegment().equals(pluginProjectName)) {
+			location.append(pluginProjectName);
+		}
+
+		myWorkspaceHelper.createProject(pluginProjectName, location);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.equinox.app.IApplication#stop(org.eclipse.equinox.app.IApplicationContext)
+	 */
+	@Override
+	public void stop() {
+		myWorkspaceHelper = null;
+	}
+
+	protected void initWorkspace(List<String> projects) throws CoreException {
+		myWorkspaceHelper.clearWorkspace();
+
+		for (String path : projects) {
+			myWorkspaceHelper.importProject(path);
+		}
+	}
+
+	@SuppressWarnings("unchecked")
+	protected CodegenEmittersWithXtend2 getCodegenEmitters(GenEditorGenerator editorGen, String bundleName, String className) {
+		CodegenEmittersWithXtend2 emitters = null;
+
+		if (className != null && bundleName != null) {
+			Bundle bundle = Platform.getBundle(bundleName);
+			Class<? extends CodegenEmittersWithXtend2> customEmittersClass;
+			try {
+				customEmittersClass = (Class<? extends CodegenEmittersWithXtend2>) bundle.loadClass(className);
+			} catch (ClassNotFoundException e) {
+				throw new RuntimeException("Custom emitter not found. "
+						+ "Class: " + className + ". "
+						+ "Bundle:" + bundleName, e);
+			}
+			Constructor<? extends CodegenEmittersWithXtend2> constructor;
+			try {
+				constructor = customEmittersClass.getConstructor(GenEditorGenerator.class);
+			} catch (Exception e) {
+				throw new RuntimeException("Constructor with" + GenEditorGenerator.class.getCanonicalName() + " parameter not found", e);
+			}
+
+			try {
+				emitters = (CodegenEmittersWithXtend2) constructor.newInstance(editorGen);
+			} catch (Exception e) {
+				throw new RuntimeException("Cannot create instance of" + className, e);
+			}
+		} else {
+			emitters = new CodegenEmittersWithXtend2(editorGen);
+		}
+		return emitters;
+	}
+
+	private CodeFormatterFactory loadFormatter(String path) {
+		if (path != null) {
+			return new SerializedCodeFormatterFactory(path);
+		}
+		return CodeFormatterFactory.DEFAULT;
+	}
+}
diff --git a/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/GMFLauncherConstants.java b/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/GMFLauncherConstants.java
new file mode 100644
index 0000000..b429cb1
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/GMFLauncherConstants.java
@@ -0,0 +1,23 @@
+package org.eclipse.gmf.tooling.codegen.launcher;
+
+
+public interface GMFLauncherConstants {
+
+	public static final String PROPERTY_GMFGEN_MODEL = "gmfgenModel"; //$NON-NLS-1$
+
+	public static final String PROPERTY_GMFGEN_PROJECT_LOCATION = "gmfgenProjectLocation"; //$NON-NLS-1$
+
+	public static final String PROPERTY_GENERATE_PROJECT_LOCATION = "generatedProjectLocation"; //$NON-NLS-1$
+
+	public static final String PROPERTY_RELATED_PROJECTS = "relatedProjects"; //$NON-NLS-1$
+
+	public static final String PROPERTY_CUSTOM_EMITTER = "customEmitter"; //$NON-NLS-1$
+
+	public static final String PROPERTY_CUSTOM_EMITTER_BUNDLE = "customEmitterBundle"; //$NON-NLS-1$
+
+	public static final String PROPERTY_FORMATTER = "formatter"; //$NON-NLS-1$
+
+	public static final String PROPERTY_TRACE = "trace"; //$NON-NLS-1$
+
+	public static final String KEY_GENERATION_PROPERTIES = "-generationProperties"; //$NON-NLS-1$
+}
diff --git a/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/utils/GMFGeneratorUtil.java b/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/utils/GMFGeneratorUtil.java
new file mode 100644
index 0000000..6db40c9
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/utils/GMFGeneratorUtil.java
@@ -0,0 +1,47 @@
+package org.eclipse.gmf.tooling.codegen.launcher.utils;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
+
+/**
+ * code copied from Generator
+ */
+public class GMFGeneratorUtil {
+
+	public static final String SEPARATOR = File.separator;
+
+	public static GenEditorGenerator loadEditorGen(String projectLocation, String gmfgenLocation) {
+		IPath gmfgenProjectPath = new Path(projectLocation);
+		String gmfgenProjectName = gmfgenProjectPath.lastSegment();
+
+		StringBuilder uri = new StringBuilder(SEPARATOR);
+		uri.append(gmfgenProjectName);
+		if (!gmfgenLocation.startsWith(SEPARATOR)) {
+			uri.append(SEPARATOR);
+		}
+		uri.append(gmfgenLocation);
+
+		URI gmfgenFileURI = URI.createPlatformResourceURI(uri.toString(), true);
+		return GMFGeneratorUtil.loadEditorGen(gmfgenFileURI);
+	}
+
+	public static GenEditorGenerator loadEditorGen(org.eclipse.emf.common.util.URI u) {
+		GenEditorGenerator result = null;
+		ResourceSet rs = new ResourceSetImpl();
+		Resource r = rs.getResource(u, true);
+		for (Object o: r.getContents()) {
+			if (o instanceof GenEditorGenerator) {
+				result = (GenEditorGenerator)o;
+				break;
+			}
+		}
+		return result;
+	}
+}
diff --git a/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/utils/SerializedCodeFormatterFactory.java b/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/utils/SerializedCodeFormatterFactory.java
new file mode 100644
index 0000000..bff5a0f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/utils/SerializedCodeFormatterFactory.java
@@ -0,0 +1,199 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation 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:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.gmf.tooling.codegen.launcher.utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.gmf.internal.common.codegen.CodeFormatterFactory;
+import org.eclipse.gmf.tooling.codegen.launcher.Activator;
+import org.eclipse.jdt.core.ToolFactory;
+import org.eclipse.jdt.core.formatter.CodeFormatter;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * org.eclipse.jdt.internal.ui.preferences.formatter.ProfileStore
+ */
+public class SerializedCodeFormatterFactory implements CodeFormatterFactory {
+
+	private final String myCodeFormatterPath;
+
+	public SerializedCodeFormatterFactory(String codeFormatterPath) {
+		myCodeFormatterPath = codeFormatterPath;
+	}
+
+	@Override
+	public CodeFormatter createCodeFormatter() {
+		File formatter = new File(myCodeFormatterPath);
+		Map<String, String> options;
+		Collection<SerializedCodeFormatterFactory.Profile> profiles = null;
+		try {
+			profiles = readProfilesFromFile(formatter);
+			options = profiles.iterator().next().getSettings();
+		} catch (CoreException e) {
+			throw new RuntimeException("Error has occured while loading formatter. "
+					+ "Formatter file path: " + myCodeFormatterPath);
+		}
+		return ToolFactory.createCodeFormatter(options);
+	}
+
+	public List<Profile> readProfilesFromFile(File file) throws CoreException {
+		try {
+			final FileInputStream reader = new FileInputStream(file);
+			try {
+				return readProfilesFromStream(new InputSource(reader));
+			} finally {
+				try {
+					reader.close();
+				} catch (IOException e) {
+				}
+			}
+		} catch (IOException e) {
+			throw createException(e.getMessage());
+		}
+	}
+
+	public static List<Profile> readProfilesFromStream(InputSource inputSource) throws CoreException {
+
+		final ProfileDefaultHandler handler = new ProfileDefaultHandler();
+		try {
+			final SAXParserFactory factory = SAXParserFactory.newInstance();
+			final SAXParser parser = factory.newSAXParser();
+			parser.parse(inputSource, handler);
+		} catch (SAXException e) {
+			throw createException(e.getMessage());
+		} catch (IOException e) {
+			throw createException(e.getMessage());
+		} catch (ParserConfigurationException e) {
+			throw createException(e.getMessage());
+		}
+		return handler.getProfiles();
+	}
+
+	private static CoreException createException(String message) {
+		return new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, message));
+	}
+
+	public final static class Profile {
+
+		private final String myName;
+
+		private final Map<String, String> mySettings;
+
+		private final int myVersion;
+
+		private final String myKind;
+
+		public Profile(String name, int version, String kind, Map<String, String> settings) {
+			myName = name;
+			mySettings = settings;
+			myVersion = version;
+			myKind = kind;
+		}
+
+		public Map<String, String> getSettings() {
+			return mySettings;
+		}
+
+		public String getName() {
+			return myName;
+		}
+
+		public int getVerstion() {
+			return myVersion;
+		}
+
+		public String getKind() {
+			return myKind;
+		}
+	}
+
+	private final static class ProfileDefaultHandler extends DefaultHandler {
+
+		private final static String XML_NODE_ROOT = "profiles";
+		private final static String XML_NODE_PROFILE = "profile";
+		private final static String XML_NODE_SETTING = "setting";
+
+		private final static String XML_ATTRIBUTE_VERSION = "version";
+		private final static String XML_ATTRIBUTE_ID = "id";
+		private final static String XML_ATTRIBUTE_NAME = "name";
+		private final static String XML_ATTRIBUTE_PROFILE_KIND = "kind";
+		private final static String XML_ATTRIBUTE_VALUE = "value";
+
+
+		private List<Profile> fProfiles;
+		private int fVersion;
+
+		private String fName;
+		private Map<String, String> fSettings;
+		private String fKind;
+
+		@Override
+		public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+
+			if (qName.equals(XML_NODE_SETTING)) {
+
+				final String key = attributes.getValue(XML_ATTRIBUTE_ID);
+				final String value = attributes.getValue(XML_ATTRIBUTE_VALUE);
+				fSettings.put(key, value);
+
+			} else if (qName.equals(XML_NODE_PROFILE)) {
+
+				fName = attributes.getValue(XML_ATTRIBUTE_NAME);
+				fKind = attributes.getValue(XML_ATTRIBUTE_PROFILE_KIND);
+
+				fSettings = new HashMap<String, String>(200);
+
+			} else if (qName.equals(XML_NODE_ROOT)) {
+
+				fProfiles = new ArrayList<Profile>();
+				try {
+					fVersion = Integer.parseInt(attributes.getValue(XML_ATTRIBUTE_VERSION));
+				} catch (NumberFormatException ex) {
+					throw new SAXException(ex);
+				}
+
+			}
+		}
+
+		@Override
+		public void endElement(String uri, String localName, String qName) {
+			if (qName.equals(XML_NODE_PROFILE)) {
+				fProfiles.add(new Profile(fName, fVersion, fKind, fSettings));
+				fName = null;
+				fSettings = null;
+				fKind = null;
+			}
+		}
+
+		public List<Profile> getProfiles() {
+			return fProfiles;
+		}
+
+	}
+}
diff --git a/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/utils/WorkspaceHelper.java b/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/utils/WorkspaceHelper.java
new file mode 100644
index 0000000..dc6d73a
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.codegen.launcher/src/org/eclipse/gmf/tooling/codegen/launcher/utils/WorkspaceHelper.java
@@ -0,0 +1,110 @@
+package org.eclipse.gmf.tooling.codegen.launcher.utils;
+
+import java.io.File;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.gmf.tooling.codegen.launcher.Activator;
+
+public class WorkspaceHelper {
+
+	public void initWorkspace(String gmfgenProject, List<String> relatedProjects) throws CoreException {
+		clearWorkspace();
+
+		for (String path : relatedProjects) {
+			importProject(path);
+		}
+
+		importProject(gmfgenProject);
+	}
+
+	public void clearWorkspace() throws CoreException {
+		boolean deleteContent = false;
+		boolean forceDelete = true;
+		NullProgressMonitor monitor = new NullProgressMonitor();
+
+		getRoot().refreshLocal(0, monitor);
+
+		for (IProject project: getRoot().getProjects()) {
+			project.delete(deleteContent, forceDelete, monitor);
+		}
+	}
+
+	public IProject createProject(String name, IPath location) throws CoreException {
+		NullProgressMonitor monitor = new NullProgressMonitor();
+
+		IProject project = getRoot().getProject(name);
+		IProjectDescription descr = getWorkspace().newProjectDescription(name);
+
+		if (location != null) {
+			descr.setLocation(location);
+		}
+
+		if (!project.exists()) {
+			project.create(descr, monitor);
+		}
+		if (!project.isOpen()) {
+			project.open(monitor);
+		}
+		return project;
+	}
+
+	
+	public IProject importProject(String path) throws CoreException {
+		Path location = new Path(path);
+		String name = location.lastSegment();
+		return importProject(name, location);
+	}
+
+	public IProject importProject(String name, IPath location) throws CoreException {
+		File projectPath = location.toFile();
+		if (!projectPath.exists() || !projectPath.isDirectory()) {
+			throw createCoreException("Cannot import project. Location don't exist or it is not directory.");
+		}
+		boolean projectFileExist = false;
+		for(String file: projectPath.list()) {
+			if (".project".equals(file)) {
+				projectFileExist = true;
+				break;
+			}
+		}
+		if (!projectFileExist) {
+			throw createCoreException("Directory is not an eclipse project");
+		}
+
+		IProject project = getRoot().getProject(name);
+		if (project.exists()) {
+			if (!project.getLocation().equals(location)) {
+				throw createCoreException("Workspace contain project with same name but different location");
+			}
+			if (!project.isOpen()) {
+				project.open(new NullProgressMonitor());
+			}
+			return project;
+		}
+
+		return createProject(name, location);
+	}
+
+	private IWorkspaceRoot getRoot() {
+		return getWorkspace().getRoot();
+	}
+
+	private IWorkspace getWorkspace() {
+		return ResourcesPlugin.getWorkspace();
+	}
+
+	private static CoreException createCoreException(String message) {
+		return new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, message));
+	}
+}
diff --git a/plugins/pom.xml b/plugins/pom.xml
index 9d2d1c7..a55680f 100644
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -60,6 +60,7 @@
 		<module>org.eclipse.gmf.xpand.migration</module>
 		<module>org.eclipse.gmf.xpand.qvtlibrary</module>
 
+		<module>org.eclipse.gmf.tooling.codegen.launcher</module>
 		<module>org.eclipse.gmf.tooling.runtime</module>
 		
 		<module>org.eclipse.gmf.tooling.simplemap.bridge.ui</module>
diff --git a/pom.xml b/pom.xml
index 023c722..35bb109 100644
--- a/pom.xml
+++ b/pom.xml
@@ -240,4 +240,12 @@
         </pluginRepository>
     </pluginRepositories>
 
+	<repositories>
+				<repository>
+			<id>tmf-xtext</id>
+			<layout>p2</layout>
+			<!-- updateFrom("Xtext, Xtend",0) -->
+			<url>http://download.eclipse.org/modeling/tmf/xtext/updates/milestones/head/I201509281643/</url>
+		</repository>
+	</repositories>
 </project>