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
10 changes: 10 additions & 0 deletions .github/scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.cache/
BuildData/
Bukkit/
CraftBukkit/
Spigot/
work/
*.txt
*.jar
apache-maven-3.9.6/

111 changes: 92 additions & 19 deletions .github/scripts/build_remapped_jars.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,30 @@
You'll need these versions to compile the server jars:
# Java 8: 1.9 -> 1.16
# Java 16: 1.17
# Java 17: 1.18+
# Java 17: 1.18 - 1.20.4
# Java 21: 1.20.5 - 1.21.1
==> https://hub.spigotmc.org/versions/1.21.1.json

Java Versions:
public static final JavaVersion JAVA_5 = new JavaVersion( "Java 5", 49 );
public static final JavaVersion JAVA_6 = new JavaVersion( "Java 6", 50 );
public static final JavaVersion JAVA_7 = new JavaVersion( "Java 7", 51 );
public static final JavaVersion JAVA_8 = new JavaVersion( "Java 8", 52 );
public static final JavaVersion JAVA_9 = new JavaVersion( "Java 9", 53 );
public static final JavaVersion JAVA_10 = new JavaVersion( "Java 10", 54 );
public static final JavaVersion JAVA_11 = new JavaVersion( "Java 11", 55 );
public static final JavaVersion JAVA_12 = new JavaVersion( "Java 12", 56 );
public static final JavaVersion JAVA_13 = new JavaVersion( "Java 13", 57 );
public static final JavaVersion JAVA_14 = new JavaVersion( "Java 14", 58 );
public static final JavaVersion JAVA_15 = new JavaVersion( "Java 15", 59 );
public static final JavaVersion JAVA_16 = new JavaVersion( "Java 16", 60 );
public static final JavaVersion JAVA_17 = new JavaVersion( "Java 17", 61 );
public static final JavaVersion JAVA_18 = new JavaVersion( "Java 18", 62 );
public static final JavaVersion JAVA_19 = new JavaVersion( "Java 19", 63 );
public static final JavaVersion JAVA_20 = new JavaVersion( "Java 20", 64 );
public static final JavaVersion JAVA_21 = new JavaVersion( "Java 21", 65 );
public static final JavaVersion JAVA_22 = new JavaVersion( "Java 22", 66 );

