Skip to content

Commit

Permalink
fix gradle 8.2 deprecations
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Dietrich <christian.dietrich.opensource@gmail.com>
  • Loading branch information
cdietrich committed Jul 18, 2023
1 parent d3a1dd7 commit c95196d
Show file tree
Hide file tree
Showing 21 changed files with 125 additions and 49 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2015, 2022 itemis AG (http://www.itemis.eu) and others.
* Copyright (c) 2015, 2023 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand Down Expand Up @@ -358,8 +358,8 @@ public void allBuildSystemsUseJava11() {
assertTrue(parentPom.contains("<maven.compiler.source>11</maven.compiler.source>"));
assertTrue(parentPom.contains("<maven.compiler.target>11</maven.compiler.target>"));
String parentGradle = config.getParentProject().buildGradle().getContent();
assertTrue(parentGradle.contains("sourceCompatibility = \'11\'"));
assertTrue(parentGradle.contains("targetCompatibility = \'11\'"));
assertTrue(parentGradle.contains("sourceCompatibility = JavaVersion.VERSION_11"));
assertTrue(parentGradle.contains("targetCompatibility = JavaVersion.VERSION_11"));
for (String it : Lists.transform(allJavaProjects(), (ProjectDescriptor it) -> it.manifest())) {
assertTrue(it.contains("Bundle-RequiredExecutionEnvironment: JavaSE-11"));
}
Expand All @@ -368,15 +368,15 @@ public void allBuildSystemsUseJava11() {

@Test
public void allBuildSystemsUseOtherJava() {
config.setJavaVersion(JavaVersion.JAVA7);
config.setJavaVersion(JavaVersion.JAVA17);
String parentPom = config.getParentProject().pom().getContent();
assertTrue(parentPom.contains("<maven.compiler.source>1.7</maven.compiler.source>"));
assertTrue(parentPom.contains("<maven.compiler.target>1.7</maven.compiler.target>"));
assertTrue(parentPom.contains("<maven.compiler.source>17</maven.compiler.source>"));
assertTrue(parentPom.contains("<maven.compiler.target>17</maven.compiler.target>"));
String parentGradle = config.getParentProject().buildGradle().getContent();
assertTrue(parentGradle.contains("sourceCompatibility = \'1.7\'"));
assertTrue(parentGradle.contains("targetCompatibility = \'1.7\'"));
assertTrue(parentGradle.contains("sourceCompatibility = JavaVersion.VERSION_17"));
assertTrue(parentGradle.contains("targetCompatibility = JavaVersion.VERSION_17"));
for (String it : Lists.transform(allJavaProjects(), (ProjectDescriptor it) -> it.manifest())) {
assertTrue(it.contains("Bundle-RequiredExecutionEnvironment: JavaSE-1.7"));
assertTrue(it.contains("Bundle-RequiredExecutionEnvironment: JavaSE-17"));
}
;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ subprojects {
group = 'full'
version = '1.0.0-SNAPSHOT'

sourceCompatibility = '11'
targetCompatibility = '11'
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

configurations.all {
exclude group: 'asm'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ jar {
}

plugins.withId('war') {
webAppDirName = "WebRoot"
war {
webAppDirectory = file("WebRoot")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ subprojects {
group = 'gradle'
version = '1.0.0-SNAPSHOT'

sourceCompatibility = '11'
targetCompatibility = '11'
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

configurations.all {
exclude group: 'asm'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testImplementation "org.eclipse.xtext:org.eclipse.xtext.testing:${xtextVersion}"
testImplementation "org.eclipse.xtext:org.eclipse.xtext.xbase.testing:${xtextVersion}"
api "org.eclipse.xtext:org.eclipse.xtext:${xtextVersion}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ jar {
}

plugins.withId('war') {
webAppDirName = "src/main/webapp"
war {
webAppDirectory = file("src/main/webapp")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ subprojects {
group = 'lsGradleApp'
version = '1.0.0-SNAPSHOT'

sourceCompatibility = '11'
targetCompatibility = '11'
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

configurations.all {
exclude group: 'asm'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ jar {
}

plugins.withId('war') {
webAppDirName = "WebRoot"
war {
webAppDirectory = file("WebRoot")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ dependencies {
}

apply plugin: 'application'
mainClassName = "org.eclipse.xtext.ide.server.ServerLauncher"
application {
mainClass = "org.eclipse.xtext.ide.server.ServerLauncher"
}

Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ subprojects {
group = 'lsGradleFatjar'
version = '1.0.0-SNAPSHOT'

sourceCompatibility = '11'
targetCompatibility = '11'
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

configurations.all {
exclude group: 'asm'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ jar {
}

plugins.withId('war') {
webAppDirName = "WebRoot"
war {
webAppDirectory = file("WebRoot")
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}

dependencies {
Expand All @@ -10,10 +10,12 @@ dependencies {

apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'
mainClassName = "org.eclipse.xtext.ide.server.ServerLauncher"
application {
mainClass = "org.eclipse.xtext.ide.server.ServerLauncher"
}

shadowJar {
from(project.convention.getPlugin(JavaPluginConvention).sourceSets.main.output)
from(project.extensions.findByType(JavaPluginExtension.class).sourceSets.main.output)
configurations = [project.configurations.runtimeClasspath]
exclude('META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA','schema/*',
'.options', '.api_description', '*.profile', '*.html', 'about.*', 'about_files/*',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
* Copyright (c) 2015, 2023 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand Down Expand Up @@ -32,6 +32,17 @@ public void setShortNotation(String shortNotation) {
private Scope scope = Scope.COMPILE;

private boolean optional = false;

private boolean gradleOnly = false;

@Pure
public boolean isGradleOnly() {
return gradleOnly;
}

public void setGradleOnly(boolean gradleOnly) {
this.gradleOnly = gradleOnly;
}

@Pure
public String getGroupId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ class IdeProjectDescriptor extends ProjectDescriptor {
pluginsSection = '''
«IF config.languageServer === LanguageServer.FATJAR»
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}
«ENDIF»
Expand All @@ -324,11 +324,13 @@ class IdeProjectDescriptor extends ProjectDescriptor {
«IF config.languageServer === LanguageServer.FATJAR»
apply plugin: 'com.github.johnrengelman.shadow'
«ENDIF»
mainClassName = "org.eclipse.xtext.ide.server.ServerLauncher"
application {
mainClass = "org.eclipse.xtext.ide.server.ServerLauncher"
}
«IF config.languageServer === LanguageServer.FATJAR»
shadowJar {
from(project.convention.getPlugin(JavaPluginConvention).sourceSets.main.output)
from(project.extensions.findByType(JavaPluginExtension.class).sourceSets.main.output)
configurations = [project.configurations.runtimeClasspath]
exclude('META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA','schema/*',
'.options', '.api_description', '*.profile', '*.html', 'about.*', 'about_files/*',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ class ParentProjectDescriptor extends ProjectDescriptor {
group = '«config.baseName»'
version = '1.0.0-SNAPSHOT'

sourceCompatibility = '«javaVersion»'
targetCompatibility = '«javaVersion»'
java {
sourceCompatibility = JavaVersion.VERSION_«javaVersion»
targetCompatibility = JavaVersion.VERSION_«javaVersion»
}

configurations.all {
exclude group: 'asm'
Expand Down Expand Up @@ -198,7 +200,9 @@ class ParentProjectDescriptor extends ProjectDescriptor {
}

plugins.withId('war') {
webAppDirName = "«Outlet.WEBAPP.sourceFolder»"
war {
webAppDirectory = file("«Outlet.WEBAPP.sourceFolder»")
}
}
'''
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
* Copyright (c) 2015, 2023 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand Down Expand Up @@ -51,7 +51,7 @@ class PomFile extends TextFile {
<version>${project.version}</version>
</dependency>
«ENDFOR»
«FOR dep : project.externalDependencies.map[maven].filter[artifactId !== null
«FOR dep : project.externalDependencies.map[maven].filter[artifactId !== null].filter[!gradleOnly]»
<dependency>
<groupId>«dep.groupId»</groupId>
<artifactId>«dep.artifactId»</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ abstract class TestProjectDescriptor extends ProjectDescriptor {
maven.artifactId = "junit-jupiter-engine"
maven.scope = Scope.TESTRUNTIME
]
deps += new ExternalDependency()=>[
maven.groupId = "org.junit.platform"
maven.artifactId = "junit-platform-launcher"
maven.scope = Scope.TESTRUNTIME
maven.gradleOnly = true
]
}
return deps
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ public GradleBuildFile buildGradle() {
_builder.append("plugins {");
_builder.newLine();
_builder.append("\t");
_builder.append("id \'com.github.johnrengelman.shadow\' version \'7.1.2\'");
_builder.append("id \'com.github.johnrengelman.shadow\' version \'8.1.1\'");
_builder.newLine();
_builder.append("}");
_builder.newLine();
Expand All @@ -1129,7 +1129,12 @@ public GradleBuildFile buildGradle() {
_builder_1.newLine();
}
}
_builder_1.append("mainClassName = \"org.eclipse.xtext.ide.server.ServerLauncher\"");
_builder_1.append("application {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("mainClass = \"org.eclipse.xtext.ide.server.ServerLauncher\"");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
_builder_1.newLine();
{
Expand All @@ -1139,7 +1144,7 @@ public GradleBuildFile buildGradle() {
_builder_1.append("shadowJar {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("from(project.convention.getPlugin(JavaPluginConvention).sourceSets.main.output)");
_builder_1.append("from(project.extensions.findByType(JavaPluginExtension.class).sourceSets.main.output)");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("configurations = [project.configurations.runtimeClasspath]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,21 @@ public GradleBuildFile buildGradle() {
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("sourceCompatibility = \'");
_builder.append("java {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("sourceCompatibility = JavaVersion.VERSION_");
String _javaVersion = this.getJavaVersion();
_builder.append(_javaVersion, "\t");
_builder.append("\'");
_builder.append(_javaVersion, "\t\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("targetCompatibility = \'");
_builder.append("\t\t");
_builder.append("targetCompatibility = JavaVersion.VERSION_");
String _javaVersion_1 = this.getJavaVersion();
_builder.append(_javaVersion_1, "\t");
_builder.append("\'");
_builder.append(_javaVersion_1, "\t\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("configurations.all {");
Expand Down Expand Up @@ -497,11 +501,17 @@ public CharSequence sourceLayoutGradle() {
_builder.append("plugins.withId(\'war\') {");
_builder.newLine();
_builder.append("\t");
_builder.append("webAppDirName = \"");
_builder.append("war {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("webAppDirectory = file(\"");
String _sourceFolder_18 = this.sourceFolder(Outlet.WEBAPP);
_builder.append(_sourceFolder_18, "\t");
_builder.append("\"");
_builder.append(_sourceFolder_18, "\t\t");
_builder.append("\")");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
return _builder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
* Copyright (c) 2015, 2023 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand Down Expand Up @@ -158,7 +158,11 @@ public String getContent() {
String _artifactId = it.getArtifactId();
return Boolean.valueOf((_artifactId != null));
};
Iterable<ExternalDependency.MavenCoordinates> _filter = IterableExtensions.<ExternalDependency.MavenCoordinates>filter(IterableExtensions.<ExternalDependency, ExternalDependency.MavenCoordinates>map(this.getProject().getExternalDependencies(), _function), _function_1);
final Function1<ExternalDependency.MavenCoordinates, Boolean> _function_2 = (ExternalDependency.MavenCoordinates it) -> {
boolean _isGradleOnly = it.isGradleOnly();
return Boolean.valueOf((!_isGradleOnly));
};
Iterable<ExternalDependency.MavenCoordinates> _filter = IterableExtensions.<ExternalDependency.MavenCoordinates>filter(IterableExtensions.<ExternalDependency.MavenCoordinates>filter(IterableExtensions.<ExternalDependency, ExternalDependency.MavenCoordinates>map(this.getProject().getExternalDependencies(), _function), _function_1), _function_2);
for(final ExternalDependency.MavenCoordinates dep : _filter) {
_builder.append("\t");
_builder.append("\t");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,19 @@ public Set<ExternalDependency> getExternalDependencies() {
};
ExternalDependency _doubleArrow_2 = ObjectExtensions.<ExternalDependency>operator_doubleArrow(_externalDependency_2, _function_2);
deps.add(_doubleArrow_2);
ExternalDependency _externalDependency_3 = new ExternalDependency();
final Procedure1<ExternalDependency> _function_3 = (ExternalDependency it) -> {
ExternalDependency.MavenCoordinates _maven = it.getMaven();
_maven.setGroupId("org.junit.platform");
ExternalDependency.MavenCoordinates _maven_1 = it.getMaven();
_maven_1.setArtifactId("junit-platform-launcher");
ExternalDependency.MavenCoordinates _maven_2 = it.getMaven();
_maven_2.setScope(Scope.TESTRUNTIME);
ExternalDependency.MavenCoordinates _maven_3 = it.getMaven();
_maven_3.setGradleOnly(true);
};
ExternalDependency _doubleArrow_3 = ObjectExtensions.<ExternalDependency>operator_doubleArrow(_externalDependency_3, _function_3);
deps.add(_doubleArrow_3);
}
return deps;
}
Expand Down

0 comments on commit c95196d

Please sign in to comment.