Skip to content

Commit fd49f71

Browse files
committed
Grawlingson: CORE Update entire compile process using !30 clean up CLI work
* Adds patcher and core openrsc client the IdleRSC project * app = idlersc app files * client = openrsc client * patcher = idlersc patcher "* Fix CLI due to input causing the program to crash on startup. * Fix transitive dependency spitting out an error on [startup](https://www.slf4j.org/codes.html#StaticLoggerBinder). * Fix `.editorconfig` causing IDE formatting to clash with spotless' preferred formatting. * Fix typo in debugger button. (This isn't 100% fixed, I'll investigate later.) * Fix infinite looping bug when the cache creation window is exited. * Add more documentation. * Add `patcher` and `client` subprojects. * Add `run` task to gradle for development/debugging purposes. This can be invoked via IDE or command line using the gradle wrapper. Bonus - args can be passed via the gradle --args option. For example, `./gradlew run --args='--auto-login --username username --password password --init-cache coleslaw'` * Move main project to `app` subproject due to shared dependencies. * ~~Bump JDK required to 11.~~ Keeping minimum required JDK at 8. * Add convenience scripts to update code shared from `core` repository. * Played musical chairs with level 3 chickens. Spoiler: I lost, every time."
1 parent cc92de0 commit fd49f71

File tree

630 files changed

+61832
-119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

630 files changed

+61832
-119
lines changed

.gitlab-ci.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ stages:
1313
before_script:
1414
- export GRADLE_USER_HOME=`pwd`/.gradle
1515
- apt-get update --quiet --assume-yes
16-
- apt-get install --quiet --assume-yes git
16+
- apt-get install --quiet --assume-yes git make
1717

1818
# git rev-list --count does not work correctly with the default settings.
1919
variables:
@@ -37,15 +37,15 @@ cache:
3737
format:
3838
stage: format
3939
script:
40-
- ./gradlew --build-cache --parallel spotlessCheck
40+
- make check-format
4141

