Skip to content

Commit 4b0f238

Browse files
authored
Reorganize the standalone example (#182)
* Reorganize the standalone example The example was halfway Mavenized but not all the way, and some classes were using the deprecated base class. This commit reorganizes the example so that it is fully Mavenized (sources in src/main/java, resources in src/main/resources), and removes the deprecated base class after revamping the examples that were using it. Epsilon programs and metamodels are now resources which would be bundled with the rest of the program, whereas models are no longer bundled with the program. * Add example code for fetching ETL traces or EVL results * Add copy of EGX example that doesn't use EgxRunConfiguration, for comparison * Add disposal to standalone example
1 parent e8acfde commit 4b0f238

File tree

67 files changed

+951
-787
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+951
-787
lines changed
Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,57 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
10+
<attributes>
11+
<attribute name="maven.pomderived" value="true"/>
12+
<attribute name="optional" value="true"/>
13+
</attributes>
14+
</classpathentry>
15+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
16+
<attributes>
17+
<attribute name="optional" value="true"/>
18+
<attribute name="maven.pomderived" value="true"/>
19+
<attribute name="test" value="true"/>
20+
</attributes>
21+
</classpathentry>
22+
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
23+
<attributes>
24+
<attribute name="maven.pomderived" value="true"/>
25+
<attribute name="test" value="true"/>
26+
<attribute name="optional" value="true"/>
27+
</attributes>
28+
</classpathentry>
29+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
430
<attributes>
531
<attribute name="maven.pomderived" value="true"/>
632
</attributes>
733
</classpathentry>
8-
<classpathentry exported="true" kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
9-
<classpathentry kind="src" path="src"/>
1034
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
1135
<attributes>
1236
<attribute name="maven.pomderived" value="true"/>
1337
</attributes>
1438
</classpathentry>
39+
<classpathentry kind="src" path="target/generated-sources/annotations">
40+
<attributes>
41+
<attribute name="optional" value="true"/>
42+
<attribute name="maven.pomderived" value="true"/>
43+
<attribute name="ignore_optional_problems" value="true"/>
44+
<attribute name="m2e-apt" value="true"/>
45+
</attributes>
46+
</classpathentry>
47+
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
48+
<attributes>
49+
<attribute name="optional" value="true"/>
50+
<attribute name="maven.pomderived" value="true"/>
51+
<attribute name="ignore_optional_problems" value="true"/>
52+
<attribute name="m2e-apt" value="true"/>
53+
<attribute name="test" value="true"/>
54+
</attributes>
55+
</classpathentry>
1556
<classpathentry kind="output" path="target/classes"/>
1657
</classpath>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
egx-gen
1+
egx-gen
2+
Tree.new.xmi
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<projectDescription>
3-
<name>org.eclipse.epsilon.examples.standalone</name>
4-
<comment></comment>
5-
<projects>
6-
</projects>
7-
<buildSpec>
8-
<buildCommand>
9-
<name>org.eclipse.jdt.core.javabuilder</name>
10-
<arguments>
11-
</arguments>
12-
</buildCommand>
13-
<buildCommand>
14-
<name>org.eclipse.m2e.core.maven2Builder</name>
15-
<arguments>
16-
</arguments>
17-
</buildCommand>
18-
</buildSpec>
19-
<natures>
20-
<nature>org.eclipse.jdt.core.javanature</nature>
21-
<nature>org.eclipse.m2e.core.maven2Nature</nature>
22-
</natures>
23-
</projectDescription>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>standalone-example</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
22+
</natures>
23+
</projectDescription>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
encoding/<project>=UTF-8
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.apt.aptEnabled=false
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
eclipse.preferences.version=1
22
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3-
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4-
org.eclipse.jdt.core.compiler.compliance=1.8
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
4+
org.eclipse.jdt.core.compiler.compliance=17
55
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
66
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
77
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
88
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
99
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
10+
org.eclipse.jdt.core.compiler.processAnnotations=disabled
1011
org.eclipse.jdt.core.compiler.release=disabled
11-
org.eclipse.jdt.core.compiler.source=1.8
12+
org.eclipse.jdt.core.compiler.source=17
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
activeProfiles=
2+
eclipse.preferences.version=1
3+
resolveWorkspaceProjects=true
4+
version=1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"java.configuration.updateBuildConfiguration": "interactive"
3+
}

