Gradle and GeneratorFragment [message #1791398] |
Thu, 28 June 2018 17:56 |
Tobias Blaufuß Messages: 4 Registered: June 2018 |
Junior Member |
|
|
Hello,
i've created a xtext project (my.example.domain.mydsl) with gradle as preferred build system and a plain source layout. My project layout looks like this:
my.example.domain.mydsl.parent (Main gradle project)
my.example.domain.mydsl.target
my.example.domain.mydsl (gradle subproject)
my.example.domain.mydsl.tests (gradle subproject)
my.example.domain.mydsl.ide (gradle subproject)
my.example.domain.mydsl.ui
I added the following GeneratorFragment to my .mwe2 configuration:
fragment = generator.GeneratorFragment2 {
generateJavaMain = true
}
This will generate a Main.java file in the package my.example.domain.mydsl.generator of the gradle subproject my.example.domain.mydsl
When i execute the generated Main-class inside eclipse it runs the generator on my provided resource files perfectly fine, but i want to execute this java application via gradle and without eclipse (AFTER the generateXtextLanguage task)
My gradle build inside the gradle subproject my.example.domain.mydsl looks like this:
dependencies {
compile "org.eclipse.xtext:org.eclipse.xtext:${xtextVersion}"
compile "org.eclipse.xtext:org.eclipse.xtext.xbase:${xtextVersion}"
}
configurations {
mwe2 {
extendsFrom compile
}
}
dependencies {
mwe2 "org.eclipse.emf:org.eclipse.emf.mwe2.launch:2.9.0.201605261059"
mwe2 "org.eclipse.xtext:org.eclipse.xtext.common.types:${xtextVersion}"
mwe2 "org.eclipse.xtext:org.eclipse.xtext.xtext.generator:${xtextVersion}"
mwe2 "org.eclipse.xtext:xtext-antlr-generator:[2.1.1, 3)"
}
task generateXtextLanguage(type: JavaExec) {
main = 'org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher'
classpath = configurations.mwe2
inputs.file "src/my/example/domain/mydsl/GenerateGlossaryModel.mwe2"
inputs.file "src/my/example/domain/mydsl/Mydsl.xtext"
outputs.dir "src-gen"
args += "src/my/example/domain/mydsl/GenerateMydsl.mwe2"
args += "-p"
args += "rootPath=/${projectDir}/.."
}
task generateXtextModels(type: JavaExec) {
main = 'my.example.domain.mydsl.generator.Main'
// Provide some parameters, arguments, etc.
// ...
}
generateXtext.dependsOn(generateXtextLanguage)
generateXtext.dependsOn(generateXtextModels)
generateXtextModels.dependsOn(generateXtextLanguage)
clean.dependsOn(cleanGenerateXtextLanguage)
eclipse.classpath.plusConfigurations += [configurations.mwe2]
//this is an eclipse plugin project
eclipseClasspath.enabled=false
cleanEclipseClasspath.enabled=false
It's basically the automatically generated gradle build with an extra task "generateXtextModels" and 2 "dependsOn" statements.
When i execute "gradle build" i get the following error:
> Task :my.example.domain.mydsl:generateXtextLanguage UP-TO-DATE
> Task :my.example.domain.mydsl:generateXtextModels FAILED
Error: Could not find or load main class my.example.domain.mydsl.generator.Main
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':my.example.domain.mydsl:generateXtextModels'.
> Process 'command '/usr/lib/jvm/java-8-openjdk/bin/java'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at gradle
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See docs
BUILD FAILED in 0s
2 actionable tasks: 1 executed, 1 up-to-date
I really don't know where to go from here. I've tried some things with classpaths, sourceSets and plugins, but I'm not making any progress here. Has anyone an idea how to call this generator class via gradle?
Thank you in advance
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03513 seconds