Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run Acceleo without eclipse editor #1

Open
matejsp opened this issue Dec 27, 2012 · 0 comments
Open

How to run Acceleo without eclipse editor #1

matejsp opened this issue Dec 27, 2012 · 0 comments

Comments

@matejsp
Copy link

matejsp commented Dec 27, 2012

Alternative solution for creating eCore model (without needing to start/restart another eclipse)

package org.eclipse.acceleo.module.droid.main;

import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.emf.common.util.BasicMonitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.Resource.Diagnostic;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.xtext.example.droid.DroidStandaloneSetup;
import org.xtext.example.droid.droid.Application;

import com.google.inject.Injector;

public class TestMe {

/**
 * @param args
 * @throws Exception 
 */
public static void main(String[] args) throws Exception {
    new org.eclipse.emf.mwe.utils.StandaloneSetup().setPlatformUri("../");
     Injector injector = new DroidStandaloneSetup().createInjectorAndDoEMFRegistration();
     XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
     resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
     Resource resource = resourceSet.createResource(URI.createURI("dummy:/example.droid"));
     InputStream in = TestMe.class.getResourceAsStream("test.droid");
     //InputStream in = new FileInputStream("test.droid"); //new ByteArrayInputStream("type foo type bar".getBytes());
     resource.load(in, resourceSet.getLoadOptions());

     for (Diagnostic diag : resource.getErrors()) {
         System.out.println(diag.getMessage());
     }

     Application model = (Application) resource.getContents().get(0);

     System.out.println(model.getName());


     List<String> arguments = new ArrayList<String>();


    Generate generator = new Generate(model, new File("src-gen"), arguments);

// for (int i = 2; i < args.length; i++) {
// generator.addPropertiesFile(args[i]);
// }

    generator.doGenerate(new BasicMonitor());
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant