From 91b86be2867223f6b678497f00302f1be5d8b2fb Mon Sep 17 00:00:00 2001 From: gpertzov Date: Sat, 28 Sep 2024 17:15:58 +0300 Subject: [PATCH] Modify build files for Gradle 8, Java 17 --- build.gradle | 102 +++++++++++++++++++++---------------------- core/build.gradle | 12 ++--- desktop/build.gradle | 55 +++++++++++++---------- gradle.properties | 6 ++- 4 files changed, 93 insertions(+), 82 deletions(-) diff --git a/build.gradle b/build.gradle index e08a4f4..8c3e804 100644 --- a/build.gradle +++ b/build.gradle @@ -1,66 +1,62 @@ buildscript { - repositories { - mavenLocal() - mavenCentral() - gradlePluginPortal() - maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } - google() - } - dependencies { - } + repositories { + mavenCentral() + maven { url 'https://s01.oss.sonatype.org' } + gradlePluginPortal() + mavenLocal() + google() + maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } + maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' } + } + dependencies { + } } allprojects { - apply plugin: "eclipse" - apply plugin: "idea" - - version = '1.0' - ext { - appName = "darkly" - gdxVersion = '1.12.1' - roboVMVersion = '2.3.12' - box2DLightsVersion = '1.5' - ashleyVersion = '1.7.3' - aiVersion = '1.8.2' - gdxControllersVersion = '2.1.0' - jUnitVersion = '4.13' - } + apply plugin: 'idea' - repositories { - mavenLocal() - mavenCentral() - google() - gradlePluginPortal() - maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } - maven { url "https://oss.sonatype.org/content/repositories/releases/" } + // This allows you to "Build and run using IntelliJ IDEA", an option in IDEA's Settings. + idea { + module { + outputDir file('build/classes/java/main') + testOutputDir file('build/classes/java/test') } + } + + repositories { + mavenLocal() + mavenCentral() + google() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url "https://oss.sonatype.org/content/repositories/releases/" } + } } -project(":desktop") { - apply plugin: "java-library" - +configure(subprojects) { + apply plugin: 'java-library' - dependencies { - implementation project(":core") - api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion" - api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" - + java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) } -} + } -project(":core") { - apply plugin: "java-library" - - test { - useJUnit() - } - - dependencies { - api "com.badlogicgames.gdx:gdx:$gdxVersion" - testImplementation "junit:junit:$jUnitVersion" - } + compileJava { + options.incremental = true + } } -tasks.eclipse.doLast { - delete ".project" -} \ No newline at end of file +subprojects { + version = '$projectVersion' + ext.appName = 'darkly' + repositories { + mavenCentral() + maven { url 'https://s01.oss.sonatype.org' } + // You may want to remove the following line if you have errors downloading dependencies. + mavenLocal() + maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } + maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' } + maven { url 'https://jitpack.io' } + } +} diff --git a/core/build.gradle b/core/build.gradle index 96c7f55..11e7ad7 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,10 +1,12 @@ -sourceCompatibility = 1.8 [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' -sourceSets.main.java.srcDirs = ["src/main/java"] -sourceSets.test.java.srcDirs = ["src/test/java"] +test { + useJUnit() +} +dependencies { + api "com.badlogicgames.ashley:ashley:$ashleyVersion" + api "com.badlogicgames.gdx:gdx:$gdxVersion" -eclipse.project { - name = appName + "-core" + testImplementation "junit:junit:$jUnitVersion" } diff --git a/desktop/build.gradle b/desktop/build.gradle index 064ab9b..180cf22 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -1,39 +1,48 @@ -sourceCompatibility = 1.8 -sourceSets.main.java.srcDirs = [ "src/" ] +buildscript { + repositories { + gradlePluginPortal() + } +} + +dependencies { + implementation "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion" + implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" + implementation project(':core') +} + +sourceSets.main.java.srcDirs = ["src/"] sourceSets.main.resources.srcDirs = ["../core/assets"] project.ext.mainClassName = "net.gpdev.darkly.desktop.DesktopLauncher" project.ext.assetsDir = new File("../core/assets") task run(dependsOn: classes, type: JavaExec) { - mainClass = project.mainClassName - classpath = sourceSets.main.runtimeClasspath - standardInput = System.in - workingDir = project.assetsDir - ignoreExitValue = true + mainClass = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true } task debug(dependsOn: classes, type: JavaExec) { - mainClass = project.mainClassName - classpath = sourceSets.main.runtimeClasspath - standardInput = System.in - workingDir = project.assetsDir - ignoreExitValue = true - debug = true + mainClass = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + debug = true } task dist(type: Jar) { - manifest { - attributes 'Main-Class': project.mainClassName - } - dependsOn configurations.runtimeClasspath - from { - configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } - } - with jar + manifest { + attributes 'Main-Class': project.mainClassName + } + dependsOn configurations.runtimeClasspath + from { + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } + } + with jar } dist.dependsOn classes - -eclipse.project.name = appName + "-desktop" diff --git a/gradle.properties b/gradle.properties index ff329ac..75ceed3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,7 @@ org.gradle.daemon=true -org.gradle.jvmargs=-Xms128m -Xmx1500m +org.gradle.jvmargs=-Xms512M -Xmx1G -Dfile.encoding=UTF-8 -Dconsole.encoding=UTF-8 org.gradle.configureondemand=false +ashleyVersion=1.7.4 +gdxVersion=1.12.1 +jUnitVersion=4.13 +projectVersion=1.0.0