Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
java-version: '25'
- uses: gradle/actions/setup-gradle@v6
with:
cache-read-only: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/chunky-2.4.x' }}
- name: Grant execute permission for gradlew
Expand All @@ -46,12 +44,12 @@ jobs:
;;
esac
- name: Upload build
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: Chunky Build
path: build/installer
- name: Upload build
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: Chunky Core
path: build/chunky-core-*.jar
74 changes: 48 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project.version = getVersion()
println "Building version ${project.version}"
def projectVersion = getVersion().toString()
println "Building version ${projectVersion}"

allprojects {
repositories {
Expand All @@ -15,7 +15,7 @@ buildscript {
}
}
dependencies {
classpath 'org.openjfx:javafx-plugin:0.0.13'
classpath 'org.openjfx:javafx-plugin:0.1.0'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.46.0'
}
}
Expand All @@ -33,20 +33,10 @@ subprojects {
java {
toolchain {
// default java version for the project
languageVersion = JavaLanguageVersion.of(17)
}
}
compileTestJava {
// compile tests using more recent features
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(21)
languageVersion = JavaLanguageVersion.of(25)
}
}
test {
// run tests using more recent features
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(21)
}
useJUnitPlatform()

// Always run tests, even when nothing changed.
Expand All @@ -55,7 +45,7 @@ subprojects {
finalizedBy jacocoTestReport // report is always generated after tests run (it's very cheap)
}
jacoco {
toolVersion = "0.8.11"
toolVersion = "0.8.15"
}
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
Expand Down Expand Up @@ -113,19 +103,37 @@ defaultTasks 'release'

task releaseVersion {
doLast {
tryCommand([ 'git', 'tag', '-a', "${project.version}", '-m', "Version ${project.version}" ], true)
tryCommand([ 'git', 'tag', '-a', "${projectVersion}", '-m', "Version ${projectVersion}" ], true)
}
}

task prepareReleaseLibraries {
dependsOn ':chunky:copyExternalDependencies'
outputs.upToDateWhen { false }

doLast {
def libDir = file('chunky/lib')
libDir.mkdirs()
copy {
from project(':chunky').tasks.named('copyExternalDependencies').get().outputs.files
into libDir
}
}
}

task versionInfo(type: JavaExec) {
dependsOn 'copyArtifacts'
dependsOn 'prepareReleaseLibraries'
outputs.upToDateWhen { false }

outputs.files file("build/chunky-${project.version}.jar")
description 'Writes build/chunky-VERSION.jar, latest.json and updates chunky-core-VERSION.jar/version.json'
outputs.file(layout.buildDirectory.file("chunky-${projectVersion}.jar"))

description = 'Writes build/chunky-VERSION.jar, latest.json and updates chunky-core-VERSION.jar/version.json'

classpath = project(':releasetools').sourceSets.main.runtimeClasspath
mainClass.set('releasetools.ReleaseBuilder')
args "${project.version}", "release_notes-${project.version}.txt"

args projectVersion, "release_notes-${projectVersion}.txt"
}

task release {
Expand All @@ -138,30 +146,34 @@ task release {
destinationDirectory.mkdirs()
file("./latest.json").renameTo("${destinationDirectory}/latest.json")
fileTree(buildDir).matching {
include "*-${project.version}.*"
include "*-${projectVersion}.*"
}.each {
it.renameTo("${destinationDirectory}/${it.name}")
}
}
}

def launcherArchives = project(':launcher').configurations.archives

