-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
187 lines (163 loc) · 4.63 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
buildscript {
repositories {
jcenter()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
plugins {
id "com.matthewprenger.cursegradle" version "1.0.10"
id "se.bjurr.gitchangelog.git-changelog-gradle-plugin" version "1.55"
}
apply plugin: 'net.minecraftforge.gradle.forge'
ext.configFile = file "build.properties"
configFile.withReader {
def prop = new Properties()
prop.load(it)
project.ext.config = new ConfigSlurper().parse prop
}
version = config.mod_version
group = config.mod_group
archivesBaseName = config.mod_name
if (System.getenv().BUILD_NUMBER)
version = "${config.mod_version}.b${System.getenv().BUILD_NUMBER}"
minecraft {
version = "${config.mc_version}-${config.forge_version}"
runDir = "run"
mappings = "${config.mcp_version}"
makeObfSourceJar = false
}
repositories {
jcenter()
maven {
name = "aroma"
url = "http://files.aroma1997.org/maven/"
}
}
dependencies {
compile "aroma1997.core:Aroma1997Core-${config.mc_version}:+:deobf"
}
processResources
{
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
include '**/reference.properties'
expand 'version': version, 'mcversion': config.mc_version
}
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
exclude '**/reference.properties'
}
}
reobfJar {
//Instead of setting the accepted mc version to the one we're compiling against, we're setting it to the first one (lowest one) we accept.
//Forge does the fuzzy detection then.
getPreTransformers().add(0, new net.minecraftforge.gradle.user.patcherUser.forge.McVersionTransformer(getAvailableMinecraftVersions()[0]))
}
jar {
manifest {
attributes 'FMLCorePlugin': 'aroma1997.stepupfix.StepupfixCore'
//attributes 'FMLCorePluginContainsFMLMod': ''
}
appendix = config.mc_version
}
task deobfJar(type: Jar) {
from sourceSets.main.output
manifest {
attributes 'FMLCorePlugin': 'aroma1997.stepupfix.StepupfixCore'
//attributes 'FMLCorePluginContainsFMLMod': ''
}
appendix = config.mc_version
classifier = 'deobf'
}
artifacts {
archives deobfJar
}
task signJar(dependsOn: ['deobfJar', '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: signingStorepass
)
} else {
println("Skipping jar signing. Signing keystore isn't available.")
}
}
}
build.dependsOn signJar
def getAvailableMinecraftVersions() {
if (!config.availableMcVersions) {
return [ config.mc_version ]
} else {
return config.availableMcVersions.split(',')
}
}
def TEMPORARY_CHANGELOG_FILE = file('changelog/currentchangelog.htm')
def FINISHED_CHANGELOG_FILE = file('changelog/fullchangelog.htm')
task changelog(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) {
doFirst {
//Get current commit.
def stdOut = new ByteArrayOutputStream();
exec {
commandLine "git", "rev-parse", "HEAD"
standardOutput = stdOut
}
toCommit = stdOut.toString().trim()
//Get previous commit
def prevCommitFile = file('changelog/lastcommit.txt')
if (!prevCommitFile.exists()) {
fromCommit = toCommit
} else {
fromCommit = prevCommitFile.text.trim()
}
println "Generating changelog from commit " + fromCommit + " to commit " + toCommit
}
file = TEMPORARY_CHANGELOG_FILE
templateContent = file('changelog/changelog.mustache').getText('UTF-8');
untaggedName = "Release ${project.version}"
doLast {
//Save current commit as previous commit
def prevCommitFile = file('changelog/lastcommit.txt')
prevCommitFile.text = toCommit
//Concate changelogs if something changed
if (!fromCommit.equals(toCommit)) {
//Concat changelogs
if (FINISHED_CHANGELOG_FILE.exists()) {
FINISHED_CHANGELOG_FILE.text = TEMPORARY_CHANGELOG_FILE.text + FINISHED_CHANGELOG_FILE.text
} else {
totalChangelogFile.text = TEMPORARY_CHANGELOG_FILE.text
}
} else {
//Create empty file, because we might need a file for other tasks
if (!FINISHED_CHANGELOG_FILE.exists()) {
FINISHED_CHANGELOG_FILE.text = ""
}
}
}
}
build.dependsOn changelog
curseforge {
apiKey = project.hasProperty('curseforge_apikey') ? project.curseforge_apikey : '0'
project {
id = config.curse_project_id
changelog = FINISHED_CHANGELOG_FILE
changelogType = 'html'
releaseType = version.contains('b') ? 'beta' : 'release'
addArtifact deobfJar
relations {
requiredLibrary 'aroma1997core'
}
getAvailableMinecraftVersions().each { ver -> addGameVersion ver }
}
}