Commit c7766f30 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

* exposed a setting that can be controlled from maven to set the correct projectContext, #164

parent 4aace8b7
Loading
Loading
Loading
Loading
Loading
+14 −7
Original line number Diff line number Diff line
@@ -19,8 +19,11 @@ import org.eclipse.ocl.pivot.utilities.OCL;
import org.eclipse.ocl.xtext.oclinecore.OCLinEcoreStandaloneSetup;

public class OCLinEcoreGenerator extends EcoreGeneratorCustom {
	private String projectRoot = "";

	@Override
	public void invoke(IWorkflowContext ctx) {
		System.out.println("Running on: "+projectRoot);
		//TODO: handle if unresolved?
		String codeGenJar = locateContainingJar(Generator.class);
    	EcorePlugin.ExtensionProcessor.process(null);
@@ -29,12 +32,8 @@ public class OCLinEcoreGenerator extends EcoreGeneratorCustom {
    		    URI.createURI(codeGenJar)
    	);        
        
    	File projectRoot = new File("").getAbsoluteFile();
    	//TODO: a bit of a hack when running from parent -> needs to be configured in maven directly.. 
    	if (projectRoot.getName().equals("org.etsi.mts.tdl.parent")) {
    		File pluginsRoot = projectRoot.getParentFile().listFiles(f->f.getName().equals("plugins"))[0];
    		projectRoot = pluginsRoot.listFiles(f->f.getName().equals("org.etsi.mts.tdl.model"))[0];
    	}
    	File projectRoot = new File(getProjectRoot()).getAbsoluteFile();

    	URIConverter.URI_MAP.put(
        		URI.createURI("platform:/resource/"+projectRoot.getName()+"/"), 
        		URI.createFileURI(projectRoot.getAbsolutePath() + File.separator)
@@ -78,5 +77,13 @@ public class OCLinEcoreGenerator extends EcoreGeneratorCustom {
        return null;
    }

	public String getProjectRoot() {
		return projectRoot;
	}

	public void setProjectRoot(String projectRoot) {
		this.projectRoot = projectRoot;
	}


}
+2 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ var rootPath = "platform:/resource/org.etsi.mts.tdl.model"
//var rootPath = "platform:/resource/" 
var rootPaths = "org.etsi.mts.tdl.model"
var srcGen = "src-gen" //this does not seem to matter... -> only for cleaning

var projectRoot = ""
Workflow {
	
	bean = org.eclipse.emf.mwe.utils.StandaloneSetup {
@@ -27,6 +27,7 @@ Workflow {
	    generateModel = true
	    generateEdit = false
	    generateEditor = false
	    projectRoot = "${projectRoot}"
	    genModel = "platform:/resource/${rootPaths}/model/tdl.genmodel"
	    srcPath = "platform:/resource/${rootPaths}/${srcGen}" 
	}
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@
					<arguments>
						<argument>/${project.basedir}/model/GenerateTDL.mwe2</argument>
						<argument>-p</argument>
						<argument>rootPath=/${project.basedir}/..</argument>
						<argument>projectRoot=${project.basedir}</argument>
					</arguments>
					<classpathScope>compile</classpathScope>
					<includePluginDependencies>true</includePluginDependencies>