Skip to content

Commit

Permalink
Fix Java 8 support
Browse files Browse the repository at this point in the history
EMF has open version ranges pulling in whatever the latest core runtime
version is, thereby breaking Java 8 compatibility. This change fixes those
versions back up. For newer Xtext/Gradle versions it uses the Xtext BOM.
For older versions it does some hand-picked version fixes.

To test this properly, we're now not just testing against  different Gradle versions.
I've also raised the maximum versions to the latest ones that we can support without
major test rewrites.

Fixes #187
Fixes #189
  • Loading branch information
oehme committed Aug 28, 2021
1 parent de7f7fe commit 3763ead
Show file tree
Hide file tree
Showing 18 changed files with 187 additions and 215 deletions.
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
minimumXtextVersion = 2.9.0
#We can't use 2.11 while we still want Java 6 support
bootstrapXtextVersion = 2.9.1
latestXtextVersion = 2.14.0
latestXtextVersion = 2.25.0
minimumGradleVersion = 4.3
latestGradleVersion = 6.9.1
systemProp.http.connectionTimeout=120000
systemProp.http.socketTimeout=120000
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import java.util.Collection
import java.util.Map
import org.eclipse.emf.ecore.resource.ResourceSet
import org.eclipse.xtend.lib.annotations.Accessors
import org.gradle.api.file.FileCollection