examples/org.eclipse.epsilon.examples.standalone/build.properties

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="ASCII"?>
2+
<Tree xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="TreeDsl" xsi:schemaLocation="TreeDsl file:/Volumes/Sources/epsilon/examples/org.eclipse.epsilon.examples.standalone/target/classes/metamodels/Tree.ecore" label="CopyOfa">
3+
<children label="CopyOfb">
4+
<children label="CopyOfc"/>
5+
</children>
6+
</Tree>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="ASCII"?>
2+
<Tree xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns="TreeDsl" xmi:id="_w_VmAFJKEd2Vx8faA_hRaA" label="migrated_a">
3+
<children xmi:id="_w_VmAVJKEd2Vx8faA_hRaA" label="migrated_b">
4+
<children xmi:id="_w_VmAlJKEd2Vx8faA_hRaA" label="migrated_c"/>
5+
</children>
6+
</Tree>
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<?xml version="1.0" encoding="ASCII"?>
2-
<Tree xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns="TreeDsl" xmi:id="_w_VmAFJKEd2Vx8faA_hRaA" label="a">
3-
<children xmi:id="_w_VmAVJKEd2Vx8faA_hRaA" label="b">
4-
<children xmi:id="_w_VmAlJKEd2Vx8faA_hRaA" label="c"/>
5-
</children>
6-
</Tree>
1+
<?xml version="1.0" encoding="ASCII"?>
2+
<Tree xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns="TreeDsl" xmi:id="_w_VmAFJKEd2Vx8faA_hRaA" label="a">
3+
<children xmi:id="_w_VmAVJKEd2Vx8faA_hRaA" label="b">
4+
<children xmi:id="_w_VmAlJKEd2Vx8faA_hRaA" label="c"/>
5+
</children>
6+
</Tree>
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<?xml version="1.0" encoding="ASCII"?>
2-
<Tree xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="TreeDsl" xsi:schemaLocation="TreeDsl Tree.ecore" label="a">
3-
<children label="b">
4-
<children label="c"/>
5-
</children>
6-
</Tree>
1+
<?xml version="1.0" encoding="ASCII"?>
2+
<Tree xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="TreeDsl" xsi:schemaLocation="TreeDsl Tree.ecore" label="a">
3+
<children label="b">
4+
<children label="c"/>
5+
</children>
6+
</Tree>

examples/org.eclipse.epsilon.examples.standalone/pom.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
</repositories>
2222

2323
<properties>
24-
<epsilon.version>2.4.0</epsilon.version>
24+
<epsilon.version>2.8.0</epsilon.version>
25+
<emfatic.version>1.1.0</emfatic.version>
2526
<epsilon.scope>compile</epsilon.scope>
26-
<maven.compiler.source>1.8</maven.compiler.source>
27-
<maven.compiler.target>1.8</maven.compiler.target>
27+
<maven.compiler.source>17</maven.compiler.source>
28+
<maven.compiler.target>17</maven.compiler.target>
2829
</properties>
2930