4242
# Explicitly state to gradle wrapper that we want the cache to be enabled,
4343
# build a release zip, then upload the zip artifact to Gitlab CI for end-users
4444
# to download.
4545
build:
4646
stage: build
4747
script:
48-
- ./gradlew --build-cache --parallel release
48+
- make release
4949
artifacts:
5050
paths:
5151
- ./*.zip
@@ -54,8 +54,7 @@ build:
5454
pages:
5555
stage: pages
5656
script:
57-
- ./gradlew --build-cache --parallel javadoc
58-
- cp -r build/docs/javadoc public
57+
- make build-javadoc
5958
artifacts:
6059
paths:
6160
- public

Cache/config.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Menus:1

Makefile

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Terminal Colours
2+
RED?=$(shell tput setaf 1)
3+
GREEN?=$(shell tput setaf 2)
4+
YELLOW?=$(shell tput setaf 3)
5+
BLUE?=$(shell tput setaf 4)
6+
BOLD?=$(shell tput bold)
7+
RST?=$(shell tput sgr0)
8+
9+
##@ Build
10+
.PHONY: build
11+
build: ## Build the project
12+
@./gradlew build
13+
14+
.PHONY: release
15+
release: ## Create a release archive
16+
@./gradlew release
17+
18+
.PHONY: clean
19+
clean: ## Clean everything up
20+
@./gradlew clean
21+
22+
##@ Maintenance
23+
.PHONY: check-cache
24+
check-cache: ## Check cache contents and update if necessary
25+
@scripts/check-cache.sh
26+
27+
.PHONY: check-client
28+
check-client: ## Check client contents and update if necessary
29+
@scripts/check-client.sh
30+
31+
.PHONY: update-core
32+
update-core: ## Update core repository
33+
@scripts/get-core-repository.sh
34+
35+
##@ Utility/CI
36+
.DEFAULT_GOAL = help
37+
38+
.PHONY: run
39+
run: ## Compile & run the project
40+
@./gradlew run
41+
42+
.PHONY: build-javadoc
43+
build-javadoc: ## Build API documentation
44+
@./gradlew app:javadoc
45+
@cp -r app/build/docs/javadoc public
46+
47+
.PHONY: check-format
48+
check-format: ## Check if source code is properly formatted
49+
@./gradlew spotlessCheck
50+
51+
.PHONY: format
52+
format: ## Format source code
53+
@./gradlew spotlessApply
54+
55+
.PHONY: help
56+
help: ## Display this help
57+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n $(YELLOW)make$(RST) $(BLUE)command$(RST)\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " $(BLUE)%-15s$(RST) %s\n", $$1, $$2 } /^##@/ { printf "\n$(BOLD)%s$(RST)\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

app/build.gradle

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
plugins {
2+
// Facilitates Java compilation
3+
id 'java'
4+
// For formatting source-code
5+
alias(libs.plugins.spotless)
6+
// Ensure jars are reproducible
7+
id 'reproducible-archives'
8+
// Bundle all dependencies (a.k.a. create a fat jar)
9+
id 'bundle-dependencies'
10+
// Use metadata from git
11+
id 'git-metadata'
12+
// Enable additional compiler warnings
13+
id 'compiler-warnings'
14+
}
15+
16+
// Tasks not related to build are split out into their own gradle scripts
17+
// in order to keep build.gradle as compact as possible.
18+
apply from: "$project.rootDir/spotless.gradle"
19+
20+
// Where dependencies are fetched from
21+
repositories {
22+
mavenCentral()
23+
maven { url "https://maven.scijava.org/content/repositories/public/" }
24+
maven { url 'https://jitpack.io' }
25+
}
26+
27+
dependencies {
28+
// Ensure gradle is aware of the patched client dependency
29+
implementation files(new File(project(':patcher').getBuildDir(), 'libs/patched_client.jar'))
30+
// Used to find/populate scripts
31+
implementation libs.reflections
32+
// Dependency of reflections spits out an error when it is not included in the jar.
33+
// https://www.slf4j.org/codes.html#StaticLoggerBinder
34+
implementation libs.slf4j.nop
35+
// Used to parse/validate CLI arguments
36+
implementation libs.commons.cli
37+
38+
39+
implementation project(path: ':client')
40+
}
41+
42+
tasks.named('compileJava') {
43+
// Create resources before compileJava runs
44+
dependsOn ':createClientCache', ':copyMapData', ':buildPatchedClient'
45+
46+
// Run spotlessApply after successful compilation rather than before, so
47+
// that any developer errors can be dealt with prior to formatting
48+
finalizedBy spotlessApply
49+
}
50+
51+
tasks.named('jar') {
52+
manifest {
53+
attributes(
54+
// Define entry point for application
55+
'Main-Class': 'bot.Main',
56+
// Embed version/build information in application
57+
'Build-Commit-Hash': "${gitCommitHash()}",
58+
'Build-Commit-Date': "${gitCommitDate()}",
59+
'Build-Commit-Count': "${gitCommitCount()}",
60+
'Build-Jdk' : "${System.properties['java.version']}",
61+
)
62+
}
63+
64+
// FTBFS: Set duplicate handling strategy for module-info.class.
65+
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
66+
}
67+
68+
tasks.register('copyJar') {
69+
// Final JAR
70+
group 'build'
71+
description 'copy app.jar to main dir'
72+
73+
inputs.file "${project(':app').getBuildDir()}/libs/app.jar"
74+
outputs.file "Idlersc.jar"
75+
76+
doLast {
77+
copy {
78+
from("${project(':app').getBuildDir()}/libs") {
79+
rename 'app.jar', "${rootProject.name}.jar"
80+
}
81+
into '../'
82+
}
83+
}
84+
85+
//File appJar = new File(project(':app').getBuildDir(), "libs/${project(':app').getName()}.jar")
86+
// from("${project(':app').getBuildDir()}/libs/app.jar")
87+
// into "."
88+
}
89+
90+
tasks.named('testClasses') {
91+
finalizedBy('copyJar')
92+
}
93+
94+
// Add additional files to clean task
95+
tasks.named('clean') {
96+
delete 'src/main/resources'
97+
}
98+
99+
// Create resources before processResources runs
100+
tasks.named('processResources') {
101+
dependsOn ':createClientCache', ':copyMapData', ':buildPatchedClient'
102+
}
103+
104+
// FTBFS: spotlessMisc complains when there is no dependency on copyMapData
105+
tasks.named('spotlessMisc') {
106+
dependsOn ':copyMapData'
107+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)