i have a Question about XText/Maven. I have a XText/Maven/Java Project.
In this Project lie the Xtext Models and Java source Files. Some of the Modelfiles reference some Java files. EG:
Model:
package a.b.c
import java.util.List
import x.y.z.MyClass // <-- This is one of the Javafile in the same Project
dto MyModel
{
MyClass myClass
}
Java:
package x.y.z;
public class MyClass
{
String foo;
String bar;
}
Structure:
project
|
|----src/main
|
|---/java/x/y/z/MyClass.java
|
|---/model/a/b/c/MyModel.dto
|
|---/gen/a/b/c/MyModel.java <-- here goes the generated Javafile from the Model
I have already managed to write an Xtext/Eclipse plugin, so the Eclipse build generate my Modelfiles and compiles the Javafiles just fine.
But now i try to build the Project with Maven. I Manage already accomplished the Generate process via an mwe2 Workflow with use of the Class
org.eclipse.emf.mwe2.launch.runtime.MWE2Launcher
and other Modelfiles genrate just fine, but the MyModel references a Java Class that is not yet Compiled and so it is not Found:
[ERROR] Execution Failed: Problems running workflow my.company.model.xtext.domainmodel.generator: Validation problems:
[ERROR] 49 errors:
[ERROR] MyModel.dto - <path>/model/a/b/c/MyModel.dto
[ERROR] 4: x.y.z.MyClass cannot be resolved to a type.
...
So the Error itself is clear. I tryed with sucess to Precompile the Java File first and add these to the Classpath. But i have dozen of this Problems and i hope the is a better way to tell Xtext/Mwe2Launcher that it should reference the requierd Java Files. Because in some magic way it already work in Eclipse but i have no Idea how.
I have the same problem. But I use Gradle instead of Maven. However it may be still useful for someone:
task precompile(type: JavaCompile) {
source = 'src/main/java'
classpath = sourceSets.main.compileClasspath
destinationDir = sourceSets.main.java.outputDir
}
task generateXtextLanguage(type: JavaExec) {
dependsOn precompile
main = 'org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher'
args += "src/main/mwe2/...your_path_here.../generate.mwe2"
classpath = layout.files(configurations.mwe2, sourceSets.main.java.outputDir)
inputs.file 'src/main/mwe2/...your_path_here.../generate.mwe2'
inputs.dir 'src/main/xcore'
outputs.dir 'target/generated-sources/xtext-gen'
}
I added precompile
task. generateXtextLanguage
dependsOn it. Also I added precompiled classes to a classpath.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.