Skip to content

Conversation

@eigenraven
Copy link
Member

@eigenraven eigenraven commented Jan 7, 2023

I think this is advanced enough to push for wider testing (but not merging yet!). The update to this buildscript version is more complex than usual, because:

  • Gradle version needs to be updated to 7.6
  • settings.gradle must be updated due to updated spotless configs (the old ones tried to reformat minecraft sources)
  • There is a chance some of the addon.gradle/dependencies.gradle scripts won't work anymore and need patching. I have added backwards compatibility for most of the constructs I could find, printing deprecation warnings as appropriate

What RFG brings compared to FG:

  • Better maintainability, it's been written from grounds up against the modern gradle apis, while reusing the pure java->java and similar transforms from FG for maximum compatibility by default
  • Support for running gradle with a newer jvm, while the code gets compiled to target version 8 via the toolchains feature
  • Optional Jabel to support syntax of Java 17 targetting Java 8 bytecode
  • Updates LWJGL to 2.9.4 from 2.9.1 in the dev environment to fix some bugs
  • Adds runObfClient/runObfServer tasks to generate a launcher-like environment which runs obfuscated minecraft forge.
  • Optional generic injection, turning most of the visible raw types like List, Map in the decompiled code into nice List<ItemStack>, Map<String, String>. It's off by default for old code because it can cause compilation errors until code is updated.
  • Redone tag replacement. Replacement is supported for backwards compatibility, now done via a javac plugin to avoid 2 annoying bugs of FG: the old way didn't work in some IntelliJ configurations, leading to GRADLETOKEN_VERSION being visible or crashes; and the old method copied all sources to a separate directory which made following compiler errors annoying as they led you to the wrong copy of the file. A new method is also provided that generates a brand new class instead of modifying existing ones, it's less hacky and what most other Java projects do.
  • I understand RFG source code and can maintain it, better than trying to patch fixes into the ancient FG codebase

Update script (bash, linux, might work on macos) - to run, put it into the examplemod repo root and run it as examplemod/update.sh which-mod-to-update/:

#!/bin/bash

set -eou pipefail

SRC_FOLDER=$(readlink -f ${BASH_SOURCE%/*})
SRC_FOLDER=$(cd "${SRC_FOLDER}" && pwd -P)
TARGET_FOLDER=$(cd "$1" && pwd -P)

echo "Source at ${SRC_FOLDER}"
echo "Target at ${TARGET_FOLDER}"

if [[ "${SRC_FOLDER}" == "${TARGET_FOLDER}" ]]; then
  echo "Src=Target"
  exit 1
fi

if [[ ! -f "${TARGET_FOLDER}"/gradlew ]]; then
  echo "Target at ${TARGET_FOLDER} is not a gradle project"
  exit 1
fi

if [[ ! -f "${TARGET_FOLDER}"/gradlew ]]; then
  echo "Target at ${TARGET_FOLDER} is not a gradle project"
  exit 1
fi

if ! grep -Eq "GTNewHorizons/ExampleMod1.7.10/(main|master)/build.gradle" "${TARGET_FOLDER}"/build.gradle; then
  echo "Target is not using the ExampleMod buildscript"
  exit 1
fi

if grep -Fq "com.gtnewhorizons.retrofuturagradle" "${TARGET_FOLDER}"/build.gradle; then
  echo "Target is already using the RFG buildscript"
  exit 0 # No-op
fi

cd "${TARGET_FOLDER}/"
git checkout master
git pull
git reset --hard
git clean -f

cp -av "${SRC_FOLDER}/gradle" "${SRC_FOLDER}/gradlew" "${SRC_FOLDER}/gradlew.bat" "${SRC_FOLDER}/build.gradle" "${TARGET_FOLDER}/"
cp -av "${SRC_FOLDER}/settings.gradle.example" "${TARGET_FOLDER}/settings.gradle"
cp -av "${SRC_FOLDER}/.gitattributes" "${TARGET_FOLDER}/.gitattributes"
git add --chmod=+x ./gradlew
git commit -am "[ci skip] Update buildscript to RetroFuturaGradle"

find src -type f -name '*.java' -exec sed -i '/_OBFID/d' {} \;
sed -i 's/runtime(/runtimeOnly(/g' dependencies.gradle
bash gradlew spotlessApply build
git commit -am "[ci skip] spotlessApply with the new settings"

echo "# See https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view" > ".git-blame-ignore-revs"
echo "# Ignore spotlessApply reformat" > ".git-blame-ignore-revs"
git rev-parse HEAD >> ".git-blame-ignore-revs"
git add ".git-blame-ignore-revs"
git commit -am "[ci skip] Add git-blame-ignore-revs for spotlessApply"

git push origin master

Closes #64
Closes #88

@ah-OOG-ah
Copy link
Member

ah-OOG-ah commented Jan 10, 2023

What is this? I'm getting it when I run runClient, and probably a few other times too.
image

@mitchej123
Copy link

mitchej123 commented Jan 10, 2023

What is this? I'm getting it when I run runClient, and probably a few other times too.

This is from CCC or CCL, and it's looking for the mappings directory so it can do some magic in dev

@eigenraven eigenraven requested review from a team January 28, 2023 20:42
@eigenraven eigenraven marked this pull request as ready for review January 28, 2023 21:11
@eigenraven eigenraven requested a review from a team as a code owner January 28, 2023 21:11
jobs:
build-and-test:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@rfg
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actions changes are temporary until we move mods over to the new buildscript, they're only needed for Jabel which is opt-in (just on by default for new projects including this template)

@eigenraven eigenraven changed the title RetroFuturaGradle port - ready for wider testing (do not merge) RetroFuturaGradle port Jan 28, 2023
Copy link

@mitchej123 mitchej123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit: and see what happens

@eigenraven eigenraven merged commit 1d5c51c into master Jan 28, 2023
@eigenraven eigenraven deleted the wip-rfg-tests branch January 28, 2023 21:58
@mitchej123
Copy link

mitchej123 commented Jan 29, 2023

Note: needed to update the ExampleMod buildscript identification in order to deal with older versions floating around in the repositories

if ! grep -Eq "GTNewHorizons/ExampleMod1.7.10/(main|master)/build.gradle" ./build.gradle; then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

genIntellijRuns problems and a hacky fix

4 participants