How do I generate code from an xcore model during a gradle build

445 views Asked by At

So I am attempting to build my project in a build server. My dsl's are failing to build because they rely on code from my xcore model and the generated code from the xcore model is not in the repository the build server pulls from. I am unsure what actually kicks off the the code generation on the xcore model. So how can I ensure that the model code is generated before gradle attempts to build my other dsl's?

Attached build.gradle for xcore project:

repositories {
    jcenter()
}

configurations {
  xtextTooling.extendsFrom xcore // alias xtextTooling to xcore to prevent confusion
}

test {
    useJUnitPlatform()
}

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 "org.eclipse.xtext:org.eclipse.xtext:${xtextVersion}"
    compile "org.eclipse.xtext:org.eclipse.xtext.xbase:${xtextVersion}"
    compile 'org.eclipse.emf:org.eclipse.emf.ecore.xcore.lib:+'
    compile group: 'org.eclipse.xtext', name: 'org.eclipse.xtext.ecore', version: '2.15.0'

    xcore group: 'org.eclipse.emf', name: 'org.eclipse.emf.mwe2.lib', version: '2.9.1.201705291010'
    xcore group: 'org.eclipse.emf', name: 'org.eclipse.emf.codegen', version: '2.14.0'

    xcore 'org.eclipse.emf:org.eclipse.emf.codegen.ecore:+'
    xcore 'org.eclipse.emf:org.eclipse.emf.codegen.ecore.xtext:+'
    xcore 'org.eclipse.emf:org.eclipse.emf.ecore.xcore:1.3.1'
    xcore 'org.eclipse.emf:org.eclipse.emf.ecore.xcore.lib:+'
    xcore "org.eclipse.xtext:org.eclipse.xtext.ecore:${xtextVersion}"

}

xtext {
    version = "${xtextVersion}"
    languages {
        ecore {
            setup = 'org.eclipse.xtext.ecore.EcoreSupport'
        }
        codegen {
            setup = 'org.eclipse.emf.codegen.ecore.xtext.GenModelSupport'
        }
        xcore {
            setup = 'org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup'
            generator.outlet.producesJava = true
        }

    }
}
sourceSets {
    main {
        resources {
            exclude '**/*.xcore'
        }
        java {
            srcDir 'build/xcore/main'
        }
    }
}

clean {
    delete 'build/xcore/main'
}

I saw some examples with a slightly different xtext region:

xtext {
    version = "${xtextVersion}"
    languages {
        ecore {
            setup = 'org.eclipse.xtext.ecore.EcoreSupport'
        }
        codegen {
            setup = 'org.eclipse.emf.codegen.ecore.xtext.GenModelSupport'
        }
        xcore {
            setup = 'org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup'
            generator.outlet.producesJava = true
            output {
                dir 'build/xcore/main'
                producesJavaFor sourceSets.main
            }
        }

    }
}

but if I attempt to use this I get the gradle error:

Could not find method output() for arguments [build_..._run_closure...] on object of type org.xtext.gradle.tasks.Language

0

There are 0 answers