-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
192 lines (159 loc) · 5.4 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
buildscript {
repositories {
jcenter()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
// Required for the curseforge task
name = "gradle"
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath "gradle.plugin.com.matthewprenger:CurseGradle:1.1.0"
}
}
apply plugin: 'java'
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'com.matthewprenger.cursegradle'
ext.propFile = file "build.properties"
propFile.withReader {
def prop = new Properties()
prop.load(it)
project.ext.props = new ConfigSlurper().parse prop
}
version = props.beneath_version
group= "com.shinoow.beneath" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "The Beneath"
sourceCompatibility = targetCompatibility = "1.8"
compileJava {
sourceCompatibility = targetCompatibility = "1.8"
}
minecraft {
version = "1.12.2-14.23.0.2491"
runDir = "run"
mappings = "snapshot_20170624"
makeObfSourceJar = false
replaceIn "Beneath.java"
replace "forgeversion", props.forge_version
replace "beneath_version", props.beneath_version
replace "cert_fingerprint", project.findProperty('signSHA1')
}
dependencies {
}
version = "${props.mc_version}-${props.beneath_version}"
processResources
{
// I really don't want that file to exist anywhere
exclude '**/Thumbs.db'
// 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'
include 'version.properties'
// replace version and mcversion
expand ([
'version':project.version,
'beneathversion':project.props.beneath_version,
'mcversion':project.props.mc_version,
'forgeversion':project.props.forge_version
])
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
exclude 'version.properties'
}
}
task srcJar(type: Jar) {
from sourceSets.main.allJava
extension = 'jar'
classifier = 'sources'
}
artifacts {
archives srcJar
}
curseforge {
apiKey = project.hasProperty('curseForgeApiKey') ? project.curseForgeApiKey : '' // gradle curse -Pcurseforge_key=your-api-key
project{
id = "254629" // http://minecraft.curseforge.com/mc-mods/"xxxxxx"-projectname
releaseType = project.props.release_type //alpha beta release
changelogType = 'html'
changelog = new File('changelog.html') //must have at least an empty string
addArtifact srcJar
relations {
optionalDependency 'grue'
}
}
}
task signJar(type: SignJar, dependsOn: reobfJar) {
// Skips if the keyStore property is missing.
onlyIf {
project.hasProperty('keyStore')
}
// findProperty allows us to reference the property without it existing.
// Using project.propName would cause the script to fail validation if
// the property did not exist.
keyStore = project.findProperty('keyStore')
alias = project.findProperty('keyStoreAlias')
storePass = project.findProperty('keyStorePass')
keyPass = project.findProperty('keyStoreKeyPass')
inputFile = jar.archivePath
outputFile = jar.archivePath
}
// Runs this task automatically when build is ran.
build.dependsOn signJar
//copies the source files over to the folder from which they will be included in a RAR-file
task prepareFiles(type: Copy){
from "$rootDir"
include "build.gradle"
include "build.properties"
include "changelog.html"
include "gradle.properties"
include "src/main/**"
into "$buildDir/rarTemp"
String filePath = "${project.findProperty("sourceDirTB")}/The Beneath ${props.beneath_version} (${props.mc_version}).rar"
String filePath1 = "${buildDir}/rarTemp/*"
new File(projectDir, "generateRAR.bat").text = project.findProperty("rarCommand")+' "'+filePath+'" "'+filePath1+'"';
}
//copies the src jar to the place where binaries are stored
task copySrcJar(type: Copy){
from srcJar
into "${project.findProperty("binariesDir")}/${archivesBaseName}/jars"
}
//copies the main jar to the place where binaries are stored
task copyJar(type: Copy){
from jar
into "${project.findProperty("binariesDir")}/${archivesBaseName}/jars"
}
//generates a jar file with the source code and gradle files, then places it in a good place
task generateRar(type: Exec){
commandLine 'cmd', "/c", "generateRAR.bat";
ignoreExitValue = true
}
//runs all of the tasks for building and deploying
task buildAndDeploy(){
dependsOn 'clean'
dependsOn 'build'
dependsOn 'curseforge'
dependsOn 'copySrcJar'
dependsOn 'copyJar'
dependsOn 'prepareFiles'
dependsOn 'generateRar'
tasks.findByName('build').mustRunAfter 'clean'
tasks.findByName('curseforge').mustRunAfter 'build'
tasks.findByName('prepareFiles').mustRunAfter 'build'
tasks.findByName('generateRar').mustRunAfter 'prepareFiles'
tasks.findByName('copySrcJar').mustRunAfter 'prepareFiles'
tasks.findByName('copyJar').mustRunAfter 'prepareFiles'
}
//final cleanup
buildAndDeploy.doLast {
delete "${buildDir}/rarTemp/"
delete "generateRAR.bat"
}