task buildReleaseJar(type: Jar) {
dependsOn ':launcher:assembleDist'
dependsOn 'prepareReleaseLibraries'
dependsOn 'versionInfo'

archiveFileName = "chunky-${project.version}.jar"
archiveFileName = "chunky-${projectVersion}.jar"
destinationDirectory = file('build/installer')
manifest {
attributes('Main-Class': 'se.llbit.chunky.launcher.ChunkyLauncher')
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

into('lib') {
from fileTree('chunky/lib').include('*.jar')
from file("build/chunky-core-${project.version}.jar")
from file("build/chunky-core-${projectVersion}.jar")
}

from {
project(':launcher').configurations.archives.allArtifacts.files.collect {
launcherArchives.allArtifacts.files.collect {
zipTree(it)
}
}
Expand All @@ -170,10 +182,20 @@ task buildReleaseJar(type: Jar) {
rename "latest.json", "version.json"
}

task copyArtifacts(type: Copy) {
task copyArtifacts {
dependsOn subprojects.jar
from subprojects.jar
into buildDir
dependsOn ':chunky:jar'
outputs.upToDateWhen { false }

doLast {
def sourceJar = project(':chunky').tasks.named('jar').get().archiveFile.get().asFile
def rootJar = file("build/chunky-core-${projectVersion}.jar")
copy {
from sourceJar
into rootJar.parentFile
rename { rootJar.name }
}
}
}

/** Helper function to run a command. Returns the command output if the command succeeded. */
Expand Down
1 change: 1 addition & 0 deletions chunky/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/bin/
/build/
/lib/
/src/gen-res/
70 changes: 42 additions & 28 deletions chunky/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ apply plugin: 'application'
apply plugin: 'maven-publish'
apply plugin: 'org.openjfx.javafxplugin'

mainClassName = 'se.llbit.chunky.main.Chunky'
archivesBaseName = 'chunky-core'
application {
mainClass = 'se.llbit.chunky.main.Chunky'
}

base {
archivesName = 'chunky-core'
}

configurations {
implementation.extendsFrom configurations.jsonlib
Expand All @@ -29,7 +34,7 @@ dependencies {
}

javafx {
version = '17.0.11'
version = '25'
configuration = 'implementation'
modules = ['javafx.base', 'javafx.controls', 'javafx.fxml']
}
Expand All @@ -52,7 +57,7 @@ jar {
zipTree(it)
}
manifest {
attributes('Main-Class': mainClassName)
attributes('Main-Class': application.mainClass)
}
into('se/llbit/chunky/main') {
from file("src/gen-res/Version.properties")
Expand All @@ -78,25 +83,35 @@ sourceSets {

processResources.dependsOn 'updateVersionString'

def projectVersion = providers.provider {
version.toString()
}

task updateVersionString {
description 'Store the current version string in src/gen-res/Version.properties'
description = 'Store the current version string in src/gen-res/Version.properties'

def versionFile = layout.projectDirectory.file('src/gen-res/Version.properties')

outputs.upToDateWhen {
def props = new Properties()
def output = file('src/gen-res/Version.properties')
if (output.isFile()) {
output.withInputStream { stream -> props.load(stream) }
if (versionFile.asFile.isFile()) {
versionFile.asFile.withInputStream { stream ->
props.load(stream)
}
}
props['version'] == project.version
props['version'] == projectVersion.get()
}

doLast {
file('src/gen-res').mkdirs()
def date = new Date()
def versionFile = file('src/gen-res/Version.properties')
ant.propertyfile(file: versionFile) {
entry(key: 'version', value: project.version)
entry(key: 'gitSha', value: tryCommand(['git', 'rev-parse', 'HEAD']).trim())
versionFile.asFile.parentFile.mkdirs()

def gitSha = rootProject.tryCommand(
['git', 'rev-parse', 'HEAD']
).trim()

ant.propertyfile(file: versionFile.asFile) {
entry(key: 'version', value: projectVersion.get())
entry(key: 'gitSha', value: gitSha)
}
}
}
Expand All @@ -112,12 +127,13 @@ task sourcesJar(type: Jar) {
}

task copyExternalDependencies(type: Copy) {
into "${buildDir}/${libsDirName}"
into layout.buildDirectory.dir("libs")
from configurations.externalDependencies
}

artifacts {
archives javadocJar, sourcesJar
tasks.named("assemble") {
dependsOn(javadocJar)
dependsOn(sourcesJar)
}

publishing {
Expand All @@ -129,7 +145,7 @@ publishing {
packaging = "jar"
description = "Minecraft mapping and rendering tool"
url = "http://chunky.llbit.se"
artifactId = archivesBaseName
artifactId = base.archivesName
version = "2.5.0-SNAPSHOT"

licenses {
Expand All @@ -156,22 +172,20 @@ publishing {

// fix dependency scopes (see https://discuss.gradle.org/t/maven-publish-plugin-generated-pom-making-dependency-scope-runtime/7494/9)
// and filter dependencies
def implementationDependencies = configurations.implementation.allDependencies
publishing.publications.all {
pom.withXml {
asNode().dependencies.'*'.findAll() {
it.scope.text() == 'runtime' && project.configurations.implementation.allDependencies.find { dep ->
asNode().dependencies.'*'.findAll {
it.scope.text() == 'runtime' &&
implementationDependencies.find { dep ->
dep.name == it.artifactId.text()
}
}.each() {
}.each {
if (it.groupId.text() == "org.openjfx") {
// remove javafx dependencies for now (maybe make them optional in the future?)
it.parent().remove(it)
// it.appendNode('optional', 'true')
} else if (it.groupId.text() == "se.llbit") {
// se.llbit dependencies are included in chunky-core
it.parent().remove(it)
} else {
// everything else is a dependency as usual
it.scope*.value = 'compile'
}
}
Expand All @@ -181,8 +195,8 @@ publishing {

repositories {
maven {
name 'Build'
url layout.buildDirectory.dir('maven')
name = 'Build'
url = layout.buildDirectory.dir('maven')
}
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 4 additions & 3 deletions launcher/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
apply plugin: 'application'
apply plugin: 'org.openjfx.javafxplugin'

mainClassName = 'se.llbit.chunky.launcher.ChunkyLauncher'
application {
mainClass = 'se.llbit.chunky.launcher.ChunkyLauncher'
}

configurations {
bundled
Expand All @@ -16,7 +18,6 @@ dependencies {
implementation project(':lib')

testImplementation 'com.google.truth:truth:1.1.3'
testImplementation 'junit:junit:4.13.2'
}

java {
Expand Down Expand Up @@ -51,7 +52,7 @@ sourceSets {
}

jar {
manifest.attributes 'Main-Class': mainClassName
manifest.attributes 'Main-Class': application.mainClass

// Include classes from the common library.
from project(':lib').configurations.archives.allArtifacts.files.collect {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.ParseException;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;

public class ChunkyLauncherCliParseTest {
@Test
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' // java toolchain resolver
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0' // java toolchain resolver
}

rootProject.name = 'chunky'
Expand Down
Loading