Skip to content

Commit 0eb0ee9

Browse files
authored
Initial commit
0 parents  commit 0eb0ee9

File tree

13 files changed

+672
-0
lines changed

13 files changed

+672
-0
lines changed

.github/workflows/commitTest.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Commit Testing
2+
3+
on: [push]
4+
5+
jobs:
6+
buildJar:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Set up PATH
12+
run: |
13+
echo "${ANDROID_HOME}/build-tools/30.0.1" >> $GITHUB_PATH
14+
- name: Set up JDK 17
15+
uses: actions/setup-java@v1
16+
with:
17+
java-version: 17
18+
- name: Build mod jar
19+
run: ./gradlew deploy
20+
- name: Upload built jar file
21+
uses: actions/upload-artifact@v2
22+
with:
23+
name: ${{ github.event.repository.name }}
24+
path: build/libs/${{ github.event.repository.name }}.jar

.github/workflows/prTest.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Pull Request Testing
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
buildJar:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Set up PATH
12+
run: |
13+
echo "${ANDROID_HOME}/build-tools/30.0.1" >> $GITHUB_PATH
14+
- name: Set up JDK 17
15+
uses: actions/setup-java@v1
16+
with:
17+
java-version: 17
18+
- name: Build mod jar
19+
run: ./gradlew deploy
20+
- name: Upload built jar file
21+
uses: actions/upload-artifact@v2
22+
with:
23+
name: ${{ github.event.repository.name }} Pull Request
24+
path: build/libs/${{ github.event.repository.name }}.jar

