Info for Mafia Update

Ethelred

Member
I still need to update my Mafia build system, but am not sure of what exactly I need to do. My current system is Java version 8, ant version 1.10.8, and svn version 1.10, and Mac OS X Mojave version 10.14. Apparently I need to upgrade Java to version 17 (?) and replace svn by git and ant by gradle. Can anyone advise me on which versions of those I should aim for? I've never used either of them and don't really know anything about them. It's been some weeks since I've been able to build a new version, still stuck on KoLmafia-20947M.jar and I'd like to start trying to build systems again. Thanks for any help or info you can offer.
 

MCroft

Developer
Staff member
So, if you want to use a recent version while getting your build system together, go to Latest, download the .dmg, install the app from there (which has a bundled JRE) and you're set.

To update your build system, the first thing you need to do is decide if you're going to use an IDE or the command line tools.

I use IntelliJ. Some people use VSCode. Others like Eclipse. You can use BBEdit if you want to.

If you need to update Java (and you probably do), There's a link at the top of this page to the "Recommended Java: V17". Click that, get the Mac/Intel build from Adoptium.

In IntelliJ, you can download the source directly from GitHub. Choose File>New Project From Source Control>GitHub and type in kolmafia/kolmafia., then clone. You'll specify a new directory and you're good. It should set up a gradle build file and you can choose Tasks>application>runShadow and you'll compile and execute from source.

The gradle file eliminates a lot of the setup generally required for SVN/ANT projects like KoLmafia.

If you want to use command line tools, it's like what I just said, but with command line tools.
 
Last edited:

fronobulax

Developer
Staff member
Specifically you do not have to install any version of Gradle. At some point in the build process once Java is there Gradle will bootstrap itself. And you can delete ant.

It is not clear to me how you would merge your local changes with the new code base. The formatting changes alone are going to create a lot of diffs and clutter.
 

heeheehee

Developer
Staff member
You have a few options. In general, I recommend first exporting your diffs manually to a patch file (e.g. `svn diff > custom-changes.patch).

You could manually apply those changes afterwards to the latest commit.

Or, for a more involved, but potentially less manual effort:

Apply your changes right before we reformatted the codebase, format the codebase + commit, merge with the following commit (using your changes wherever there's a conflict), and then try to merge with the latest commit. Something like...
Bash:
git switch -c custom-changes 9ad396391a
patch -p0 < custom-changes.patch
./gradlew spotlessApply
for i in {1..10}; do sed -i -e 's/  \t/    /g' src/**/*.java test/**/*.java; done
git add src/ test/
git commit -m "Import custom changes from SVN repo"
git merge -s ours fbfd2252d0 --no-edit

git branch -u origin/main
git pull --no-edit
 

Ethelred

Member
I took the first step and downloaded Java 17 from Adoptium and a recent .jar file - KoLmafia-25807.jar. And that's about as far as I got. Neither double clicking the .jar file nor trying to execute it from the command line via a "java -jar KoLmafia-25807.jar" from the terminal produced any results. No abort or error messages at all, as far as I could find. Anybody have any suggestions? Thanks again for the ongoing help.
 

MCroft

Developer
Staff member
from my terminal ...

This will dump a lot of output. It will either be obvious what is failing or you can post it here.


Bash:
Michaels-MBP:dist mcroft$ ls
KoLmafia-25807-M.jar
Michaels-MBP:dist mcroft$ java -version
openjdk version "16.0.1" 2021-04-20
OpenJDK Runtime Environment Zulu16.30+15-CA (build 16.0.1+9)
OpenJDK 64-Bit Server VM Zulu16.30+15-CA (build 16.0.1+9, mixed mode, sharing)
Michaels-MBP:dist mcroft$ java -verbose -jar KoLmafia-25807-M.jar | tee KM-loadoutput.txt
 

MCroft

Developer
Staff member
also, the jar is from "an unidentified developer" (That's us!), so you might have to right-click and open it, if you're using the GUI.
 
Top