This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathbuild.gradle
172 lines (141 loc) · 4.71 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
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
name = 'forge'
url = 'http://files.minecraftforge.net/maven'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
classpath 'com.matthewprenger:CurseGradle:1.0-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'com.matthewprenger.cursegradle'
// ext.build = System.getenv().BUILD_NUMBER ?: 'git'
ext.modversion = "${project.version_major}.${project.version_minor}.${project.version_micro}"
group = 'com.kamesuta.mc'
version = "${project.version_minecraft}-${modversion}"
compileJava.options.encoding = 'UTF-8'
idea {
module {
downloadSources = true
inheritOutputDirs = true
}
}
minecraft {
version = "${project.version_minecraft}-${project.version_forge}"
if (project.hasProperty('version_mappings'))
mappings = project.version_mappings
if (!project.hasProperty('run_location'))
runDir = 'run'
else
runDir = run_location.replace('{modid}', project.name).replace('{mcversion}', project.version_minecraft)
replaceIn 'Reference.java'
replace '${version}', modversion
replace '${mcversion}', project.version_minecraft
replace '${forgeversion}', project.version_forge
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property 'version', project.version
inputs.property 'mcversion', project.minecraft.version
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
expand([
'modid' : project.name,
'version' : modversion,
'mcversion' : project.version_minecraft,
'forgeversion' : project.version_forge,
'minforgeversion': project.hasProperty('version_minforge') ? project.version_minforge : project.version_forge,
])
}
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
dependencies {
}
def commonManifest = {
if (project.hasProperty('extra_fmlat')) {
attributes 'FMLAT': project.extra_fmlat
}
}
jar {
from sourceSets.api.output
classifier = project.hasProperty('extra_classifier') ? project.extra_classifier : 'universal'
manifest commonManifest
}
sourceJar {
from sourceSets.api.allSource
}
task apiJar(dependsOn: 'classes', type: Jar) {
from sourceSets.api.output
classifier = 'api'
manifest commonManifest
}
artifacts {
archives sourceJar
archives apiJar
}
if (!project.hasProperty('keystore_location'))
ext.keystore_location = '.'
if (!project.hasProperty('keystore_alias'))
ext.keystore_alias = ''
if (!project.hasProperty('keystore_password'))
ext.keystore_password = ''
task signJars(dependsOn: ['reobf', 'devJar', 'sourceJar', 'apiJar']) {
inputs.dir jar.destinationDir
inputs.file keystore_location
inputs.property 'keystore_alias', keystore_alias
inputs.property 'keystore_password', keystore_password
outputs.dir jar.destinationDir
onlyIf {
return keystore_location != '.'
}
doLast {
jar.destinationDir.eachFile { file ->
if (!file.getPath().endsWith('.jar'))
return;
logger.lifecycle "signing ${file}"
ant.signjar(
destDir: file.getParentFile(),
jar: file,
keystore: keystore_location,
alias: keystore_alias,
storepass: keystore_password
)
}
}
}
if (!project.hasProperty('release_location'))
ext.release_location = '.'
else
ext.release_location = release_location.replace('{modid}', project.name).replace('{mcversion}', project.version_minecraft).replace('{version}', version)
task release(dependsOn: 'signJars', type: Copy) {
from project.tasks.jar.destinationDir
into project.file(project.release_location)
eachFile { file ->
logger.lifecycle "copying ${file}"
}
onlyIf {
return project.release_location != '.'
}
}
if (project.hasProperty('api_key_curseforge') && project.hasProperty('extra_curseforge_id')) {
curse {
dependsOn signJars
releaseType = project.hasProperty('extra_curseforge_releasetype') ? project.extra_curseforge_releasetype : 'release'
apiKey = project.api_key_curseforge
projectId = project.extra_curseforge_id
changelog = ''
additionalArtifact devJar, sourceJar, apiJar
relatedProject 'lunatriuscore'
}
}