.gitignore

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
logs/
2+
/core/assets/mindustry-saves/
3+
/core/assets/mindustry-maps/
4+
/core/assets/bundles/output/
5+
/core/assets/.gifimages/
6+
/deploy/
7+
/desktop/packr-out/
8+
/desktop/packr-export/
9+
/desktop/mindustry-saves/
10+
/desktop/mindustry-maps/
11+
/desktop/gifexport/
12+
/core/lib/
13+
/ios/assets/
14+
/core/assets-raw/sprites/generated/
15+
/core/assets-raw/sprites_out/
16+
/annotations/build/
17+
/annotations/out/
18+
/net/build/
19+
/tools/build/
20+
/tests/build/
21+
/server/build/
22+
/test_files/
23+
/annotations/build/
24+
/desktop-sdl/build/
25+
desktop-sdl/build/
26+
/android/assets/mindustry-maps/
27+
/android/assets/mindustry-saves/
28+
/core/assets/gifexport/
29+
/core/assets/version.properties
30+
/core/assets/locales
31+
/ios/src/io/anuke/mindustry/gen/
32+
/core/src/io/anuke/mindustry/gen/
33+
ios/robovm.properties
34+
packr-out/
35+
config/
36+
*.gif
37+
38+
version.properties
39+
40+
.attach_*
41+
## Java
42+
43+
*.class
44+
*.war
45+
*.ear
46+
hs_err_pid*
47+
crash-report-*
48+
49+
## Robovm
50+
/ios/robovm-build/
51+
52+
## GWT
53+
/html/war/
54+
/html/gwt-unitCache/
55+
.apt_generated/
56+
.gwt/
57+
gwt-unitCache/
58+
www-test/
59+
.gwt-tmp/
60+
61+
## Android Studio and Intellij and Android in general
62+
/android/libs/armeabi/
63+
/android/libs/armeabi-v7a/
64+
/android/libs/arm64-v8a/
65+
/android/libs/x86/
66+
/android/libs/x86_64/
67+
/android/gen/
68+
.idea/
69+
*.ipr
70+
*.iws
71+
*.iml
72+
/android/out/
73+
com_crashlytics_export_strings.xml
74+
75+
## Eclipse
76+
77+
.classpath
78+
.project
79+
.metadata/
80+
/android/bin/
81+
/core/bin/
82+
/desktop/bin/
83+
/html/bin/
84+
/ios/bin/
85+
/ios-moe/bin/
86+
*.tmp
87+
*.bak
88+
*.swp
89+
*~.nib
90+
.settings/
91+
.loadpath
92+
.externalToolBuilders/
93+
*.launch
94+
95+
## NetBeans
96+
97+
/nbproject/private/
98+
/android/nbproject/private/
99+
/core/nbproject/private/
100+
/desktop/nbproject/private/
101+
/html/nbproject/private/
102+
/ios/nbproject/private/
103+
/ios-moe/nbproject/private/
104+
105+
/build/
106+
/android/build/
107+
/core/build/
108+
/desktop/build/
109+
/html/build/
110+
/ios/build/
111+
/ios-moe/build/
112+
113+
/nbbuild/
114+
/android/nbbuild/
115+
/core/nbbuild/
116+
/desktop/nbbuild/
117+
/html/nbbuild/
118+
/ios/nbbuild/
119+
/ios-moe/nbbuild/
120+
121+
/dist/
122+
/android/dist/
123+
/core/dist/
124+
/desktop/dist/
125+
/html/dist/
126+
/ios/dist/
127+
/ios-moe/dist/
128+
129+
/nbdist/
130+
/android/nbdist/
131+
/core/nbdist/
132+
/desktop/nbdist/
133+
/html/nbdist/
134+
/ios/nbdist/
135+
/ios-moe/nbdist/
136+
137+
nbactions.xml
138+
nb-configuration.xml
139+
140+
## Gradle
141+
142+
/local.properties
143+
.gradle/
144+
gradle-app.setting
145+
/build/
146+
/android/build/
147+
/core/build/
148+
/desktop/build/
149+
/html/build/
150+
/ios/build/
151+
/ios-moe/build/
152+
153+
## OS Specific
154+
.DS_Store
155+
Thumbs.db
156+
android/libs/

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Mindustry Java Mod Template
2+
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).
3+
4+
## Building for Desktop Testing
5+
6+
1. Install JDK **17**.
7+
2. Run `gradlew jar` [1].
8+
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.**
9+
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.
10+
11+
## Building through Github Actions
12+
13+
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.
14+
To get a jar file that works for every platform, do the following:
15+
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.
16+
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.
17+
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.
18+
19+
## Building Locally
20+
21+
Building locally takes more time to set up, but shouldn't be a problem if you've done Android development before.
22+
1. Download the Android SDK, unzip it and set the `ANDROID_HOME` environment variable to its location.
23+
2. Make sure you have API level 30 installed, as well as any recent version of build tools (e.g. 30.0.1)
24+
3. Add a build-tools folder to your PATH. For example, if you have `30.0.1` installed, that would be `$ANDROID_HOME/build-tools/30.0.1`.
25+
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.
26+
27+
## Adding Dependencies
28+
29+
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.
30+
31+
- `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.
32+
- `compileOnly` means that the dependency is only around at compile time, and not included in the jar.
33+
34+
Only use `implementation` if you want to package another Java library *with your mod*, and that library is not present in Mindustry already.
35+
36+
---
37+
38+
*[1]* *On Linux/Mac it's `./gradlew`, but if you're using Linux I assume you know how to run executables properly anyway.*
39+
*[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.*

assets/sprites/frog.png

39.7 KB
Loading

build.gradle

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
apply plugin: "java"
2+
3+
version '1.0'
4+
5+
sourceSets.main.java.srcDirs = ["src"]
6+
7+
repositories{
8+
mavenCentral()
9+
maven{ url "https://raw.githubusercontent.com/Zelaux/MindustryRepo/master/repository" }
10+
maven{ url 'https://www.jitpack.io' }
11+
}
12+
13+
java{
14+
targetCompatibility = 8
15+
sourceCompatibility = JavaVersion.VERSION_17
16+
}
17+
18+
ext{
19+
//the build number that this mod is made for
20+
mindustryVersion = 'v145'
21+
jabelVersion = "93fde537c7"
22+
sdkRoot = System.getenv("ANDROID_HOME") ?: System.getenv("ANDROID_SDK_ROOT")
23+
}
24+
25+
//java 8 backwards compatibility flag
26+
allprojects{
27+
tasks.withType(JavaCompile){
28+
options.compilerArgs.addAll(['--release', '8'])
29+
}
30+
}
31+
32+
dependencies{
33+
compileOnly "com.github.Anuken.Arc:arc-core:$mindustryVersion"
34+
compileOnly "com.github.Anuken.Mindustry:core:$mindustryVersion"
35+
36+
annotationProcessor "com.github.Anuken:jabel:$jabelVersion"
37+
}
38+
39+
//force arc version
40+
configurations.all{
41+
resolutionStrategy.eachDependency { details ->
42+
if(details.requested.group == 'com.github.Anuken.Arc'){
43+
details.useVersion "$mindustryVersion"
44+
}
45+
}
46+
}
47+
48+
task jarAndroid{
49+
dependsOn "jar"
50+
51+
doLast{
52+
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.");
53+
54+
def platformRoot = new File("$sdkRoot/platforms/").listFiles().sort().reverse().find{ f -> new File(f, "android.jar").exists()}
55+
56+
if(!platformRoot) throw new GradleException("No android.jar found. Ensure that you have an Android platform installed.")
57+
58+
//collect dependencies needed for desugaring
59+
def dependencies = (configurations.compileClasspath.asList() + configurations.runtimeClasspath.asList() + [new File(platformRoot, "android.jar")]).collect{ "--classpath $it.path" }.join(" ")
60+
61+
//dex and desugar files - this requires d8 in your PATH
62+
"d8 $dependencies --min-api 14 --output ${project.archivesBaseName}Android.jar ${project.archivesBaseName}Desktop.jar"
63+
.execute(null, new File("$buildDir/libs")).waitForProcessOutput(System.out, System.err)
64+
}
65+
}
66+
67+
jar{
68+
archiveFileName = "${base.archivesBaseName}Desktop.jar"
69+
70+
from{
71+
configurations.runtimeClasspath.collect{ it.isDirectory() ? it : zipTree(it) }
72+
}
73+
74+
from(rootDir){
75+
include "mod.hjson"
76+
}
77+
78+
from("assets/"){
79+
include "**"
80+
}
81+
}
82+
83+
task deploy(type: Jar){
84+
dependsOn jarAndroid
85+
dependsOn jar
86+
archiveFileName = "${base.archivesBaseName}.jar"
87+
88+
from{ [zipTree("$buildDir/libs/${project.archivesBaseName}Desktop.jar"), zipTree("$buildDir/libs/${project.archivesBaseName}Android.jar")] }
89+
90+
doLast{
91+
delete{
92+
delete "$buildDir/libs/${project.archivesBaseName}Desktop.jar"
93+
delete "$buildDir/libs/${project.archivesBaseName}Android.jar"
94+
}
95+
}
96+
}

gradle.properties

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
org.gradle.jvmargs=--illegal-access=permit \
2+
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
3+
--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED \
4+
--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED \
5+
--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED \
6+
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
7+
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \
8+
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
9+
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
10+
--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED \
11+
--add-exports=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED \
12+
--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED \
13+
--add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED

gradle/wrapper/gradle-wrapper.jar

54.9 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)