Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle buildscript refactor. #82

Merged
merged 1 commit into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
134 changes: 52 additions & 82 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,116 +1,86 @@
import org.gradle.internal.os.OperatingSystem

plugins {
id 'com.github.johnrengelman.shadow' version '7.1.0'
id 'java'
id 'application'
id("application")
id("com.github.johnrengelman.shadow").version("7.1.0")
}

group 'com.GwgCommunity'
version '1.0-SNAPSHOT'
tasks.wrapper {
gradleVersion = "7.3.1"
distributionType = Wrapper.DistributionType.BIN
}

group = "com.GwgCommunity"
version = "1.0-SNAPSHOT"

sourceCompatibility = 11
targetCompatibility = 11

project.ext.lwjglVersion = "3.3.0"
project.ext.jomlVersion = "1.10.1"
switch (OperatingSystem.current()) {
repositories { mavenCentral() }

ext.junitVersion = "4.13.2"
ext.lwjglVersion = "3.3.0"
ext.jomlVersion = "1.10.4"

/* ext.lwjglNatives */ switch (OperatingSystem.current()) {
case OperatingSystem.LINUX:
def osArch = System.getProperty("os.arch")
project.ext.lwjglNatives = osArch.startsWith("arm") || osArch.startsWith("aarch64")
ext.lwjglNatives = osArch.startsWith("arm") || osArch.startsWith("aarch64")
? "natives-linux-${osArch.contains("64") || osArch.startsWith("armv8") ? "arm64" : "arm32"}"
: "natives-linux"
break
case OperatingSystem.MAC_OS:
project.ext.lwjglNatives = System.getProperty("os.arch").startsWith("aarch64") ? "natives-macos-arm64" : "natives-macos"
ext.lwjglNatives = System.getProperty("os.arch").startsWith("aarch64") ? "natives-macos-arm64" : "natives-macos"
break
case OperatingSystem.WINDOWS:
def osArch = System.getProperty("os.arch")
project.ext.lwjglNatives = osArch.contains("64")
ext.lwjglNatives = osArch.contains("64")
? "natives-windows${osArch.startsWith("aarch64") ? "-arm64" : ""}"
: "natives-windows-x86"
break
}

repositories {
mavenCentral()
}

application {
mainClass = 'scenes.TextRenderingDemo'
}

jar {
manifest {
attributes(
'Main-Class': 'scenes.UIRenderingDemo',
)
}
dependencies {
testImplementation("junit:junit:$junitVersion")
implementation(platform("org.lwjgl:lwjgl-bom:$lwjglVersion"))
implementation("org.lwjgl:lwjgl")
implementation("org.lwjgl:lwjgl-glfw")
implementation("org.lwjgl:lwjgl-openal")
implementation("org.lwjgl:lwjgl-opengl")
implementation("org.lwjgl:lwjgl-stb")
runtimeOnly("org.lwjgl:lwjgl::$lwjglNatives")
runtimeOnly("org.lwjgl:lwjgl-glfw::$lwjglNatives")
runtimeOnly("org.lwjgl:lwjgl-openal::$lwjglNatives")
runtimeOnly("org.lwjgl:lwjgl-opengl::$lwjglNatives")
runtimeOnly("org.lwjgl:lwjgl-stb::$lwjglNatives")
implementation("org.joml:joml:$jomlVersion")
}


task fatJar(type: Jar) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest.from jar.manifest
classifier = 'all'
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
}

sourceSets {
test {
java {
srcDir 'src/main/test'
}
application {
mainClass = "scenes.UIRenderingDemo"
if (OperatingSystem.current() == OperatingSystem.MAC_OS) {
applicationDefaultJvmArgs = ["-XstartOnFirstThread"]
}
}

test {
testLogging {
events "passed", "skipped", "failed"
}
useJUnit()
testLogging.events("passed", "skipped", "failed")
}

dependencies {
testImplementation group: 'junit', name: 'junit', version: '4.12'

implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")

implementation "org.lwjgl:lwjgl"
implementation "org.lwjgl:lwjgl-glfw"
implementation "org.lwjgl:lwjgl-openal"
implementation "org.lwjgl:lwjgl-opengl"
implementation "org.lwjgl:lwjgl-stb"
runtimeOnly "org.lwjgl:lwjgl::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-glfw::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-openal::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-stb::$lwjglNatives"
implementation "org.joml:joml:${jomlVersion}"
}

task generateApiDocs(type: Javadoc) {
title = ""
options.noTimestamp(false)
source sourceSets.main.allJava
classpath = configurations.runtimeClasspath
options.encoding 'UTF-8'
destinationDir = file("build/generated-files")
options.addStringOption("doclet", "com.microsoft.doclet.DocFxDoclet")
options.docletpath = [file("lib/docfx-doclet-1.0-SNAPSHOT-jar-with-dependencies.jar")]
dependsOn build
}

// Possible thing to look into later... this doesn't work, I am too tired rn to try making it work.
task execute(type: JavaExec) {
dependsOn fatJar
classpath = fatJar.outputs.files
// main('com.name.enginetester.GameLoop')

if (OperatingSystem.current() == OperatingSystem.MAC_OS) {
jvmArgs '-XstartOnFirstThread'
}
tasks.register("generateApiDocs", Javadoc) {
it.title = ""
it.options.noTimestamp(false)
it.source(sourceSets.main.allJava)
it.classpath = configurations.runtimeClasspath
it.options.encoding("UTF-8")
it.destinationDir = file("build/generated-files")
it.options.addStringOption("doclet", "com.microsoft.doclet.DocFxDoclet")
it.options.docletpath = [file("lib/docfx-doclet-1.0-SNAPSHOT-jar-with-dependencies.jar")]
it.dependsOn(build)
}

// aliases
tasks.register("fatJar") { it.dependsOn(tasks.shadowJar) }
tasks.register("execute") { it.dependsOn(tasks.runShadow) }
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 0 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#Tue Dec 07 22:11:29 CST 2021
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME