forked from OreCruncher/DynamicSurroundings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
199 lines (162 loc) · 6.02 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
188
189
190
191
192
193
194
195
196
197
198
199
buildscript {
repositories {
jcenter()
maven {
name = "Forge"
url = "http://files.minecraftforge.net/maven"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply from: 'configuration.gradle'
sourceCompatibility = targetCompatibility = "1.8" // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = "1.8"
}
minecraft {
runDir = "run"
replace '@VERSION@', project.ext.modVersion
mappings = project.ext.snapshot
}
repositories {
maven {
name = "chickenbones"
url = "http://chickenbones.net/maven/"
}
maven {
url "http://dvs1.progwml6.com/files/maven"
}
maven {
name "Mobius Repo"
url "http://mobiusstrip.eu/maven"
}
maven {
name "Foxiehost"
url "http://maven.foxiehost.eu"
}
maven {
name "Chisel"
url "http://maven.tterrag.com"
}
maven {
url 'https://repo.elytradev.com/'
}
}
dependencies {
//compile "com.github.glitchfiend.biomesoplenty:BiomesOPlenty:1.12.2-7.0.1.2399:deobf"
// http://dvs1.progwml6.com/files/maven/mezz/jei/
deobfCompile "mezz.jei:jei_1.12.2:4.11.0.212:api"
runtime "mezz.jei:jei_1.12.2:4.11.0.212"
}
processResources
{
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
// Reobfuscate the output of the mod JAR task with SRG names, otherwise the mod won't be able to reference MC classes
reobf {
coreJar { mappingType = 'SEARGE' }
}
// Define a new task for the contained JAR
// If you want to, you can distribute this as a separate artifact to a Maven
task coreJar(type: Jar) {
// Copy all compiled files and resources from the source set to the JAR
// If you have additional source sets, add the same logic here
from(sourceSets.main.output) {
// Include the coremod package
// If you need additional files, add some more includes
include 'org/orecruncher/dsurround/asm/**'
}
// Standard coremod manifest definitions
manifest {
// Added benefit of separating mod and coremod: No need for FMLCorePluginContainsFMLMod
attributes 'FMLCorePlugin': "org.orecruncher.dsurround.asm.TransformLoader"
// Strictly speaking not required (right now)
// Allows Forge to extract the dependency to a local repository (Given that the corresponding PR is merged)
// If another mod ships the same dependency, it doesn't have to be extracted twice
attributes 'Maven-Artifact': "${project.group}:${project.archivesBaseName}-core:${project.version}"
}
// Add a classifier to the JAR ('-core' at the end of the file name)
// Distinguishes the mod JAR from the shipped one
classifier 'core'
group = 'build'
}
task sourcesJar(type: Jar, dependsOn: classes) {
description = 'Creates a JAR containing the source code.'
from sourceSets.main.allSource
classifier = 'sources'
}
task deobfJar(type: Jar) {
description = 'Creates a JAR containing the non-obfuscated compiled code.'
from sourceSets.main.output
classifier = "deobf"
manifest {
// The crucial manifest attribute: Make Forge extract the contained JAR
attributes 'ContainedDeps': coreJar.archivePath.name
attributes 'FMLAT': 'dsurround_at.cfg'
attributes 'Maven-Artifact': "${project.group}:${project.archivesBaseName}:${project.version}"
}
}
task signCoreJar(type: SignJar) {
onlyIf { // Skip the task if our secret data isn't available
project.hasProperty('keyStore')
}
dependsOn reobfCoreJar
keyStore = project.keyStore // This needs to be a path to the keystore file
alias = project.keyStoreAlias
storePass = project.keyStorePass
keyPass = project.keyStoreKeyPass
inputFile = coreJar.archivePath.absolutePath
outputFile = coreJar.archivePath.absolutePath
}
jar {
// Don't include the coremod in the main JAR
// If you have more coremod-related packages that aren't nested in the main one, add inclusions for them
exclude 'org/orecruncher/dsurround/asm/**'
// Add the output of the coremod JAR task to the main JAR for later extraction
from(coreJar.archivePath.absolutePath) {
include '*' // Due to the way Gradle's copy tasks work, we need this line for the JAR to get added
}
manifest {
// The crucial manifest attribute: Make Forge extract the contained JAR
attributes 'ContainedDeps': coreJar.archivePath.name
attributes 'FMLAT': 'dsurround_at.cfg'
attributes 'Maven-Artifact': "${project.group}:${project.archivesBaseName}:${project.version}"
}
// Only run the main jar task after the coremod JAR was completely built
dependsOn signCoreJar
}
// https://gist.github.com/matthewprenger/9b2da059b89433a01c1c
task signJar(type: SignJar) {
onlyIf { // Skip the task if our secret data isn't available
project.hasProperty('keyStore')
}
dependsOn reobfJar
keyStore = project.keyStore // This needs to be a path to the keystore file
alias = project.keyStoreAlias
storePass = project.keyStorePass
keyPass = project.keyStoreKeyPass
inputFile = jar.archivePath
outputFile = jar.archivePath
}
//Adds the artifact types added by this script to the actual artifacts list.
artifacts {
archives sourcesJar
archives deobfJar
}
signJar.dependsOn build
signJar.dependsOn signCoreJar