Compiling from Source

From Kolmafia
Jump to navigation Jump to search

News

Once great and big, now secondhand news...

KoLmafia has migrated to the GitHub, GIT and gradle.

The Windows, Linux and macOS instructions have been updated, and might have been lightly tested

The good news is that the IDE setup is a lot easier. The bad news is you'll need to take some steps to build anything.

To contribute to the Mafia project, you'll need to be able to install the Java Development Kit, connect to the git repository, and be comfortable writing Java Code. Instructions for the first two are included below:

Windows

  1. Download Tools
    1. Download and install Java Development Kit 17 or newer, available from Adoptium. The minimum recommended version is Java 17, but check the *Recommended Java* version on the KoLmafia Forums to be up to date].
    2. Download and install GIT following the instructions from Atlassian's GIT install page.
    3. Download and install Tortoise GIT (if needed) from https://tortoisegit.org
  2. Configure Windows Environment Variables
    Win 10 Environment Variable Editor
    1. Windows 10
      1. Go to settings
      2. type 'enviro' in the search
      3. click on the 'edit environment variables' suggestion
      4. add or edit JAVA_HOME, and PATH variables
        PATH should include JAVA_HOME
        If the JAVA installer has already set these variables, they can be updated or left alone.
  3. Open a new Command Prompt (or Powershell) window and navigate to the directory to which you wish to create kolmafia (e.g. cd %USERPROFILE%\projects, or some similar directory)
  4. Clone the source code for the KoLmafia Project.
    1. If you have a github account:
      git clone git@github.com:kolmafia/kolmafia.git
      
    2. If not:
      git clone https://github.com/kolmafia/kolmafia.git
      
  5. Compile KoLmafia with the Gradle wrapper
    cd kolmafia && gradlew.bat runShadow
    
Optional

If you intend to commit code to GitHub, you will need to follow GitHub's instructions for adding a Personal Access Token (PAT)

Linux

Do once:

  1. Install git - you probably already have this. If not, follow this guide.
  2. Get an appropriate JDK. If your package manager does not contain a sufficiently up-to-date version of Java, the safest and easiest way to do this is with Adoptium.
  3. Clone the repo:
    1. If you have a github account:
      git clone git@github.com:kolmafia/kolmafia.git
      
      If not:
      git clone https://github.com/kolmafia/kolmafia.git

Do every session:

  1. Set up your environment to use that JDK you just downloaded
     export PATH="/where/you/put/that/jdk/bin:${PATH}"
    (Optionally, put this in your .profile or .bashrc if you want to set and forget.)
  2. Navigate to your cloned repository:
    cd /where/you/cloned/kolmafia
  3. Get new updates with
    git pull
    If you have local uncommitted changes, you may want to instead use git stash && git pull && git stash pop.
  4. Build the new jar:
    ./gradlew clean shadowJar

You have a KoLmafia jar file that can be invoked with

java -jar dist/KoLmafia-*.jar

Do other installation steps as you wish.

macOS

  1. Verify required packages
    1. java --version
      • if not found or less than Java 17... Install Java Development Kit version 17 from Adoptium Temurin
    2. git --version
  2. Configure development environment
    Most of these steps can be included in .profile or the equivalent for your shell of choice.
    1. In the terminal set JAVA_HOME to the java home directory.
      /usr/libexec/java_home -V will list all known values for java_home.
      If you have multiple copies of java, choose the version you want to use. export JAVA_HOME=`/usr/libexec/java_home -v17
  3. Open a new terminal window and navigate to the directory to which you wish to create kolmafia (e.g. cd ~/projects, or some similar directory)
  4. Clone the source code for the KoLmafia Project.
    1. If you have a github account:
      git clone git@github.com:kolmafia/kolmafia.git
      
    2. If not:
      git clone https://github.com/kolmafia/kolmafia.git
      

Do every session:

  1. Navigate to your cloned repository:
    cd ~/projects/kolmafia
  2. Get new updates with
    git pull
    If you have local uncommitted changes, you may want to instead use git stash && git pull && git stash pop.
  3. Compile KoLmafia with the Gradle wrapper:
    ./gradlew runShadow
    

Optional

If you intend to commit code to GitHub, you will need to follow GitHub's instructions for adding a Personal Access Token (PAT) '