docs/Developers/Building-Locally.md
By the end of this guide, you will have Unciv running locally from code, so you can make changes and test them locally.
https://github.com/<YourUsername>/UncivUnable to find method ''void org.apache.commons.compress.archivers.zip.ZipFile.<init>(java.nio.channels.SeekableByteChannel)'' errors when you try to sync. If you have this problem go into File > Settings > Languages & Frameworks > Android SDK
Unciv.desktop.main (Unciv.desktop for Bumblebee or below), main class to com.unciv.app.desktop.DesktopLauncher and $ProjectFileDir$/android/assets as the Working directory, OK to close the window
-Xmx4096m -Xms256m -XX:MaxMetaspaceSize=256m to allow a debugged game a little more memory. Or, use the -DnoLog= or -DonlyLog= options to control console logging. See the Log.kt comments for details.../../docs/uniques.md (No such file or directory) error that means you forgot to set the working directory!
Important: Unchecking this creates annoying merge conflicts. Before commits (non-translation) remove those trailing space. For more info check Coding Standard.
android/assets/SaveFiles folder once you have one, "Mark directory as" > Excluded
android/assets/mods folder and any other files you may create while testing that do not belong in the public project.Unciv uses Gradle to specify dependencies and how to run. In the background, the Gradle gnomes will be off fetching the packages (a one-time effort) and, once that's done, will build the project!
Unciv uses Gradle 8.11.1 and the Android Gradle Plugin 8.9.1. Can check in File > Project Structure > Project
Note: advanced build commands (as described in the next paragraph), specifically
gradlew desktop:distto build a jar, run just fine in Android Studio's terminal (Alt+F12), with most dependencies already taken care of.
gradlew desktop:rungradlew desktop:dist./gradlew desktop:run./gradlew desktop:distIf the terminal returns Permission denied or Command not found on Mac/Linux, run chmod +x ./gradlew first. This is a one-time procedure.
If you get an error that Android SDK folder wasn't found, install it by running:
sudo apt update && sudo apt install android-sdk (Debian, Ubuntu, Mint etc.)
Then, set the SDK location in the local.properties file by adding:
sdk.dir = /path/to/android/sdk - for example, /usr/lib/android-sdk
If during initial launch you get an error that the JDK version is wrong, install the JDK from here.
Note: Gradle may take up to several minutes to download files After building, the output .JAR file should be in
/desktop/build/libs/Unciv.jar
For actual development, you'll probably need to download Android Studio and build it yourself - see above :)
Sometimes, checking things out on the desktop version is not enough and you need to debug Unciv running on an Android device. For an introduction, see Testing android builds.
Congratulations! Unciv should now be running on your computer! Now we can start changing some code, and later we'll see how your changes make it into the main repository!
Now would be a good time to get to know the project in general at the Project Structure overview!
You can (and in some cases should) run and even debug the unit tests locally.
:tests:test and "Arguments" to --tests "com.unciv.*", OK to close the window.Detekt checks for code smells and other linting issues. To generate Detekt reports:
detekt-cli with detekt-cli.bat.
PATH/TO/DETEKT/detekt-cli --parallel --report html:detekt/reports.html --config .github/workflows/detekt_config/detekt-warnings.ymlPATH/TO/DETEKT/detekt-cli --parallel --report html:detekt/reports.html --config .github/workflows/detekt_config/detekt-errors.ymldetekt/reports.htmlFrom time to time, Unciv bumps the versions of major tools - mainly Gradle, the Android SDK Platform, and the Android SDK Build-Tools. The new versions and support files are automatically downloaded for you, but old versions are not cleaned up automatically, nor are intermediate build files specific to Gradle versions. This may leave a few gigabytes of dead files on your system. If these bother you, you can clean up as follows:
Additionally, git prioritizes safety of your changes over efficiency to the extreme, leading to some bloat.
git gc is automatically done for you, but sparingly, and running it manually won't hurt.
For a more thorough cleanup, run git gc --prune=now --aggressive sporadically from Studio's terminal (or any shell within Unicv's project folder),
making sure to clean up all your obsolete branches first, and that all remaining branches are in sync with the online branches they're backing
or based on master if they're local only.
The simple multiplayer host included in the sources can be set up to debug or run analogously to the main game:
Unciv.server.main (Unciv.server for Studio versions Bumblebee or below), main class to com.unciv.app.server.UncivServer and <repo_folder>/android/assets/ as the Working directory, OK to close the window.To build a jar file, refer to Without Android Studio and replace 'desktop' with 'server'. That is, run ./gradlew server:dist and when it's done look for /server/build/libs/UncivServer.jar