Skip to content

Commit

Permalink
Move to Java 21 (#7077)
Browse files Browse the repository at this point in the history
* Initial cut for Java 21 support + lots of debug

* Update PMD to 7.0.0-rc4

* PMD now passes

* Checkstyle now passes

* grdle 8.5 for full Java 21 support

* Use official monocole

* Initial cut for Java 21 support + lots of debug

* Update PMD to 7.0.0-rc4

* PMD now passes

* Checkstyle now passes

* grdle 8.5 for full Java 21 support

* Updates to reflect latest 17 and 21 releases

* Tidy-up after 1st successful build

* Tidy-up after 1st successful build

* Tidy-up after 1st successful build

* Updated:
pmd to 7.0.0
gradle to 8.7
checkstyle to 10.15.0
spotbugs to 4.8.3

* PMD updates

* Formatted output for downloadJRE and downloadJavaFXModules a little.
Refactored code a little
Removed few warnings detected by IDEA.

* Removed an unnecessary empty line.

* Use Linux 21.0.1 for aarch64 JavaFX
Removed trailing spaces (IDEA)
Applied few recommendations from Spotbugs (just to test it)

* Updated Spotbugs Plugin to 6.0.9 (the solution was taken from spotbugs/spotbugs-gradle-plugin#972 (comment))

* Update deps

* Initial cut for Java 21 support + lots of debug

* Update PMD to 7.0.0-rc4

* PMD now passes

* Checkstyle now passes

* grdle 8.5 for full Java 21 support

* Initial cut for Java 21 support + lots of debug

* Update PMD to 7.0.0-rc4

* PMD now passes

* Updates to reflect latest 17 and 21 releases

* Tidy-up after 1st successful build

* Tidy-up after 1st successful build

* Tidy-up after 1st successful build

* Updated:
pmd to 7.0.0
gradle to 8.7
checkstyle to 10.15.0
spotbugs to 4.8.3

* PMD updates

* Formatted output for downloadJRE and downloadJavaFXModules a little.
Refactored code a little
Removed few warnings detected by IDEA.

* Removed an unnecessary empty line.

* Use Linux 21.0.1 for aarch64 JavaFX
Removed trailing spaces (IDEA)
Applied few recommendations from Spotbugs (just to test it)

* Updated Spotbugs Plugin to 6.0.9 (the solution was taken from spotbugs/spotbugs-gradle-plugin#972 (comment))

* Update deps

* Last fixes for full pre release build to work

* Add comments for removal of SecurityManager

* * updated com.github.spotbugs to 6.0.15
* updated checkstyle to 10.17.0
* updated pmd to 7.1.0
* updated spotbugs to 4.8.5

* Corrected the distTar failure on Windows (#152)

* Corrected the error UncheckedIOException related to the buildDirectory. It was resolved by Gradle to `C:...\pcgen\property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactorySFixedDirectory, C:...\pcgen\build))\launch4j`
Updated few dependencies as well.

Signed-off-by: Vest <[email protected]>

* Formatted build.gradle, by putting a space character after "version:"

Signed-off-by: Vest <[email protected]>

---------

Signed-off-by: Vest <[email protected]>

* Removed explicit "buildDirectory" variable. Replaced it with the lazy layout.buildDirectory
Replaces projectDir with layout.projectDirectory, because the variable projectDir hides the property Project.projectDir
Replaced "new File" with "file"
Replaced many "eager" tasks with lazy tasks.register.
Reconfigured many tasks in a lazy way
Updated task-tree to v4.0.0
Renamed task all to allTasks, because it was confusing what it does.
Formatted few lines in build scripts.

Signed-off-by: Vest <[email protected]>

* Added an explicit dependency between tasks -> this should be changed to input/output files instead (because the Jar task creates an *output* file, that will be an *input* file for the copyToOutput task).
Corrected a wrong code of genProjectNsis

Signed-off-by: Vest <[email protected]>

* converted genProjectNsis to the "lazy" API. Removed buildDirectory as a variable, replaced it with layout.buildDirectory

Signed-off-by: Vest <[email protected]>

* converted buildNsis to the "lazy" API.

Signed-off-by: Vest <[email protected]>

* Removed 32-bit version from pcgen.nsi (NSIS installer)
Replaced few tasks creation calls with the "register".
Added /WX key (fail with warnings) for NSIS
Corrected few "delete" calls

Signed-off-by: Vest <[email protected]>

* Upgrade Grade wrapper from 8.7 to 8.8

Signed-off-by: Vest <[email protected]>

* Formatted code a little, replaced $projectDir with layout.projectDirectory
Fixed failed :prepareRelease task. Formatted the description, so it will not have a long line in source code.

Signed-off-by: Vest <[email protected]>

* Fixed a typo in the property name (build.gradle)

* Corrected an issue with JavaFX modules (a wrong relative folder was used).
Simplified the :idea task using "fileTree"

* Corrected the :genDataList task

* Refactored release.gradle, this reduced the number of lines.

* Refactored release.gradle, this reduced the number of lines.

* Replaced eager tasks with lazy
Replaced projectDir with layout.projectDirectory
Moved :downloadJRE and :downloadJavaFXModules to the "lazy" (doLast) section. Now, JRE and JavaFX modules are downloaded only, when the task is required/called.
Slightly improved the logging for :downloadJRE
Detached :downloadJRE from :downloadJavaFXModules (they are independent). Removed codes, where the modules and JDK were extracted. It seems that the new JDK doesn't have files that we omitted in the past.
Adjusted dependencies, because :downloadJRE is an independent task now.
Formatted pcgen.nsi

* Corrected the broken tasks: :jpackageImage, :buildNsis
Removed :clean from :prepareRelease.

* Corrected types of Files in :checksum

Signed-off-by: Vest <[email protected]>

* Refactored build.gradle:
* renamed :all to :allTasks in comments
* :downloadJavaFXModules is lazy, tries to reuse the downloaded files, removes empty folders (Window JRE still contains empty folders - this is TODO)
* :downloadJavaFXModules remove local "mods/" from the task. This task is used to download modules for all supported platforms only
* :downloadJavaFXLocal added for local builds only (used for different tests, for :run). It isn't used for packaging, but for compilation only
* :extractJavaFXLocal extracts downloaded JavaFX binaries into mods/.
* :compileJava - we don't download all JREs and JavaFX artifacts anymore. Added a dependency to :extractJavaFXLocal
* :test - removes dependencies to :downloadJRE, :downloadJavaFXModules

Corrected a typo in build-gradle.xml Ant
Now we add :compileJava as a direct dependency to all ant tasks, where plugins are built.

* Removed unhelpful println calls from some tasks such as :copyToLibs or :downloadJRE
Corrected a bug in :downloadJRE, now we delete the JDK folder, if it contains an old JDK. Previously, we couldn't extract JDK into it (unfortunately, the deletion removes JavaFX, if it has been downloaded previously).
:downloadJavaFXLocal - OS_NAME isn't used, because it is "private"
:clean moved to the bottom, and it deletes probably everything.
:run doesn't require all JDKs and all JavaFX modules. It simply depends on :extractJavaFXLocal now. Two dependencies were removed.
Slightly improved the logging of :buildNsis, but this steps requires more testing.

* Fixed a broken plugin, caused by 187f6c2

* Removed println in PlayerCharacter.java, that was added in #7056

* Updated dependencies in build.gradle and reporting.gradle

* Upgraded pmd found several issues in source code that were corrected:
* This collection could be an EnumMap
* Unnecessary explicit array creation for varargs method call
* Lambda expression could be written as a method reference: xxxxxx::yyyyyyy

* Mistakenly collapsed imports in a previous commit, and violated :checkstyleMain

* Upgraded gradlew to 8.9
Refactored :downloadJavaFXModules, :downloadJRE, :genDataList, :genProjectNsis to support "up-to-date" (kind of a caching) feature from gradle
Added more logging to :buildNsis

* Moved the creation of the nsisRelease folder from :genProjectNsis to :buildNsis

* Fixed *.xsl templates: they were using a function str:substring-after-last from xsltsl (https://www.w3.org/TR/xslt11/). The second parameter has the name "chars", but the code was using "char".

* Refactored :jpackage, and made is shorter.

* :clean - delete files/folders that are generated during the build.

* :clean - delete files/folders that are generated during the build: outputsheets/d20/western/htmlxml/psheet_fantasy_std.htm

* Refactored :copyMasterSheets

* Attempt to resolve the bug, when the JRE is packaged before JavaFX modules are downloaded.

* Upgraded JDK and JavaFX to 21.0.4

* Language bundle date updates

* Refactored Gradle scripts to support Mac builds (#175)

* Upgraded Gradle wrapper to 8.10.2

* Updated com.github.spotbugs to 6.0.23
Updated checkstyle to 10.18.1
Updated pmd to 7.6.0
Reffactored Main.java -> use streams, now it has a "draft" branch that is executed, when the application is launched from Mac's bundle

* Fixed an error in ConfigurationSettings.java detected by Checkstyle.

* Corrected a logical error in ConfigurationSettings.java

---------

Signed-off-by: Vest <[email protected]>
Co-authored-by: Vest <[email protected]>
  • Loading branch information
karianna and Vest authored Sep 30, 2024
1 parent 816c09f commit b85d15d
Show file tree
Hide file tree
Showing 59 changed files with 1,166 additions and 1,094 deletions.
3 changes: 1 addition & 2 deletions build-gradle.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
build-gradle.xml - a stub ant file to allow gradle to include just the plugin build tasks.
build-gradle.xml - a stub ant file to allow Gradle to include just the plugin build tasks.
-->
<project name="pcgen" basedir=".">
<property name="manifest.file" value="code/manifest" />
Expand Down
837 changes: 436 additions & 401 deletions build.gradle

Large diffs are not rendered by default.

28 changes: 15 additions & 13 deletions code/gradle/autobuild.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,42 @@ import java.time.LocalDateTime
*/
ext {
if (System.env.BUILD_NUMBER) {
destAutobuildDir = '/home/pcgen1/public_html/autobuilds/'
destAutobuildDir = file('/home/pcgen1/public_html/autobuilds/')
} else {
destAutobuildDir = "${buildDir}/autobuilds/"
destAutobuildDir = layout.buildDirectory.dir("autobuilds").get()
}

buildTimestamp = LocalDateTime.now(Clock.systemUTC())
}

task copyDocs(type: Sync) {
tasks.register("copyDocs", Sync) {
from 'docs'
into "${destAutobuildDir}/pcgen-docs/"
into destAutobuildDir.dir("pcgen-docs/")
}

task copyDist(type: Sync, dependsOn: 'buildDist') {
from "${buildDir}/distributions"
into "${destAutobuildDir}/downloads/"
tasks.register("copyDist", Sync) {
dependsOn buildDist
from layout.buildDirectory.dir("distributions")
into destAutobuildDir.dir("downloads")
}

task copySite(type: Copy) {
tasks.register("copySite", Copy) {
// Ensure this always runs - we don't want an incorrect date
outputs.upToDateWhen { false }
from "${projectDir}/code/gradle/site"
into "${destAutobuildDir}"
from layout.projectDirectory.dir("code/gradle/site")
into destAutobuildDir
expand(copyright: Calendar.instance.get(Calendar.YEAR), version: version, timestamp: buildTimestamp,
simpleVersion: version.replaceAll('-SNAPSHOT', '').replaceAll(/\./, ''))
}

task copyInstaller(type: Copy) {
tasks.register("copyInstaller", Copy) {
// Ensure this always runs - we don't want an outdated installer
outputs.upToDateWhen { false }
from "${releaseDir}"
into "${destAutobuildDir}/downloads/"
into destAutobuildDir.dir("downloads")
}

// The Main Task
task deployAutobuild (dependsOn: ['copyDocs', 'copyDist', 'copySite', 'copyInstaller']) {
tasks.register("deployAutobuild") {
dependsOn copyDocs, copyDist, copySite, copyInstaller
}
56 changes: 33 additions & 23 deletions code/gradle/distribution.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ext {
}

programDistsImage = copySpec {
from("$buildDir/launch4j") {
from(layout.buildDirectory.dir("launch4j")) {
include 'pcgen.exe'
}
}
Expand All @@ -55,7 +55,7 @@ ext {
from('code') {
include 'LICENSE'

eachFile{ file ->
eachFile { file ->
if(file.getName().endsWith(".sh")) {
file.setMode(0755)
}
Expand All @@ -64,7 +64,7 @@ ext {
}

libsDistsImage = copySpec {
from("$buildDir/libs") {
from(layout.buildDirectory.dir("libs")) {
into 'libs'
exclude 'pcgen-*.jar'
}
Expand All @@ -83,7 +83,7 @@ ext {
}
}

application{
application {
// Output the startScripts (.bat and .sh) in main distribute folder rather than .bin
executableDir = ""
applicationDefaultJvmArgs = ["-Dsun.java2d.d3d=false"]
Expand All @@ -96,33 +96,39 @@ application{
applicationDistribution.with(programDistsImage)
}

run {
tasks.named("run") {
dependsOn assemble, extractJavaFXLocal
// Required to fixed incorrectly added "--module-path" and adds correct modules.
doFirst {

jvmArgs = ["-ea", // -ea enables assertions
"--enable-preview", // enable Java preview features
"--module-path",
"${projectDir}/mods/lib/",
"--add-modules", "javafx.controls,javafx.web,javafx.swing,javafx.fxml"
"--module-path", layout.projectDirectory.dir("mods/lib").asFile.absolutePath,
"--add-modules", "javafx.controls,javafx.web,javafx.swing,javafx.fxml,javafx.graphics"
]

}
}
tasks.run.dependsOn(assemble)
tasks.run.dependsOn(downloadJavaFXModules)

installDist.doLast{
delete {
delete fileTree("${buildDir}/install/pcgen/lib") {
include 'javafx-*'
tasks.named("installDist") {
dependsOn createExe
doLast{
delete {
delete fileTree(layout.buildDirectory.dir("install/pcgen/lib")) {
include 'javafx-*'
}
}
}
}

[distZip, distTar, installDist]*.dependsOn createExe
tasks.named("distTar") {
dependsOn createExe
}

tasks.named("distZip") {
dependsOn createExe
}

task testZip(type: Zip, dependsOn: ['converterJar', 'copyToLibs', 'copyToOutput']) {
tasks.register("testZip", Zip) {
dependsOn converterJar, copyToLibs, copyToOutput
archiveClassifier.set('test')
into(zipRootFolder) {
with dataDistsImage
Expand All @@ -134,23 +140,25 @@ task testZip(type: Zip, dependsOn: ['converterJar', 'copyToLibs', 'copyToOutput'
}
}

task dataZip(type: Zip, dependsOn: ['copyMasterSheets']) {
tasks.register("dataZip", Zip) {
dependsOn copyMasterSheets
archiveClassifier.set('data')
into(zipRootFolder) {
with dataDistsImage
with autobuildSpec
}
}

task docsZip(type: Zip) {
tasks.register("docsZip", Zip) {
archiveClassifier.set('docs')
into(zipRootFolder) {
with docsDistsImage
with autobuildSpec
}
}

task programZip(type: Zip, dependsOn: ['converterJar', 'createExe']) {
tasks.register("programZip", Zip) {
dependsOn converterJar, createExe
archiveClassifier.set('program')
into(zipRootFolder) {
with programDistsImage
Expand All @@ -159,14 +167,16 @@ task programZip(type: Zip, dependsOn: ['converterJar', 'createExe']) {
}
}

task libsZip(type: Zip, dependsOn: 'copyToLibs') {
tasks.register("libsZip", Zip) {
dependsOn copyToLibs
archiveClassifier.set('libs')
into(zipRootFolder) {
with libsDistsImage
with autobuildSpec
}
}

task buildDist(dependsOn: ['dataZip', 'docsZip', 'programZip', 'libsZip', 'runtimeZip']) {
tasks.register("buildDist") {
dependsOn dataZip, docsZip, programZip, libsZip, runtimeZip
description = "Build the five zip files (docs, data, program, libs and full) which comprise the autobuild distribution."
}
Loading

0 comments on commit b85d15d

Please sign in to comment.