Upgrading from 4.x
This page describes how to upgrade a build from version 4.x of the plugins to 5.0.0. It lists what you have to change and what you will notice.
Requirements
- Gradle 8.5 or newer, instead of 7.1
- Java 21 or newer for the JVM that runs Gradle, instead of Java 11
- Xtext and Xtend 2.40 or newer, instead of 2.17
Since 2.40, Xtend is published in the org.eclipse.xtext group. Change the group of the Xtend library:
dependencies {
// before: implementation("org.eclipse.xtend:org.eclipse.xtend.lib:2.30.0")
implementation("org.eclipse.xtext:org.eclipse.xtend.lib:2.45.0")
}
dependencies {
// before: implementation 'org.eclipse.xtend:org.eclipse.xtend.lib:2.30.0'
implementation 'org.eclipse.xtext:org.eclipse.xtend.lib:2.45.0'
}
Changes to Build Scripts
Imports
The types of the DSL moved from org.xtext.gradle.tasks to org.xtext.gradle, for example XtextExtension, Language and Outlet. The enums SourceInstaller and IssueSeverity are there as well.
Source Folders
Use sources to add a folder that is not in the Java source set:
// before: xtext.sourceSets["main"].srcDir("src/main/heroes")
xtext.sourceSets["main"].sources.srcDir("src/main/heroes")
sourceSets {
main {
// before: xtend.srcDir("src/main/xtend")
xtend.sources.srcDir("src/main/xtend")
}
}
// before: xtext.sourceSets.main.srcDir 'src/main/heroes'
xtext.sourceSets.main.sources.srcDir 'src/main/heroes'
// before: sourceSets.main.xtend.srcDir 'src/main/xtend'
sourceSets.main.xtend.sources.srcDir 'src/main/xtend'
Output Folders
Output folders are directory properties now. Set them with a directory:
sourceSets {
main {
// before: xtend.outputDir = "xtend-gen"
xtend.outputDir = file("xtend-gen")
}
}
xtext.sourceSets["main"].output {
// before: dir(xtext.languages["herolang"].generator.outlet, "build/heroes")
dir(xtext.languages["herolang"].generator.outlet).set(layout.buildDirectory.dir("heroes"))
}
// before: sourceSets.main.xtend.outputDir = 'xtend-gen'
sourceSets.main.xtend.outputDir = file('xtend-gen')
xtext.sourceSets.main.output {
// before: dir(xtext.languages.herolang.generator.outlet, 'build/heroes')
dir(xtext.languages.herolang.generator.outlet).set(layout.buildDirectory.dir('heroes'))
}
Debugger and Generator Options
The source installer is an enum. SMAP is the default for every language, not only for Xtend. NONE was removed. The Java version of the generated code is a number.
import org.xtext.gradle.SourceInstaller
xtend {
// before: debugger.sourceInstaller = "PRIMARY"
debugger.sourceInstaller = SourceInstaller.PRIMARY
// before: generator.javaSourceLevel = "1.8"
generator.javaSourceLevel = 8
}
import org.xtext.gradle.SourceInstaller
xtend {
// before: debugger.sourceInstaller = 'PRIMARY'
debugger.sourceInstaller = SourceInstaller.PRIMARY
// before: generator.javaSourceLevel = '1.8'
generator.javaSourceLevel = 8
}
Configurations
The configurations with Xtext and the languages of a source set are named like those of the Java plugin:
| 4.x | 5.0.0 |
|---|---|
xtextToolingMain |
xtextTooling |
xtextTooling<SourceSet>, like xtextToolingTest |
<sourceSet>XtextTooling, like testXtextTooling |
xtextLanguages can no longer be resolved. Resolve xtextTooling instead.
Language Plugins
Some methods that language plugins could use were removed:
| Removed in 5.0.0 | Use instead |
|---|---|
XtextExtension.getXtextVersion(FileCollection) |
XtextExtension.version |
XtextSourceDirectorySet.qualifyConfigurationName(String) |
XtextSourceSet.toolingConfigurationName |
Outlet.getFolderFragment() |
|
XtextGenerate.installDebugInfo(File) |
Changes in Behavior
DSL Files of Other Projects and Libraries
The plugin no longer searches external libraries on the compile classpath for DSL files. Add libraries with DSL files to the xtextModels configuration. See Referring to Other Projects.
Active Annotations
Xtend runs active annotations only from the annotation processor path. Add the library with your active annotations to the annotationProcessor configuration, see Active Annotations. Otherwise the build fails with “X is on the classpath, but not on the annotation processor path”.
Java Version and JDK
The plugin now takes the Java version of the generated code from the Java compiler of each source set. It is the compiler’s release if that is set, otherwise its source compatibility. DSL files can refer to the classes of the Java compiler’s JDK, not of the JVM that runs Gradle. Code that used a newer JDK than the compiler now fails in the generator instead of in the Java compiler.
Eclipse
Only Buildship is supported, not gradle eclipse.