3031
<dependencies>
@@ -91,7 +92,7 @@
9192
<dependency>
9293
<groupId>org.eclipse.emfatic</groupId>
9394
<artifactId>org.eclipse.emfatic.core</artifactId>
94-
<version>1.1.0-SNAPSHOT</version>
95+
<version>${emfatic.version}</version>
9596
</dependency>
9697
</dependencies>
9798

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*********************************************************************
2+
* Copyright (c) 2008-2025 The University of York.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
**********************************************************************/
10+
package org.eclipse.epsilon.examples.standalone.egl;
11+
12+
import java.nio.file.Paths;
13+
14+
import org.eclipse.epsilon.egl.EglModule;
15+
import org.eclipse.epsilon.emc.emf.EmfModel;
16+
import org.eclipse.epsilon.examples.standalone.egl.flexmiemfatic.EglFlexmiEmfaticStandaloneExample;
17+
18+
public class EglStandaloneExample {
19+
20+
public static void main(String[] args) throws Exception {
21+
EglModule module = new EglModule();
22+
module.parse(EglStandaloneExample.class.getResource("/egl/Demo.egl"));
23+
if (!module.getParseProblems().isEmpty()) {
24+
System.out.println("Parsing problems: " + module.getParseProblems());
25+
System.exit(1);
26+
}
27+
28+
EmfModel model = new EmfModel();
29+
model.setName("Model");
30+
model.setModelFile("models/Tree.xmi");
31+
model.setMetamodelFile(Paths.get(
32+
EglFlexmiEmfaticStandaloneExample.class.getResource("/metamodels/Tree.ecore")
33+
.toURI()).toFile().getAbsolutePath()
34+
);
35+
model.setReadOnLoad(true);
36+
model.setStoredOnDisposal(false);
37+
model.load();
38+
module.getContext().getModelRepository().addModel(model);
39+
40+
try {
41+
Object result = module.execute();
42+
System.out.println(result);
43+
} finally {
44+
module.getContext().getModelRepository().dispose();
45+
module.getContext().dispose();
46+
}
47+
}
48+
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*********************************************************************
2+
* Copyright (c) 2008-2025 The University of York.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
**********************************************************************/
10+
package org.eclipse.epsilon.examples.standalone.egl;
11+
12+
import java.io.File;
13+
import java.nio.file.Path;
14+
import java.nio.file.Paths;
15+
16+
import org.eclipse.epsilon.common.util.StringProperties;
17+
import org.eclipse.epsilon.egl.EgxModule;
18+
import org.eclipse.epsilon.emc.emf.EmfModel;
19+
20+
/**
21+
* This example demonstrates using the Epsilon Generation Language, the M2T language of Epsilon, in a stand-alone manner
22+
*
23+
* @author Sina Madani
24+
* @author Dimitrios Kolovos
25+
*/
26+
public class EgxModuleExample {
27+
28+
public static void main(String[] args) throws Exception {
29+
Path root = Paths.get(EgxModuleExample.class.getResource("/").toURI());
30+
31+
StringProperties modelProperties = new StringProperties();
32+
modelProperties.setProperty(EmfModel.PROPERTY_NAME, "Model");
33+
modelProperties.setProperty(EmfModel.PROPERTY_FILE_BASED_METAMODEL_URI,
34+
root.resolve("metamodels/Tree.ecore").toAbsolutePath().toUri().toString()
35+
);
36+
modelProperties.setProperty(EmfModel.PROPERTY_MODEL_URI,
37+
Paths.get("models", "Tree.xmi").toUri().toString()
38+
);
39+
modelProperties.setProperty(EmfModel.PROPERTY_CACHED, "true");
40+
modelProperties.setProperty(EmfModel.PROPERTY_CONCURRENT, "true");
41+
42+
EmfModel model = new EmfModel();
43+
model.load(modelProperties);
44+
45+
EgxModule module = new EgxModule(new File("egx-gen").getAbsolutePath());
46+
module.parse(root.resolve("egx/demo.egx"));
47+
module.getContext().getFrameStack().put("eglTemplateFileName", "tree.egl");
48+
module.getContext().setProfilingEnabled(true);
49+
module.getContext().getModelRepository().addModel(model);
50+
51+
try {
52+
module.execute();
53+
} finally {
54+
module.getContext().getModelRepository().dispose();
55+
module.getContext().dispose();
56+
}
57+
}
58+
59+
}

0 commit comments

Comments
 (0)