//TODO move to Xtext
@Accessors
Expand Down
2 changes: 2 additions & 0 deletions xtext-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,14 @@ tasks.withType(Test) {
minimumIntegrationTest {
reports.html.destination = file("$testReportDir/$name")
reports.junitXml.destination = file("$testResultsDir/$name")
systemProperty 'gradle.version', minimumGradleVersion
systemProperty 'xtext.version', minimumXtextVersion
}

task latestIntegrationTest(type: Test) {
classpath = minimumIntegrationTest.classpath
testClassesDirs = minimumIntegrationTest.testClassesDirs
systemProperty 'gradle.version', latestGradleVersion
systemProperty 'xtext.version', latestXtextVersion
enabled = JavaVersion.current().java8Compatible
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import org.gradle.testkit.runner.BuildTask
import org.junit.Before
import org.junit.Rule
import org.xtext.gradle.test.GradleBuildTester.ProjectUnderTest
import java.io.File

abstract class AbstractIntegrationTest {

@Rule public extension GradleBuildTester tester = new GradleBuildTester
protected extension ProjectUnderTest rootProject
protected val extension XtextBuilderAssertions = new XtextBuilderAssertions

public final static String XTEXT_VERSION = System.getProperty("xtext.version", "2.9.0")

Expand All @@ -25,6 +25,7 @@ abstract class AbstractIntegrationTest {
«repositories»
}
'''
createFile('gradle.properties', 'org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m')
}

protected def CharSequence getRepositories() '''
Expand All @@ -42,4 +43,8 @@ abstract class AbstractIntegrationTest {
return buildResult.task(taskName)
}
def OutputSnapshot snapshot(File baseDir) {
new OutputSnapshot(baseDir)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package org.xtext.gradle.test

import org.junit.Test
import org.xtext.gradle.test.GradleBuildTester.ProjectUnderTest

import static org.junit.Assert.*

//TODO use a different language than Xtend
class BuildingAMultiModulePlainLanguageProject extends AbstractIntegrationTest {

Expand All @@ -15,12 +17,12 @@ class BuildingAMultiModulePlainLanguageProject extends AbstractIntegrationTest {
subprojects {
apply plugin: 'org.xtext.builder'
apply plugin: 'java-base'
dependencies {
add('default', 'org.eclipse.xtend:org.eclipse.xtend.lib:«XTEXT_VERSION»')
xtextLanguages 'org.eclipse.xtend:org.eclipse.xtend.core:«XTEXT_VERSION»'
}
xtext {
version = '«XTEXT_VERSION»'
languages {
Expand All @@ -34,13 +36,13 @@ class BuildingAMultiModulePlainLanguageProject extends AbstractIntegrationTest {
}
}
}
generateXtext.classpath = configurations.'default'
task jar(type:Jar) {
from(xtext.sourceSets.main.files)
}
artifacts {
'default' jar
}
Expand All @@ -61,7 +63,7 @@ class BuildingAMultiModulePlainLanguageProject extends AbstractIntegrationTest {
downStreamProject.createFile("src/main/java/B.xtend", '''class B extends A {}''')
build("generateXtext")
}

@Test
def void generatorOnlyRunsForLocalModels() {
upStreamProject.createFile("src/main/java/A.xtend", '''class A {}''')
Expand All @@ -74,13 +76,14 @@ class BuildingAMultiModulePlainLanguageProject extends AbstractIntegrationTest {
@Test
def void upStreamChangesArePickedUpDownStream() {
val upStream = upStreamProject.createFile("src/main/java/A.xtend", '''class A {}''')
val downStream = downStreamProject.createFile("src/main/java/B.xtend", '''class B extends A {}''')
downStreamProject.createFile("src/main/java/B.xtend", '''class B extends A {}''')
build("generateXtext")
val snapshot = snapshot(downStreamProject.projectDir)

upStream.content = '''
class A implements Cloneable {}
'''
val result = build("generateXtext", "-i")
result.hasRunGeneratorFor(downStream)
build("generateXtext", "-i")
snapshot.assertChangedClasses("B")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@ class BuildingAMultiModuleXtendProject extends AbstractXtendIntegrationTest {
@Test
def void upStreamChangesArePickedUpDownStream() {
val upStream = upStreamProject.createFile("src/main/java/A.xtend", '''class A {}''')
val downStream = downStreamProject.createFile("src/main/java/B.xtend", '''class B extends A {}''')
downStreamProject.createFile("src/main/java/B.xtend", '''class B extends A {}''')
build("build")

val snapshot = snapshot(downStreamProject.projectDir)

upStream.content = '''
class A implements Cloneable {}
'''
val result = build("build", "-i")
result.hasRunGeneratorFor(downStream)
build("build")
snapshot.assertChangedClasses("B")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ class BuildingAPlainLanguageProject extends AbstractIntegrationTest {
super.setup
buildFile << '''
apply plugin: 'org.xtext.builder'
configurations {
compile
}
dependencies {
compile 'org.eclipse.xtend:org.eclipse.xtend.lib:«XTEXT_VERSION»'
xtextLanguages 'org.eclipse.xtend:org.eclipse.xtend.core:«XTEXT_VERSION»'
}
xtext {
version = '«XTEXT_VERSION»'
languages {
Expand All @@ -32,7 +32,7 @@ class BuildingAPlainLanguageProject extends AbstractIntegrationTest {
}
}
}
generateXtext.classpath = configurations.compile
'''
}
Expand Down Expand Up @@ -65,28 +65,27 @@ class BuildingAPlainLanguageProject extends AbstractIntegrationTest {
val upStream = createFile('src/main/xtend/UpStream.xtend', '''
class UpStream {}
''')
val downStream = createFile('src/main/xtend/DownStream.xtend', '''
createFile('src/main/xtend/DownStream.xtend', '''
class DownStream {
UpStream upStream
}
''')
val unrelated = createFile('src/main/xtend/Unrelated.xtend', '''
createFile('src/main/xtend/Unrelated.xtend', '''
class Unrelated {}
''')

build("generateXtext")
val snapshot = snapshot(projectDir)

upStream.content = '''
class UpStream {
def void foo() {}
}
'''
val secondResult = build("generateXtext", "-i")

secondResult.hasRunGeneratorFor(upStream)
secondResult.hasRunGeneratorFor(downStream)
secondResult.hasNotRunGeneratorFor(unrelated)
build("generateXtext")

snapshot.assertChangedClasses("UpStream", "DownStream")
}

@Test
def void generateOnceFoldersAreNotCleanedByCleanBuilds() {
buildFile << '''xtext.languages.xtend.generator.outlet.cleanAutomatically = false'''
Expand All @@ -106,7 +105,7 @@ class BuildingAPlainLanguageProject extends AbstractIntegrationTest {
// then
staleFile.shouldExist
}

@Test
def void generateOnceFoldersAreNotCleanedByGradleClean() {
buildFile << '''xtext.languages.xtend.generator.outlet.cleanAutomatically = false'''
Expand Down
Loading

0 comments on commit 3763ead

Please sign in to comment.