1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-09-11 08:15:35 +03:00
Mindustry/build.gradle

360 lines
12 KiB
Groovy
Raw Normal View History

buildscript{
2020-01-23 03:16:56 +03:00
ext{
getArcHash = {
return new Properties().with{ p -> p.load(file('gradle.properties').newReader()); return p }["archash"]
}
arcHash = getArcHash()
2020-01-23 03:16:56 +03:00
}
repositories{
2017-04-30 04:25:59 +03:00
mavenLocal()
mavenCentral()
2017-12-20 04:51:46 +03:00
google()
maven{ url "https://oss.sonatype.org/content/repositories/snapshots/" }
2017-04-30 04:25:59 +03:00
jcenter()
2019-10-23 01:45:05 +03:00
maven{ url 'https://jitpack.io' }
2017-04-30 04:25:59 +03:00
}
2018-12-29 23:58:11 +03:00
dependencies{
2019-11-20 03:08:41 +03:00
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.8'
2019-10-23 01:45:05 +03:00
classpath "com.github.anuken:packr:-SNAPSHOT"
classpath "com.github.Anuken.Arc:packer:$arcHash"
classpath "com.github.Anuken.Arc:arc-core:$arcHash"
2017-04-30 04:25:59 +03:00
}
}
allprojects{
2019-11-20 06:32:59 +03:00
apply plugin: 'maven'
2020-04-30 02:54:20 +03:00
version = 'release'
2019-08-29 05:07:08 +03:00
group = 'com.github.Anuken'
2018-02-22 03:50:27 +03:00
ext{
2020-05-08 04:46:26 +03:00
versionNumber = '6'
if(!project.hasProperty("versionModifier")) versionModifier = 'pre-alpha'
if(!project.hasProperty("versionType")) versionType = 'official'
appName = 'Mindustry'
2019-11-06 21:59:35 +03:00
steamworksVersion = '891ed912791e01fe9ee6237a6497e5212b85c256'
2020-06-17 21:35:47 +03:00
rhinoVersion = 'eeb327d141146663ff3924bd20d2a5da8a6439cc'
2019-04-08 16:03:18 +03:00
2019-11-20 03:08:41 +03:00
loadVersionProps = {
return new Properties().with{p -> p.load(file('../core/assets/version.properties').newReader()); return p }
}
debugged = {
2019-09-21 23:44:47 +03:00
return new File(projectDir.parent, '../Mindustry-Debug').exists() && !project.hasProperty("release") && project.hasProperty("args")
}
2018-12-29 20:22:41 +03:00
localArc = {
2019-09-13 20:05:10 +03:00
return !project.hasProperty("release") && new File(projectDir.parent, '../Arc').exists()
2018-12-29 20:22:41 +03:00
}
2018-12-29 19:59:43 +03:00
arcModule = { String name ->
2018-12-29 20:22:41 +03:00
if(localArc()){
2018-12-29 19:59:43 +03:00
return project(":Arc:$name")
}else{
2018-12-29 20:22:41 +03:00
//skip to last submodule
2018-12-29 19:59:43 +03:00
if(name.contains(':')) name = name.split(':').last()
2018-12-29 20:22:41 +03:00
return "com.github.Anuken.Arc:$name:${getArcHash()}"
2018-12-29 19:59:43 +03:00
}
}
2019-08-16 18:00:15 +03:00
generateDeployName = { String platform ->
if(platform == "windows"){
platform += "64"
}
platform = platform.capitalize()
if(platform.endsWith("64") || platform.endsWith("32")){
platform = "${platform.substring(0, platform.length() - 2)}-${platform.substring(platform.length() - 2)}bit"
}
2019-08-16 18:14:18 +03:00
return "[${platform}]${getModifierString()}[${getNeatVersionString()}]${appName}"
2019-08-16 18:00:15 +03:00
}
getVersionString = {
String buildVersion = getBuildVersion()
return "$versionNumber-$versionModifier-$buildVersion"
}
2019-08-16 18:00:15 +03:00
getNeatVersionString = {
String buildVersion = getBuildVersion()
return "v$buildVersion"
}
getModifierString = {
if(versionModifier != "release"){
return "[${versionModifier.toUpperCase()}]"
}
return ""
}
getBuildVersion = {
if(!project.hasProperty("buildversion")) return "custom build"
return project.getProperties()["buildversion"]
}
getPackage = {
return project.ext.mainClassName.substring(0, project.ext.mainClassName.indexOf("desktop") - 1)
}
2018-05-03 20:04:30 +03:00
generateLocales = {
2018-09-09 23:19:53 +03:00
def output = 'en\n'
2018-08-24 20:54:53 +03:00
def bundles = new File(project(':core').projectDir, 'assets/bundles/')
bundles.listFiles().each{ other ->
2018-10-06 18:56:39 +03:00
if(other.name == "bundle.properties") return
2018-09-09 23:19:53 +03:00
output += other.name.substring("bundle".length() + 1, other.name.lastIndexOf('.')) + "\n"
}
2018-10-06 18:56:39 +03:00
new File(project(':core').projectDir, 'assets/locales').text = output
2020-06-05 17:45:57 +03:00
new File(project(':core').projectDir, 'assets/basepartnames').text = new File(project(':core').projectDir, 'assets/baseparts/').list().join("\n")
}
2018-05-03 20:04:30 +03:00
writeVersion = {
2018-08-24 20:54:53 +03:00
def pfile = new File(project(':core').projectDir, 'assets/version.properties')
2018-05-03 20:04:30 +03:00
def props = new Properties()
try{
pfile.createNewFile()
2019-04-08 16:03:18 +03:00
}catch(Exception ignored){
}
2018-05-03 20:04:30 +03:00
if(pfile.exists()){
2018-05-03 20:04:30 +03:00
props.load(new FileInputStream(pfile))
2018-09-04 19:10:48 +03:00
String buildid = getBuildVersion()
2019-08-26 05:02:00 +03:00
println("Compiling with build: '$buildid'")
2018-05-03 20:04:30 +03:00
2018-09-04 19:10:48 +03:00
props["type"] = versionType
props["number"] = versionNumber
props["modifier"] = versionModifier
props["build"] = buildid
2018-05-03 20:04:30 +03:00
props.store(pfile.newWriter(), "Autogenerated file. Do not modify.")
}
}
2020-01-25 02:31:54 +03:00
writeProcessors = {
2020-01-26 21:16:42 +03:00
new File(rootDir, "annotations/src/main/resources/META-INF/services/").mkdirs()
2020-01-25 02:31:54 +03:00
def processorFile = new File(rootDir, "annotations/src/main/resources/META-INF/services/javax.annotation.processing.Processor")
def text = new StringBuilder()
def files = new File(rootDir, "annotations/src/main/java")
files.eachFileRecurse(groovy.io.FileType.FILES){ file ->
if(file.name.endsWith(".java") && (file.text.contains(" extends BaseProcessor") || (file.text.contains(" extends AbstractProcessor") && !file.text.contains("abstract class")))){
text.append(file.path.substring(files.path.length() + 1)).append("\n")
}
}
processorFile.text = text.toString().replace(".java", "").replace("/", ".").replace("\\", ".")
}
2020-05-28 01:11:42 +03:00
writePlugins = {
new File(rootDir, "annotations/src/main/resources/META-INF/services/").mkdirs()
def processorFile = new File(rootDir, "annotations/src/main/resources/META-INF/services/com.sun.source.util.Plugin")
def text = new StringBuilder()
def files = new File(rootDir, "annotations/src/main/java")
files.eachFileRecurse(groovy.io.FileType.FILES){ file ->
if(file.name.endsWith(".java") && (file.text.contains(" implements Plugin"))){
text.append(file.path.substring(files.path.length() + 1)).append("\n")
}
}
processorFile.text = text.toString().replace(".java", "").replace("/", ".").replace("\\", ".")
}
2017-04-30 04:25:59 +03:00
}
repositories{
2017-04-30 04:25:59 +03:00
mavenLocal()
mavenCentral()
maven{ url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven{ url "https://oss.sonatype.org/content/repositories/releases/" }
maven{ url 'https://jitpack.io' }
2019-04-13 21:57:26 +03:00
jcenter()
2017-04-30 04:25:59 +03:00
}
2020-06-16 04:52:51 +03:00
tasks.withType(JavaCompile){
sourceCompatibility = 1.8
targetCompatibility = 1.8
options.encoding = "UTF-8"
2020-06-26 21:27:26 +03:00
options.compilerArgs += ["-Xlint:deprecation"]
2020-06-16 04:52:51 +03:00
}
2017-04-30 04:25:59 +03:00
}
project(":desktop"){
2017-04-30 04:25:59 +03:00
apply plugin: "java"
2020-02-07 18:47:58 +03:00
compileJava.options.fork = true
dependencies{
2020-05-12 19:31:09 +03:00
implementation project(":core")
implementation arcModule("natives:natives-box2d-desktop")
implementation arcModule("natives:natives-desktop")
implementation arcModule("natives:natives-freetype-desktop")
implementation 'com.github.MinnDevelopment:java-discord-rpc:v2.0.1'
2020-05-12 19:31:09 +03:00
if(debugged()) implementation project(":debug")
2020-05-12 19:31:09 +03:00
implementation "com.github.Anuken:steamworks4j:$steamworksVersion"
2019-08-18 22:26:06 +03:00
2020-05-12 19:31:09 +03:00
implementation arcModule("backends:backend-sdl")
}
}
project(":ios"){
2018-04-27 23:01:37 +03:00
apply plugin: "java"
apply plugin: "robovm"
2018-11-21 03:28:26 +03:00
task incrementConfig{
def vfile = file('robovm.properties')
def props = new Properties()
if(vfile.exists()){
props.load(new FileInputStream(vfile))
2019-10-21 00:08:54 +03:00
}else{
props['app.id'] = 'io.anuke.mindustry'
2019-10-25 01:52:42 +03:00
props['app.version'] = '5.0'
2019-12-25 20:06:19 +03:00
props['app.mainclass'] = 'mindustry.IOSLauncher'
2019-10-21 00:08:54 +03:00
props['app.executable'] = 'IOSLauncher'
props['app.name'] = 'Mindustry'
}
2019-10-21 00:08:54 +03:00
props['app.build'] = (!props.containsKey("app.build") ? 40 : props['app.build'].toInteger() + 1) + ""
2018-11-21 03:28:26 +03:00
props.store(vfile.newWriter(), null)
}
dependencies{
2020-05-12 19:31:09 +03:00
implementation project(":core")
2019-04-08 16:03:18 +03:00
2020-05-12 19:31:09 +03:00
implementation arcModule("natives:natives-ios")
implementation arcModule("natives:natives-freetype-ios")
implementation arcModule("natives:natives-box2d-ios")
implementation arcModule("backends:backend-robovm")
2019-04-08 16:03:18 +03:00
2020-04-30 01:29:19 +03:00
compileOnly project(":annotations")
2018-04-27 23:01:37 +03:00
}
}
project(":core"){
2020-05-12 19:31:09 +03:00
apply plugin: "java-library"
2017-04-30 04:25:59 +03:00
2019-06-23 17:52:03 +03:00
task preGen{
2019-10-21 00:05:23 +03:00
outputs.upToDateWhen{ false }
generateLocales()
2019-08-26 05:02:00 +03:00
writeVersion()
2020-01-25 02:31:54 +03:00
writeProcessors()
2020-05-28 01:11:42 +03:00
writePlugins()
}
2019-11-20 03:08:41 +03:00
task copyChangelog{
doLast{
def props = loadVersionProps()
def androidVersion = props['androidBuildCode'].toInteger() - 2
def buildVersion = props["build"]
def loglines = file("../changelog").text.split("\n")
def maxLength = 460
def androidLogList = loglines.findAll{ line -> !line.endsWith("]") || line.endsWith("[Mobile]") || line.endsWith("[Android]")}
def result = ""
2020-05-18 22:38:56 +03:00
androidLogList.forEach{line ->
2019-11-20 03:08:41 +03:00
if(result.length() + line.length() + 1 < maxLength){
result += line + "\n"
}
2020-05-18 22:38:56 +03:00
}
2019-11-20 03:08:41 +03:00
def changelogs = file("../fastlane/metadata/android/en-US/changelogs/")
new File(changelogs, buildVersion + ".txt").text = (result)
new File(changelogs, androidVersion + ".txt").text = (result)
}
}
dependencies{
2019-06-23 17:52:03 +03:00
compileJava.dependsOn(preGen)
2019-05-05 18:36:38 +03:00
2020-05-12 19:31:09 +03:00
api "org.lz4:lz4-java:1.4.1"
api arcModule("arc-core")
api arcModule("extensions:freetype")
api arcModule("extensions:box2d")
api arcModule("extensions:g3d")
api arcModule("extensions:fx")
api arcModule("extensions:arcnet")
2020-06-16 06:22:14 +03:00
api "com.github.Anuken:rhino:$rhinoVersion"
2020-05-12 19:31:09 +03:00
if(localArc() && debugged()) api arcModule("extensions:recorder")
2018-10-29 01:34:18 +03:00
compileOnly project(":annotations")
2018-10-28 21:26:58 +03:00
annotationProcessor project(":annotations")
2017-04-30 04:25:59 +03:00
}
}
project(":server"){
apply plugin: "java"
dependencies{
2020-05-12 19:31:09 +03:00
implementation project(":core")
implementation arcModule("natives:natives-box2d-desktop")
implementation arcModule("backends:backend-headless")
}
}
2018-10-04 03:58:35 +03:00
project(":tests"){
apply plugin: "java"
dependencies{
2018-10-04 03:58:35 +03:00
testImplementation project(":core")
testImplementation "org.junit.jupiter:junit-jupiter-params:5.3.1"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.3.1"
2020-05-12 19:31:09 +03:00
testImplementation arcModule("backends:backend-headless")
testImplementation arcModule("natives:natives-box2d-desktop")
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.3.1"
2018-10-04 03:58:35 +03:00
}
test{
2018-10-04 03:58:35 +03:00
useJUnitPlatform()
workingDir = new File("../core/assets")
2020-05-07 21:35:24 +03:00
testLogging {
exceptionFormat = 'full'
}
2018-10-04 03:58:35 +03:00
}
}
project(":tools"){
2018-06-16 01:06:05 +03:00
apply plugin: "java"
dependencies{
2020-05-12 19:31:09 +03:00
implementation project(":core")
2019-06-20 23:27:57 +03:00
2020-05-12 19:31:09 +03:00
implementation arcModule("natives:natives-desktop")
implementation arcModule("natives:natives-freetype-desktop")
implementation arcModule("natives:natives-box2d-desktop")
implementation arcModule("backends:backend-headless")
2018-06-16 01:06:05 +03:00
}
}
project(":annotations"){
2020-05-12 19:31:09 +03:00
apply plugin: "java-library"
dependencies{
2020-05-12 19:31:09 +03:00
implementation 'com.squareup:javapoet:1.12.1'
implementation "com.github.Anuken.Arc:arc-core:$arcHash"
implementation files("${System.getProperty('java.home')}/../lib/tools.jar")
}
}
2019-08-21 21:46:36 +03:00
task deployAll{
task cleanDeployOutput{
doFirst{
2020-05-12 19:32:53 +03:00
if(getBuildVersion() == "custom build" || getBuildVersion() == "") throw new IllegalArgumentException("----\n\nSET A BUILD NUMBER FIRST!\n\n----")
2019-08-21 21:46:36 +03:00
if(!project.hasProperty("release")) throw new IllegalArgumentException("----\n\nSET THE RELEASE PROJECT PROPERTY FIRST!\n\n----")
delete{
delete "deploy/"
}
}
}
dependsOn cleanDeployOutput
dependsOn "desktop:packrLinux64"
dependsOn "desktop:packrWindows64"
dependsOn "desktop:packrWindows32"
dependsOn "desktop:packrMacOS"
2019-08-21 21:46:36 +03:00
dependsOn "server:deploy"
dependsOn "android:deploy"
2019-09-02 19:40:52 +03:00
}