"""
import logging
import os
Expand All @@ -18,18 +41,55 @@
logger = logging.getLogger(__name__)

java_versions_needed = {
'9': 8,
'10': 8,
'11': 8,
'12': 8,
'13': 8,
'14': 8,
'15': 8,
'16': 8,
'17': 16,
'18': 17,
'19': 17,
'20': 17,
"1.8": (7, 8),
"1.8.3": (7, 8),
"1.8.4": (7, 8),
"1.8.5": (7, 8),
"1.8.6": (7, 8),
"1.8.7": (7, 8),
"1.8.8": (7, 8),
"1.9": (7, 8),
"1.9.2": (7, 8),
"1.9.4": (7, 8),
"1.10": (7, 8),
"1.10.2": (7, 8),
"1.11": (7, 8),
"1.11.1": (7, 8),
"1.11.2": (7, 8),
"1.12": (8, 8),
"1.12.1": (8, 9),
"1.12.2": (8, 10),
"1.13": (8, 11),
"1.13.1": (8, 11),
"1.13.2": (8, 12),
"1.14": (8, 12),
"1.14.1": (8, 12),
"1.14.2": (8, 12),
"1.14.3": (8, 12),
"1.14.4": (8, 13),
"1.15": (8, 13),
"1.15.1": (8, 13),
"1.15.2": (8, 14),
"1.16.1": (8, 14),
"1.16.2": (8, 14),
"1.16.3": (8, 15),
"1.16.4": (8, 15),
"1.16.5": (8, 16),
"1.17": (16, 16),
"1.17.1": (16, 17),
"1.18": (17, 17),
"1.18.1": (17, 17),
"1.18.2": (17, 18),
"1.19": (17, 18),
"1.19.1": (17, 18),
"1.19.2": (17, 19),
"1.19.3": (17, 20),
"1.19.4": (17, 20),
"1.20": (17, 21),
"1.20.1": (17, 21),
"1.20.2": (17, 21),
"1.20.4": (17, 22),
"1.20.6": (21, 22),
}
__dir__ = Path(__file__).parent.resolve().absolute()
__root__ = __dir__.parent.parent
Expand All @@ -42,14 +102,27 @@ def find_version_to_build(directory: Path) -> tuple[str, str]:


def get_java_path(version: str) -> str:
minor = version.split('.')[1]
java_version = java_versions_needed[minor]
versions = version.split('.')
min_java, max_java = -1, -1

for version_needed in [version, ".".join(versions[:3]), ".".join(versions[:2]), versions[1]]:
if version_needed not in java_versions_needed:
continue

min_java, max_java = java_versions_needed[version_needed]

for java_version in range(min_java, max_java + 1):
java_path = os.getenv(f'JAVA_HOME_{java_version}_X64')
if java_path:
return java_path + '/bin/java'

alternative = Path(f"/usr/lib/jvm/java-{java_version}-openjdk-amd64/bin/java")
if alternative.exists():
return str(alternative)

java_path = os.getenv(f'JAVA_HOME_{java_version}_X64')
if not java_path:
raise Exception(f"No JAVA_HOME found for version {version}")
break # First one should stop the loop for searching!

return java_path + '/bin/java'
raise Exception(f"No JAVA_HOME found for version {version}, I need something between '{min_java}' and '{max_java}'")


def run_build_tools(version: str, spigot_needed: str) -> None:
Expand Down
138 changes: 138 additions & 0 deletions .github/scripts/fetch_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
"""
Steps:
- goto: https://hub.spigotmc.org/versions/
- copy/paste the list in the "txt" variable underneath.
- run the script
- copy/paste the output in the "build_remapped_jars.py" script
"""
import json
import re
from pathlib import Path
from pprint import pprint

import requests

version_url = "https://hub.spigotmc.org/versions/"

txt = """
1.10.2.json 10-Dec-2021 01:54 325
1.10.json 10-Dec-2021 01:54 325
1.11.1.json 10-Dec-2021 02:02 327
1.11.2.json 10-Dec-2021 02:02 327
1.11.json 19-Dec-2016 12:14 325
1.12.1.json 29-Aug-2018 23:54 352
1.12.2.json 10-Dec-2021 01:31 354
1.12.json 29-Aug-2018 23:56 352
1.13-pre7.json 21-Jul-2018 04:58 325
1.13.1.json 22-Oct-2018 19:00 352
1.13.2.json 10-Dec-2021 01:31 354
1.13.json 29-Aug-2018 23:54 352
1.14-pre5.json 25-Apr-2019 00:20 352
1.14.1.json 27-May-2019 02:27 353
1.14.2.json 21-Jun-2019 09:57 353
1.14.3-pre4.json 23-Jun-2019 01:05 353
1.14.3.json 19-Jul-2019 23:04 353
1.14.4.json 10-Dec-2021 01:31 355
1.14.json 13-May-2019 22:53 353
1.15.1.json 21-Jan-2020 03:40 353
1.15.2.json 10-Dec-2021 01:31 355
1.15.json 17-Dec-2019 21:19 353
1.16.1.json 11-Aug-2020 07:40 353
1.16.2.json 10-Sep-2020 20:55 353
1.16.3.json 25-Oct-2020 07:17 353
1.16.4.json 14-Jan-2021 22:05 353
1.16.5.json 10-Dec-2021 01:31 355
1.17.1.json 10-Dec-2021 01:32 355
1.17.json 06-Jul-2021 12:21 353
1.18-pre5.json 23-Nov-2021 22:37 353
1.18-pre8.json 25-Nov-2021 23:20 353
1.18-rc3.json 29-Nov-2021 05:03 353
1.18.1.json 28-Feb-2022 15:04 353
1.18.2.json 07-Jun-2022 16:08 353
1.18.json 10-Dec-2021 13:16 353
1.19.1.json 04-Aug-2022 10:41 353
1.19.2.json 07-Dec-2022 16:12 353
1.19.3.json 14-Mar-2023 16:36 353
1.19.4.json 07-Jun-2023 15:58 353
1.19.json 25-Jul-2022 09:01 353
1.20.1.json 21-Sep-2023 16:40 353
1.20.2.json 05-Dec-2023 16:43 353
1.20.3.json 23-Apr-2024 15:25 353
1.20.4.json 23-Apr-2024 15:25 353
1.20.5.json 28-May-2024 21:03 353
1.20.6.json 28-May-2024 21:03 353
1.20.json 21-Sep-2023 16:40 353
1.8.3.json 17-May-2015 09:44 302
1.8.4.json 10-Dec-2021 01:54 315
1.8.5.json 10-Dec-2021 01:54 315
1.8.6.json 10-Dec-2021 01:54 315
1.8.7.json 10-Dec-2021 01:54 315
1.8.8.json 10-Dec-2021 01:54 315
1.8.json 16-Apr-2015 22:00 479
1.9.2.json 07-May-2016 06:41 323
1.9.4.json 10-Dec-2021 01:54 336
1.9.json 30-Mar-2016 16:03 323
"""


def natural_sort_key(s):
return [int(text) if text.isdigit() else text.lower() for text in re.split('([0-9]+)', s)]


def _retrieve_versions() -> dict:
versions = {}

for line in txt.strip().splitlines():
fields = line.split()
json_file = fields[0]
size = int(fields[-1])

if '-' in json_file: # -pre, -rc, ... -> Not interested!
continue

target = Path(__file__).parent / '.cache' / json_file
if not target.exists() or target.stat().st_size != size:
print(" > Working on:", json_file)
target.parent.mkdir(exist_ok=True, parents=True)
response = requests.get(version_url + json_file)
target.write_bytes(response.content)
data = response.json()
else:
data = json.loads(target.read_bytes())

versions[target.stem] = data

return versions


def _convert_java_class_version_to_java_version(nr1, nr2) -> tuple[int, int]:
version_table = {
49: 5,
50: 6,
51: 7,
52: 8,
53: 9,
54: 10,
55: 11,
56: 12,
57: 13,
58: 14,
59: 15,
60: 16,
61: 17,
62: 18,
63: 19,
64: 20,
65: 21,
66: 22,
}

return version_table[nr1], version_table[nr2]


if __name__ == '__main__':
versions = _retrieve_versions()
for version in sorted(versions, key=natural_sort_key):
data = versions[version]
min_max = data.get('javaVersions', [51, 52])
print(f'"{version}": {_convert_java_class_version_to_java_version(*min_max)},')
5 changes: 5 additions & 0 deletions .github/workflows/build_cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ jobs:
build:
runs-on: ubuntu-latest

permissions:
contents: write
packages: write

steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -46,6 +50,7 @@ jobs:
8
16
17
21

- name: Set up Python
uses: actions/setup-python@v5
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
8
16
17
21

- name: Set up Python
uses: actions/setup-python@v5
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/maven-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
8
16
17
21

- name: Set up Python
uses: actions/setup-python@v5
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@ tmp/
*.iws
log*.txt
*.log

# Buildtools related stuff
BuildTools.log.txt
.cache/
apache-maven-*/
BuildData/
CraftBukkit/
Spigot/
spigot-*.jar
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
<modules>
<module>core</module>
<module>dist</module>
<module>v1_21</module>
<module>v1_20_R6</module>
<module>v1_20_R4</module>
<module>v1_20_R2</module>
<module>v1_20_R1</module>
Expand Down
Loading
Loading