From 450bfeec2cba4b798b00e33b03ab526399ec5b75 Mon Sep 17 00:00:00 2001 From: Christian Dietrich Date: Fri, 31 Mar 2023 10:16:31 +0200 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 | 10 ++++++++-- 1 file changed, 8 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 69242ee..201fe55 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 @@ -224,12 +224,18 @@ class XtextGradleBuilder implements IncrementalXtextBuilder { attachToEmfObject(resourceSet) language2GeneratorConfig.putAll( gradleRequest.generatorConfigsByLanguage.mapValues [ gradleConfig | + val javaVersion = JavaVersion.fromQualifier(gradleConfig.javaSourceLevel.toString) + if (javaVersion === null) { + val msg = "Xtext does not support Java " + gradleConfig.javaSourceLevel.toString + "." + gradleRequest.logger.error(msg) + throw new GradleException(msg) + } 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 ] ] )