-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.gradle
115 lines (98 loc) · 3.44 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
buildscript {
repositories {
jcenter()
maven { url = "http://files.minecraftforge.net/maven" }
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
// setup plugins to use
plugins {
id 'de.fuerstenau.buildconfig' version '1.1.8'
id 'idea'
id 'net.minecraftforge.gradle.forge' version '2.0.2'
}
// setup external properties file
ext.configFile = file "build.properties"
// read external properties file
configFile.withReader {
def prop = new Properties()
prop.load(it)
project.ext.config = new ConfigSlurper().parse prop
}
// set default version, group and package namespace
version = config.mc_version + '-' + config.mod_version
group = config.mod_group
archivesBaseName = config.mod_name
// if we are building from pipeline, then add build number to the version
if (System.getenv().BUILD_NUMBER)
version = "${version}.${System.getenv().BUILD_NUMBER}"
// if we are not building with a key, add this to the version
if (!project.hasProperty('signingKeystore')) {
project.properties.put('signingFingerprint', 'unsigned')
version = version + '-unsigned'
}
sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
}
minecraft {
version = "${config.mc_version}-${config.forge_version}"
runDir = "run"
mappings = 'stable_39'
makeObfSourceJar = false
}
dependencies {
testCompile "junit:junit:4.11"
testCompile 'org.mockito:mockito-core:2.7.22'
}
buildConfig {
sourceSets{
appName = config.mod_name
main {
buildConfigField "String", "acceptedVersions", config.accepted_versions
buildConfigField "String", "fingerprint", project.findProperty('signingFingerprint')
buildConfigField "String", "updateJSON",
config.update_url +
'?mkver=' + project.version +
'&mcver=' + config.mc_version +
'&fmver=' + config.forge_version +
'&fngpt=' + project.findProperty('signingFingerprint')
}
}
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "mod_version", project.version
inputs.property "mod_name", config.mod_name
inputs.property "mc_version", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace variable
expand 'mod_name':config.mod_name, 'mod_version':project.version, 'mc_version':project.minecraft.version
}
// copy everything else except the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
task signJar(dependsOn: ['jar']){
doLast {
// Skip the task if our secret data isn't available
if (project.hasProperty('signingKeystore')) {
ant.signjar(
destDir: "$buildDir/libs",
jar: "$buildDir/libs/*.jar",
alias: signingAlias,
storetype: "jks",
keystore: signingKeystore,
storepass: signingPassword
)
} else {
println("Skipping jar signing. Signing keystore isn't available.")
}
}
}
build.dependsOn signJar