gpt4 book ai didi

gradle - Xtext:无法解析对 JvmType MyGeneratorModule 的引用

转载 作者:行者123 更新时间:2023-12-03 03:57:47 27 4
gpt4 key购买 nike

我正在使用 Entities and StateMachine 示例为多个 dsl 复制示例 Xtext Web 项目的结构。我使用 Gradle 作为我的构建系统。我有课MyGeneratorModule在我的两个语法项目中。在我的工作流程中,我这样引用它:configuration = MyGeneratorModule {...}我可以在每个项目中正常运行工作流,但是当我尝试从 Web 项目执行 jettyRun 时,我收到此错误:

Task :com.selinc.logic.program:generateXtextLanguage FAILED
0 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher - [XtextLinkingDiagnostic: null:17 Couldn't resolve reference to JvmType 'MyGeneratorModule'.

我在工作流程或 gradle 构建中遗漏了什么吗?这是我的语言 build.gradle 文件和工作流程的更完整示例:

mwe2:
component = XtextGenerator {
configuration = MyGeneratorModule { // <- This is what is not resolving
project = StandardProjectConfig {
baseName = baseName
rootPath = rootPath
runtimeTest = {
enabled = true
}
web = {
enabled = true
root = "../myWebProject"
src = "../myWebProject/src/main/java"
srcGen = "../myWebProject/src/main/xtext-gen"
assets = "../myWebProject/src/main/webapp"
}
mavenLayout = true
}
code = {
encoding = "UTF-8"
lineDelimiter = "\r\n"
fileHeader = "/*\n * generated by Xtext \${version}\n */"
}
}
cleaner = {
exclude = "MyOtherLanguageWebModule.java"
}
language = StandardLanguage {
name = "MyLang"
fileExtensions = "lang"
serializer = {
generateStub = false
}
webSupport = {
generateHtmlExample = true
framework = "CODEMIRROR"
generateJsHighlighting = false
generateServlet = false
generateWebXml=true
}
junitSupport = {
junitVersion = "5"
}
}
}

构建.gradle:
    dependencies {
testCompile "org.junit.jupiter:junit-jupiter-api:5.1.0"
testRuntime "org.junit.jupiter:junit-jupiter-engine:5.1.0"
testCompile "org.eclipse.xtext:org.eclipse.xtext.testing:${xtextVersion}"

compile project(':myOtherLang')
compile project(':myXCoreModel')
compile project(":util")

compile group: 'org.eclipse.xtext', name: 'org.eclipse.xtext.ecore', version: '2.15.0'
compile "org.eclipse.xtext:org.eclipse.xtext.xbase:${xtextVersion}"
}
sourceSets {
mwe2 {}
}
configurations {
mwe2 {
extendsFrom compile
}
mwe2Compile.extendsFrom mainCompile
mwe2Runtime.extendsFrom mainRuntime
}
sourceSets.mwe2.java.srcDir 'generator'

dependencies {
mwe2Compile "org.eclipse.emf:org.eclipse.emf.mwe2.launch:2.9.1.201705291010"
mwe2Compile "org.eclipse.xtext:org.eclipse.xtext.common.types:${xtextVersion}"
mwe2Compile "org.eclipse.xtext:org.eclipse.xtext.xtext.generator:${xtextVersion}"
mwe2Compile "org.eclipse.xtext:xtext-antlr-generator:[2.1.1, 3)"

//added for xcore support
mwe2Compile 'org.eclipse.emf:org.eclipse.emf.ecore.xcore:1.3.1'
mwe2Compile 'org.eclipse.emf:org.eclipse.emf.codegen.ecore.xtext:+'
}

task generateXtextLanguage(type: JavaExec) {
main = 'org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher'
classpath = project.sourceSets.mwe2.runtimeClasspath
inputs.file "path/GenerateMyLang.mwe2"
inputs.file "path/MyLang.xtext"
outputs.dir "src-gen"
args += "path/GenerateMyLang.mwe2"
args += "-p"
args += "rootPath=/${projectDir}/.."
}

test {
useJUnitPlatform()
}
generateXtext.dependsOn(generateXtextLanguage)
clean.dependsOn(cleanGenerateXtextLanguage)
eclipse.classpath.plusConfigurations += [configurations.mwe2]

最佳答案

我怀疑这是否可行。您复制的代码不会生成 xtext 语言
您应该将自定义模块移动到单独的 gradle 项目,从而单独编译它。或者,您可以尝试使用 gradle buildSrc/separate 源文件夹代码

(我不确定这是否适用于这个用例)

dependencies {
compile "org.eclipse.xtext:org.eclipse.xtext:${xtextVersion}"
compile "org.eclipse.xtext:org.eclipse.xtext.xbase:${xtextVersion}"
}
sourceSets {
mwe2 {}
}
configurations {
mwe2 {
extendsFrom compile
}
mwe2Compile.extendsFrom mainCompile
mwe2Runtime.extendsFrom mainRuntime
}
sourceSets.mwe2.java.srcDir 'generator'

dependencies {
mwe2Compile "org.eclipse.emf:org.eclipse.emf.mwe2.launch:2.9.1.201705291010"
mwe2Compile "org.eclipse.xtext:org.eclipse.xtext.common.types:${xtextVersion}"
mwe2Compile "org.eclipse.xtext:org.eclipse.xtext.xtext.generator:${xtextVersion}"
mwe2Compile "org.eclipse.xtext:xtext-antlr-generator:[2.1.1, 3)"
}

task generateXtextLanguage(type: JavaExec) {
main = 'org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher'
classpath = project.sourceSets.mwe2.runtimeClasspath
inputs.file "src/org/xtext/example/mydsl/GenerateMyDsl.mwe2"
inputs.file "src/org/xtext/example/mydsl/MyDsl.xtext"
outputs.dir "src-gen"
args += "src/org/xtext/example/mydsl/GenerateMyDsl.mwe2"
args += "-p"
args += "rootPath=/${projectDir}/.."
}

generateXtext.dependsOn(generateXtextLanguage)
clean.dependsOn(cleanGenerateXtextLanguage)
eclipse.classpath.plusConfigurations += [configurations.mwe2]

关于gradle - Xtext:无法解析对 JvmType MyGeneratorModule 的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54009122/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com