-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3acc952
Showing
20 changed files
with
673 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Build Mod | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
buildJar: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up PATH | ||
run: | | ||
echo "${ANDROID_HOME}/build-tools/34.0.0" >> $GITHUB_PATH | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 17 | ||
- name: Build mod jar | ||
run: | | ||
chmod +x ./gradlew | ||
./gradlew deploy | ||
- name: Upload built jar file | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ github.event.repository.name }} | ||
path: build/libs/${{ github.event.repository.name }}.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
logs/ | ||
/core/assets/mindustry-saves/ | ||
/core/assets/mindustry-maps/ | ||
/core/assets/bundles/output/ | ||
/core/assets/.gifimages/ | ||
/deploy/ | ||
/desktop/packr-out/ | ||
/desktop/packr-export/ | ||
/desktop/mindustry-saves/ | ||
/desktop/mindustry-maps/ | ||
/desktop/gifexport/ | ||
/core/lib/ | ||
/ios/assets/ | ||
/core/assets-raw/sprites/generated/ | ||
/core/assets-raw/sprites_out/ | ||
/annotations/build/ | ||
/annotations/out/ | ||
/net/build/ | ||
/tools/build/ | ||
/tests/build/ | ||
/server/build/ | ||
/test_files/ | ||
/annotations/build/ | ||
/desktop-sdl/build/ | ||
desktop-sdl/build/ | ||
/android/assets/mindustry-maps/ | ||
/android/assets/mindustry-saves/ | ||
/core/assets/gifexport/ | ||
/core/assets/version.properties | ||
/core/assets/locales | ||
/ios/src/io/anuke/mindustry/gen/ | ||
/core/src/io/anuke/mindustry/gen/ | ||
ios/robovm.properties | ||
packr-out/ | ||
config/ | ||
*.gif | ||
|
||
version.properties | ||
|
||
.attach_* | ||
## Java | ||
|
||
*.class | ||
*.war | ||
*.ear | ||
hs_err_pid* | ||
crash-report-* | ||
replay_pid* | ||
|
||
## Robovm | ||
/ios/robovm-build/ | ||
|
||
## GWT | ||
/html/war/ | ||
/html/gwt-unitCache/ | ||
.apt_generated/ | ||
.gwt/ | ||
gwt-unitCache/ | ||
www-test/ | ||
.gwt-tmp/ | ||
|
||
## Android Studio and Intellij and Android in general | ||
/android/libs/armeabi/ | ||
/android/libs/armeabi-v7a/ | ||
/android/libs/arm64-v8a/ | ||
/android/libs/x86/ | ||
/android/libs/x86_64/ | ||
/android/gen/ | ||
.idea/ | ||
*.ipr | ||
*.iws | ||
*.iml | ||
/android/out/ | ||
com_crashlytics_export_strings.xml | ||
|
||
## Eclipse | ||
|
||
.classpath | ||
.project | ||
.metadata/ | ||
/android/bin/ | ||
/core/bin/ | ||
/desktop/bin/ | ||
/html/bin/ | ||
/ios/bin/ | ||
/ios-moe/bin/ | ||
*.tmp | ||
*.bak | ||
*.swp | ||
*~.nib | ||
.settings/ | ||
.loadpath | ||
.externalToolBuilders/ | ||
*.launch | ||
|
||
## NetBeans | ||
|
||
/nbproject/private/ | ||
/android/nbproject/private/ | ||
/core/nbproject/private/ | ||
/desktop/nbproject/private/ | ||
/html/nbproject/private/ | ||
/ios/nbproject/private/ | ||
/ios-moe/nbproject/private/ | ||
|
||
/build/ | ||
/android/build/ | ||
/core/build/ | ||
/desktop/build/ | ||
/html/build/ | ||
/ios/build/ | ||
/ios-moe/build/ | ||
|
||
/nbbuild/ | ||
/android/nbbuild/ | ||
/core/nbbuild/ | ||
/desktop/nbbuild/ | ||
/html/nbbuild/ | ||
/ios/nbbuild/ | ||
/ios-moe/nbbuild/ | ||
|
||
/dist/ | ||
/android/dist/ | ||
/core/dist/ | ||
/desktop/dist/ | ||
/html/dist/ | ||
/ios/dist/ | ||
/ios-moe/dist/ | ||
|
||
/nbdist/ | ||
/android/nbdist/ | ||
/core/nbdist/ | ||
/desktop/nbdist/ | ||
/html/nbdist/ | ||
/ios/nbdist/ | ||
/ios-moe/nbdist/ | ||
|
||
nbactions.xml | ||
nb-configuration.xml | ||
|
||
## Gradle | ||
|
||
/local.properties | ||
.gradle/ | ||
gradle-app.setting | ||
/build/ | ||
/android/build/ | ||
/core/build/ | ||
/desktop/build/ | ||
/html/build/ | ||
/ios/build/ | ||
/ios-moe/build/ | ||
|
||
## OS Specific | ||
.DS_Store | ||
Thumbs.db | ||
android/libs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Mindustry Java Mod Template | ||
A Java Mindustry mod template that works on Android and PC. The Kotlin version of this mod can be seen [here](https://github.com/Anuken/MindustryKotlinModTemplate). | ||
|
||
## Building for Desktop Testing | ||
|
||
1. Install JDK **17**. | ||
2. Run `gradlew jar` [1]. | ||
3. Your mod jar will be in the `build/libs` directory. **Only use this version for testing on desktop. It will not work with Android.** | ||
To build an Android-compatible version, you need the Android SDK. You can either let Github Actions handle this, or set it up yourself. See steps below. | ||
|
||
## Building through Github Actions | ||
|
||
This repository is set up with Github Actions CI to automatically build the mod for you every commit. This requires a Github repository, for obvious reasons. | ||
To get a jar file that works for every platform, do the following: | ||
1. Make a Github repository with your mod name, and upload the contents of this repo to it. Perform any modifications necessary, then commit and push. | ||
2. Check the "Actions" tab on your repository page. Select the most recent commit in the list. If it completed successfully, there should be a download link under the "Artifacts" section. | ||
3. Click the download link (should be the name of your repo). This will download a **zipped jar** - **not** the jar file itself [2]! Unzip this file and import the jar contained within in Mindustry. This version should work both on Android and Desktop. | ||
|
||
## Building Locally | ||
|
||
Building locally takes more time to set up, but shouldn't be a problem if you've done Android development before. | ||
1. Download the Android SDK, unzip it and set the `ANDROID_HOME` environment variable to its location. | ||
2. Make sure you have API level 30 installed, as well as any recent version of build tools (e.g. 30.0.1) | ||
3. Add a build-tools folder to your PATH. For obv, if you have `30.0.1` installed, that would be `$ANDROID_HOME/build-tools/30.0.1`. | ||
4. Run `gradlew deploy`. If you did everything correctlly, this will create a jar file in the `build/libs` directory that can be run on both Android and desktop. | ||
|
||
## Adding Dependencies | ||
|
||
Please note that all dependencies on Mindustry, Arc or its submodules **must be declared as compileOnly in Gradle**. Never use `implementation` for core Mindustry or Arc dependencies. | ||
|
||
- `implementation` **places the entire dependency in the jar**, which is, in most mod dependencies, very undesirable. You do not want the entirety of the Mindustry API included with your mod. | ||
- `compileOnly` means that the dependency is only around at compile time, and not included in the jar. | ||
|
||
Only use `implementation` if you want to package another Java library *with your mod*, and that library is not present in Mindustry already. | ||
|
||
--- | ||
|
||
*[1]* *On Linux/Mac it's `./gradlew`, but if you're using Linux I assume you know how to run executables properly anyway.* | ||
*[2]: Yes, I know this is stupid. It's a Github UI limitation - while the jar itself is uploaded unzipped, there is currently no way to download it as a single file.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
item.original-beta-version-iron.name=Iron | ||
item.original-beta-version-iron.description=A hard industrial metal. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
item.original-beta-version-iron.name=? | ||
item.original-beta-version-iron.description=?????????? |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
apply plugin: "java" | ||
|
||
version '1.0' | ||
|
||
sourceSets.main.java.srcDirs = ["src"] | ||
|
||
repositories{ | ||
mavenCentral() | ||
maven{ url "https://raw.githubusercontent.com/Zelaux/MindustryRepo/master/repository" } | ||
maven{ url 'https://www.jitpack.io' } | ||
} | ||
|
||
java{ | ||
targetCompatibility = 8 | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
} | ||
|
||
ext{ | ||
//the build number that this mod is made for | ||
mindustryVersion = 'v146' | ||
jabelVersion = "93fde537c7" | ||
//windows sucks | ||
isWindows = System.getProperty("os.name").toLowerCase().contains("windows") | ||
sdkRoot = System.getenv("ANDROID_HOME") ?: System.getenv("ANDROID_SDK_ROOT") | ||
} | ||
|
||
//java 8 backwards compatibility flag | ||
allprojects{ | ||
tasks.withType(JavaCompile){ | ||
options.compilerArgs.addAll(['--release', '8']) | ||
} | ||
} | ||
|
||
dependencies{ | ||
compileOnly "com.github.Anuken.Arc:arc-core:$mindustryVersion" | ||
compileOnly "com.github.Anuken.Mindustry:core:$mindustryVersion" | ||
|
||
annotationProcessor "com.github.Anuken:jabel:$jabelVersion" | ||
} | ||
|
||
//force arc version | ||
configurations.all{ | ||
resolutionStrategy.eachDependency { details -> | ||
if(details.requested.group == 'com.github.Anuken.Arc'){ | ||
details.useVersion "$mindustryVersion" | ||
} | ||
} | ||
} | ||
|
||
task jarAndroid{ | ||
dependsOn "jar" | ||
|
||
doLast{ | ||
if(!sdkRoot || !new File(sdkRoot).exists()) throw new GradleException("No valid Android SDK found. Ensure that ANDROID_HOME is set to your Android SDK directory."); | ||
|
||
def platformRoot = new File("$sdkRoot/platforms/").listFiles().sort().reverse().find{ f -> new File(f, "android.jar").exists()} | ||
|
||
if(!platformRoot) throw new GradleException("No android.jar found. Ensure that you have an Android platform installed.") | ||
|
||
//collect dependencies needed for desugaring | ||
def dependencies = (configurations.compileClasspath.asList() + configurations.runtimeClasspath.asList() + [new File(platformRoot, "android.jar")]).collect{ "--classpath $it.path" }.join(" ") | ||
|
||
def d8 = isWindows ? "d8.bat" : "d8" | ||
|
||
//dex and desugar files - this requires d8 in your PATH | ||
"$d8 $dependencies --min-api 14 --output ${project.archivesBaseName}Android.jar ${project.archivesBaseName}Desktop.jar" | ||
.execute(null, new File("$buildDir/libs")).waitForProcessOutput(System.out, System.err) | ||
} | ||
} | ||
|
||
jar{ | ||
archiveFileName = "${base.archivesBaseName}Desktop.jar" | ||
|
||
from{ | ||
configurations.runtimeClasspath.collect{ it.isDirectory() ? it : zipTree(it) } | ||
} | ||
|
||
from(rootDir){ | ||
include "mod.hjson" | ||
} | ||
|
||
from("assets/"){ | ||
include "**" | ||
} | ||
} | ||
|
||
task deploy(type: Jar){ | ||
dependsOn jarAndroid | ||
dependsOn jar | ||
archiveFileName = "${base.archivesBaseName}.jar" | ||
|
||
from{ [zipTree("$buildDir/libs/${project.archivesBaseName}Desktop.jar"), zipTree("$buildDir/libs/${project.archivesBaseName}Android.jar")] } | ||
|
||
doLast{ | ||
delete{ | ||
delete "$buildDir/libs/${project.archivesBaseName}Desktop.jar" | ||
delete "$buildDir/libs/${project.archivesBaseName}Android.jar" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
org.gradle.jvmargs=--illegal-access=permit \ | ||
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \ | ||
--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED \ | ||
--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED \ | ||
--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED \ | ||
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \ | ||
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \ | ||
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \ | ||
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \ | ||
--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED \ | ||
--add-exports=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED \ | ||
--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED \ | ||
--add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.