-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
235 lines (206 loc) · 7.08 KB
/
build.gradle
File metadata and controls
235 lines (206 loc) · 7.08 KB
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
import org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact
import org.gradle.api.internal.java.JavaLibrary
import org.ultramine.gradle.task.ReobfTask
import org.ultramine.gradle.task.SideSplitTask
import org.ultramine.gradle.task.SpeicialClassTransformTask
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'eclipse'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
compileJava.options.encoding = 'UTF-8'
group = project_group
version = (concat_mc_version_to=='version' ? (minecraft_version+'-') : '') + computeVersion()
repositories {
maven {
name 'forge'
url 'http://files.minecraftforge.net/maven'
}
mavenCentral()
maven {
name 'sonatypeSnapshot'
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
maven {
name 'minecraft'
url 'https://libraries.minecraft.net/'
}
maven {
name 'ultramine'
url 'http://maven.ultramine.ru/'
}
}
configurations {
compileCommon
compileClient
compileServer
compile.extendsFrom compileCommon, compileClient, compileServer
runtimeCommon
runtimeClient.extendsFrom runtimeCommon, compileCommon, compileClient
runtimeServer.extendsFrom runtimeCommon, compileCommon, compileServer
runtimeAll.extendsFrom runtimeCommon, compileCommon, compileClient, compileServer
runtime.setExtendsFrom([runtimeAll])
//runtimeClient & runtimeServer is not linking to IDE and must not be used for adding dependencies
}
dependencies {
// compileCommon 'org.ultramine.core:ultramine_core-1.7.10:0.1.0-beta.11'
compile 'org.ultramine.core:ultramine_core-1.7.10:0.2.0-indev'
compileCommon 'org.codehaus.groovy:groovy-all:2.4.4'
testCompile 'org.spockframework:spock-core:1.0-groovy-2.4'
testCompile 'junit:junit:4.5'
testRuntime "cglib:cglib-nodep:2.2.2"
testRuntime "org.objenesis:objenesis:1.2"
}
task injectVersion(type: SpeicialClassTransformTask) {
dependsOn tasks.compileJava
inputDir = tasks.compileJava.destinationDir
replace {
replaceIn 'org.ultramine.mods.scripting.UMScripting'
replace '@version@', version
}
}
task reobf(type: ReobfTask) {
dependsOn tasks.compileJava, tasks.injectVersion
classpath = sourceSets.main.compileClasspath;
srg = 'conf/mcp2srg.srg'
inputDir = tasks.compileJava.destinationDir
overrideInputDir = tasks.injectVersion.outputDir
}
task sidesplit(type: SideSplitTask) {
dependsOn tasks.reobf
inputDir = tasks.reobf.outputDir
}
task processServerResources(type: ProcessResources) {
from sourceSets.main.resources.srcDirs
into new File(buildDir, 'resources_server')
exclude 'assets/minecraft/font'
exclude 'assets/minecraft/shaders'
exclude 'assets/minecraft/texts'
exclude 'assets/minecraft/textures'
exclude 'assets/fml/textures'
}
task processClientResources(type: ProcessResources) {
from sourceSets.main.resources.srcDirs
into new File(buildDir, 'resources_client')
exclude 'org/ultramine/defaults'
}
task jar_server(type: Jar) {
dependsOn(tasks.sidesplit, tasks.processServerResources)
from fileTree(tasks.sidesplit.getServerClasses()), tasks.processServerResources
classifier = 'server'
manifest {
attributes(
'FMLCorePlugin': 'org.ultramine.mods.scripting.asm.CorePlugin',
'FMLCorePluginContainsFMLMod': 'true'
)
}
}
task jar_client(type: Jar) {
dependsOn(tasks.sidesplit, tasks.processClientResources)
from fileTree(tasks.sidesplit.getClientClasses()), tasks.processClientResources
classifier = 'client'
}
task jar_universal(type: Jar) {
dependsOn(tasks.reobf, tasks.processResources)
from tasks.reobf.getOutputDir(), tasks.processResources
classifier = 'universal'
}
jar {
classifier = 'dev'
}
task jar_source(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
artifacts {
if(produce_universal_jar == 'true') archives jar_universal
if(produce_server_jar == 'true') archives jar_server
if(produce_client_jar == 'true') archives jar_client
}
publishing {
publications {
if(publish_jars.contains('dev'))
mavenDevJar(MavenPublication) {
from new JavaLibrary(new ArchivePublishArtifact(tasks.jar), configurations.runtimeCommon.getAllDependencies())
artifacts.matching({it.classifier == "dev"}).all({it.classifier = null})
artifact tasks.jar_source
}
if(publish_jars.contains('universal'))
mavenUnivarsalJar(MavenPublication) {
from new JavaLibrary(new ArchivePublishArtifact(tasks.jar_universal), configurations.runtimeAll.getAllDependencies())
artifacts.matching({it.classifier == "universal"}).all({it.classifier = null})
artifactId = project.name + '-universal'
}
if(publish_jars.contains('server'))
mavenServerJar(MavenPublication) {
from new JavaLibrary(new ArchivePublishArtifact(tasks.jar_server), configurations.runtimeServer.getAllDependencies())
artifacts.matching({it.classifier == "server"}).all({it.classifier = null})
artifactId = project.name + '-server'
}
if(publish_jars.contains('client'))
mavenClientJar(MavenPublication) {
from new JavaLibrary(new ArchivePublishArtifact(tasks.jar_client), configurations.runtimeClient.getAllDependencies())
artifacts.matching({it.classifier == "client"}).all({it.classifier = null})
artifactId = project.name + '-client'
}
}
repositories {
if(project.hasProperty('publish_url') && !publish_url.isEmpty())
maven {
url publish_url
}
}
}
task dumpLibs(type: Copy) {
into "$buildDir/libs/libraries"
from configurations.runtime
}
String getGitDesc() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--long'
standardOutput = stdout
errorOutput = stdout
}.rethrowFailure().assertNormalExitValue()
return stdout.toString().trim()
}
String computeVersion() {
if(project.hasProperty('override_version'))
return override_version
String mmversion; // major.minor
String commit;
try {
String[] parts = getGitDesc().split('-')
if(parts.length != 3) throw new GradleException('no git tags found')
if(!parts[0].startsWith('v')) throw new GradleException('last git tag is not a version')
mmversion = parts[0].substring(1) //removing 'v'
commit = parts[2].substring(1) //removing 'g'
} catch (Exception e) {
if(release_type != 'indev') throw e
return 'indev'
}
if(release_type != 'stable') {
int ind = mmversion.lastIndexOf('.')
mmversion = mmversion.substring(0, ind+1) + ((mmversion.substring(ind+1) as int) + 1) + '.0-' + release_type
}
int revision = 0;
if(project.hasProperty('override_revision')) {
revision = override_revision as int
} else if(release_type != 'indev' || project.hasProperty('increment_revision')) {
File verfile = file("$buildDir/versions/$mmversion")
String filetext;
if(verfile.exists() && !(filetext = verfile.getText().trim()).isEmpty()) {
String[] fileparts = filetext.split(':')
if(fileparts.length != 2) throw new GradleException('Version file is corrupted: ' + verfile.getAbsolutePath())
revision = fileparts[1] as int;
if(!commit.equals(fileparts[0]) || project.hasProperty('increment_revision')) {
revision++;
verfile.write(commit+':'+revision)
}
} else {
verfile.getParentFile().mkdirs()
verfile.write(commit+':0')
}
}
return (revision > 0 || release_type == 'stable') ? (mmversion+'.'+revision) : mmversion;
}