Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2015-07-23 13:04:39 +0000
committerTom Schindl2015-07-23 13:04:39 +0000
commit838f71e604249bc127f3088d397b5e375c2d13e3 (patch)
tree15d31ae8f1b84131bf3156e623cc1c434c99ea80 /releng/cmdtools
parent3e2d87bc2f1d41ea983d5d77344ffb001091ee22 (diff)
downloadorg.eclipse.efxclipse-838f71e604249bc127f3088d397b5e375c2d13e3.tar.gz
org.eclipse.efxclipse-838f71e604249bc127f3088d397b5e375c2d13e3.tar.xz
org.eclipse.efxclipse-838f71e604249bc127f3088d397b5e375c2d13e3.zip
add bnd project to export ldef generator as standalone app
Diffstat (limited to 'releng/cmdtools')
-rw-r--r--releng/cmdtools/org.eclipse.fx.code.editor.ldef.app/bnd.bnd14
-rw-r--r--releng/cmdtools/org.eclipse.fx.code.editor.ldef.app/ldef.bndrun43
-rw-r--r--releng/cmdtools/org.eclipse.fx.code.editor.ldef.app/src/.gitignore0
-rw-r--r--releng/cmdtools/org.eclipse.fx.code.editor.ldef.app/src/org/eclipse/fx/code/editor/ldef/app/Main.java100
4 files changed, 157 insertions, 0 deletions
diff --git a/releng/cmdtools/org.eclipse.fx.code.editor.ldef.app/bnd.bnd b/releng/cmdtools/org.eclipse.fx.code.editor.ldef.app/bnd.bnd
new file mode 100644
index 000000000..6e8bcef54
--- /dev/null
+++ b/releng/cmdtools/org.eclipse.fx.code.editor.ldef.app/bnd.bnd
@@ -0,0 +1,14 @@
+Bundle-Version: 0.0.0.${tstamp}
+Service-Component: \
+ *
+-buildpath: \
+ biz.aQute.bnd.annotation,\
+ org.eclipse.fx.code.editor.ldef,\
+ com.google.inject,\
+ org.eclipse.emf.ecore,\
+ org.eclipse.emf.ecore.xmi,\
+ org.eclipse.emf.common,\
+ org.eclipse.xtext
+Private-Package: \
+ org.eclipse.fx.code.editor.ldef.app
+-runee: JavaSE-1.8
diff --git a/releng/cmdtools/org.eclipse.fx.code.editor.ldef.app/ldef.bndrun b/releng/cmdtools/org.eclipse.fx.code.editor.ldef.app/ldef.bndrun
new file mode 100644
index 000000000..7c56534af
--- /dev/null
+++ b/releng/cmdtools/org.eclipse.fx.code.editor.ldef.app/ldef.bndrun
@@ -0,0 +1,43 @@
+-runfw: org.eclipse.osgi;version='[3.7,4)'
+-runee: JavaSE-1.8
+-runsystemcapabilities: ${native_capability}
+
+-resolve.effective: active;skip:="osgi.service"
+
+-runbundles: \
+ ch.qos.logback.classic;version='[1.1.2,1.1.3)',\
+ ch.qos.logback.core;version='[1.1.2,1.1.3)',\
+ com.google.guava;version='[18.0.0,18.0.1)',\
+ com.google.inject;version='[3.0.0,3.0.1)',\
+ javax.inject;version='[1.0.0,1.0.1)',\
+ org.antlr.runtime;version='[3.2.0,3.2.1)',\
+ org.apache.felix.configadmin;version='[1.8.0,1.8.1)',\
+ org.apache.felix.gogo.command;version='[0.14.0,0.14.1)',\
+ org.apache.felix.gogo.runtime;version='[0.10.0,0.10.1)',\
+ org.apache.felix.gogo.runtime;version='[0.12.1,0.12.2)',\
+ org.apache.felix.gogo.shell;version='[0.10.0,0.10.1)',\
+ org.apache.felix.scr;version='[1.6.2,1.6.3)',\
+ org.eclipse.emf.common;version='[2.11.0,2.11.1)',\
+ org.eclipse.emf.ecore;version='[2.11.0,2.11.1)',\
+ org.eclipse.emf.ecore.xmi;version='[2.11.0,2.11.1)',\
+ org.eclipse.equinox.common;version='[3.7.0,3.7.1)',\
+ org.eclipse.equinox.ds;version='[1.4.300,1.4.301)',\
+ org.eclipse.equinox.util;version='[1.0.500,1.0.501)',\
+ org.eclipse.fx.code.editor.ldef;version='[2.1.0,2.1.1)',\
+ org.eclipse.fx.code.editor.ldef.app;version=latest,\
+ org.eclipse.osgi.services;version='[3.5.0,3.5.1)',\
+ org.eclipse.xtext;version='[2.8.3,2.8.4)',\
+ org.eclipse.xtext.common.types;version='[2.8.3,2.8.4)',\
+ org.eclipse.xtext.util;version='[2.8.3,2.8.4)',\
+ org.eclipse.xtext.xbase.lib;version='[2.8.3,2.8.4)',\
+ org.objectweb.asm;version='[5.0.1,5.0.2)',\
+ org.slf4j.log4j;version='[1.7.2,1.7.3)',\
+ osgi.cmpn;version='[5.0.0,5.0.1)',\
+ slf4j.api;version='[1.7.7,1.7.8)'
+
+-runrequires: \
+ osgi.identity;filter:='(osgi.identity=org.eclipse.equinox.ds)',\
+ osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)',\
+ osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)',\
+ osgi.identity;filter:='(&(osgi.identity=osgi.cmpn)(version>=4.2))',\
+ osgi.identity;filter:='(osgi.identity=org.eclipse.fx.code.editor.ldef.app)'
diff --git a/releng/cmdtools/org.eclipse.fx.code.editor.ldef.app/src/.gitignore b/releng/cmdtools/org.eclipse.fx.code.editor.ldef.app/src/.gitignore
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/releng/cmdtools/org.eclipse.fx.code.editor.ldef.app/src/.gitignore
diff --git a/releng/cmdtools/org.eclipse.fx.code.editor.ldef.app/src/org/eclipse/fx/code/editor/ldef/app/Main.java b/releng/cmdtools/org.eclipse.fx.code.editor.ldef.app/src/org/eclipse/fx/code/editor/ldef/app/Main.java
new file mode 100644
index 000000000..3005f26fa
--- /dev/null
+++ b/releng/cmdtools/org.eclipse.fx.code.editor.ldef.app/src/org/eclipse/fx/code/editor/ldef/app/Main.java
@@ -0,0 +1,100 @@
+package org.eclipse.fx.code.editor.ldef.app;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Map;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.fx.code.editor.ldef.LDefStandaloneSetup;
+import org.eclipse.fx.code.editor.ldef.generator.LDefGenerator;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.Provider;
+
+import aQute.bnd.annotation.component.Component;
+import aQute.bnd.annotation.component.Reference;
+
+@Component(properties = "main.thread=true")
+public class Main implements Runnable {
+ String[] args;
+
+ public void run() {
+ Injector injector = new LDefStandaloneSetup().createInjectorAndDoEMFRegistration();
+ GeneratorHelper generatorHelper = injector.getInstance(GeneratorHelper.class);
+
+ String definitionFile = "/Users/tomschindl/Documents/e-workspaces/codesample/at.bestsolution.sample.code/src/main/java/at/bestsolution/sample/code/dart.ldef";
+ String outDir = "/Users/tomschindl/Documents/e-workspaces/codesample/at.bestsolution.sample.code/src/main/java";
+
+ if( args.length > 0 ) {
+ definitionFile = args[0];
+ }
+
+ if( args.length > 1 ) {
+ outDir = args[1];
+ }
+
+ generatorHelper.generate(definitionFile,outDir);
+ }
+
+ @Reference(target = "(launcher.arguments=*)")
+ void setArgs(Object service, Map<String, Object> props) {
+ this.args = (String[]) props.get("launcher.arguments");
+ }
+
+ static class GeneratorHelper {
+ @Inject
+ private Provider<ResourceSet> resourceSetProvider;
+
+ @Inject
+ private LDefGenerator generator;
+
+ public void generate(String ldefFile, String outDir) {
+ Resource resource = resourceSetProvider.get().getResource(URI.createFileURI(ldefFile), true);
+ Path root = Paths.get(outDir);
+
+ generator.doGenerate(resource, new IFileSystemAccess() {
+
+ @Override
+ public void generateFile(String fileName, CharSequence contents) {
+ generateFile(fileName, null, contents);
+ }
+
+ @Override
+ public void generateFile(String fileName, String outputConfigurationName, CharSequence contents) {
+ Path path = root.resolve(fileName);
+ if( ! Files.exists(path.getParent()) ) {
+ try {
+ Files.createDirectories(path.getParent());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ try ( OutputStream stream = Files.newOutputStream(path); ) {
+ stream.write(contents.toString().getBytes());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public void deleteFile(String fileName) {
+ Path path = root.resolve(fileName);
+ try {
+ Files.deleteIfExists(path);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ });
+ }
+ }
+}

Back to the top