intellij-ideaandroid-gradle-pluginxtextxtext-gradle-plugin

How to build my xtext language with gradle for android


I've written a test-DSL in xtext and generated an IntelliJ plugin. I have a small Android-test project and in Android Studio my DSL-editor shows up and also generates the output files as expected.

Now I try to configure gradle to also generate the files, but this fails with an error.

I found the Android Integration section for the xtext-builder. This seems out-dated (e.g. it refers to org.xtext.android, which does not exist - also the link there is broken).

Anyway, in the xtext-gradle-plugin github repo there is an org.xtext.android.builder plugin: I guess this is the correct one.

My project build.gradle file looks like this (relevant parts only):

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/" // needed for org.xtext:xtext-android-gradle-plugin
        }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath "org.xtext:xtext-android-gradle-plugin:1.0.14"
    }
}

allprojects {
    repositories {
        jcenter()
        mavenLocal() // This is required so that the mydsl language is found
    }
}

when I activate the org.xtext.android.builder plugin in the build.gradle file of in my app module:

apply plugin: 'com.android.application'
apply plugin: "org.xtext.android.builder" // causes the Error!

I get this error:

Error:Unable to find method 'com.android.build.gradle.api.BaseVariant.getJavaCompiler()Lorg/gradle/api/tasks/compile/AbstractCompile;'...

I guess there's some version mismatch or something is not up-to-date.
Any ideas?


Solution

  • This was a bug (#73) in the xtext-gradle-plugin. It was fixed in Version 1.0.16.