From fb5e1db69917cc612b0a6edc21a9f9198c026c2a Mon Sep 17 00:00:00 2001 From: Christian Dietrich Date: Sat, 19 Feb 2022 08:29:48 +0100 Subject: [PATCH] [eclipse/xtext-core#1835] better treatment of unsupported Java versions in Xtext Signed-off-by: Christian Dietrich --- .../org/xtext/gradle/builder/XtextGradleBuilder.xtend | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xtext-gradle-builder/src/main/java/org/xtext/gradle/builder/XtextGradleBuilder.xtend b/xtext-gradle-builder/src/main/java/org/xtext/gradle/builder/XtextGradleBuilder.xtend index 683bb9b..f4044c2 100644 --- a/xtext-gradle-builder/src/main/java/org/xtext/gradle/builder/XtextGradleBuilder.xtend +++ b/xtext-gradle-builder/src/main/java/org/xtext/gradle/builder/XtextGradleBuilder.xtend @@ -230,12 +230,16 @@ class XtextGradleBuilder implements IncrementalXtextBuilder { attachToEmfObject(resourceSet) language2GeneratorConfig.putAll( gradleRequest.generatorConfigsByLanguage.mapValues [ gradleConfig | + val javaVersion = JavaVersion.fromQualifier(gradleConfig.javaSourceLevel.toString) + if (javaVersion === null) { + gradleRequest.logger.warn("Xtext does not support Java " + gradleConfig.javaSourceLevel.toString + ", falling back to " + JavaVersion.JAVA8.label) + } new GeneratorConfig => [ generateSyntheticSuppressWarnings = gradleConfig.isGenerateSyntheticSuppressWarnings generateGeneratedAnnotation = gradleConfig.isGenerateGeneratedAnnotation - includeDateInGeneratedAnnotation = gradleConfig.isIncludeDateInGeneratedAnnotation + includeDateInGeneratedAnnotation = gradleConfig.isIncludeDateInGeneratedAnnotation generatedAnnotationComment = gradleConfig.generatedAnnotationComment - javaSourceVersion = JavaVersion.fromQualifier(gradleConfig.javaSourceLevel.toString) + javaSourceVersion = javaVersion ?: JavaVersion.JAVA8 ] ] )