forked from MCLink-Modding/MCLink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
135 lines (112 loc) · 4.17 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
import groovy.json.JsonBuilder
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
version = "0.3.2"
if (System.getenv().BUILD_NUMBER != null) version += "." + System.getenv().BUILD_NUMBER
subprojects {
version = rootProject.version
}
ext.getChangeLog = { ->
def outStream = new ByteArrayOutputStream()
exec {
executable = 'git'
args = ['log', '-n', '1', "--format='%B'"]
standardOutput = outStream
}
return outStream.toString().replaceAll("^\\s*'\\s*|\\s*'\\s*\$", "").replaceAll("[\\r\\n]+", "\n")
}
evaluationDependsOnChildren()
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
allprojects {
group = "net.dries007.mclink"
archivesBaseName = "MCLink"
apply plugin: 'maven'
sourceCompatibility = targetCompatibility = "1.8"
compileJava {
sourceCompatibility = targetCompatibility = "1.8"
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.guava:guava:17.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'org.apache.logging.log4j:log4j-core:2.0-beta9'
compile 'org.jetbrains:annotations:15.0'
}
//noinspection GroovyAssignabilityCheck
task setupDecompWorkspace
//noinspection GroovyAssignabilityCheck
task setupDevWorkspace
//noinspection GroovyAssignabilityCheck
task setupCiWorkspace
//noinspection GroovyAssignabilityCheck
project.tasks.withType(Jar) { jarTask ->
jarTask.appendix = 'lib'
}
subprojects {
version = rootProject.version
dependencies {
compile rootProject
}
sourceSets.main.resources.srcDirs += rootProject.sourceSets.main.resources.srcDirs
jar {
//noinspection GroovyAssignabilityCheck
duplicatesStrategy = 'exclude'
from rootProject.sourceSets.main.output
}
if (project.hasProperty('minecraft')) {
sourceJar {
//noinspection GroovyAssignabilityCheck
duplicatesStrategy = 'exclude'
from rootProject.sourceSets.main.allSource
}
//noinspection GroovyAssignabilityCheck
project.tasks.withType(Jar) { jarTask ->
jarTask.appendix = 'Forge-' + project.minecraft.version
}
processResources {
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
expand 'version': project.version, 'mcversion': project.minecraft.version
}
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
doLast {
//noinspection GroovyAssignabilityCheck
def updateFile = new File(project.archivesBaseName.toLowerCase() + '.json')
def json
if (updateFile.exists()) {
json = new JsonSlurper().parseText(updateFile.getText())
} else {
def builder = new JsonBuilder()
json = builder(homepage: "https://mclink.dries007.net", promos: new HashMap<>())
}
//noinspection GroovyAssignabilityCheck
json['promos'][project.minecraft.version + '-latest'] = project.version
//noinspection GroovyAssignabilityCheck
json['promos'][project.minecraft.version + '-recommended'] = project.version
if (!json.containsKey(project.minecraft.version)) json.put(project.minecraft.version, new HashMap<>())
//noinspection GroovyAssignabilityCheck
def version = json[project.minecraft.version]
version.put(project.version, getChangeLog())
updateFile.write JsonOutput.prettyPrint(JsonOutput.toJson(json))
}
}
rootProject.setupDecompWorkspace.dependsOn setupDecompWorkspace
rootProject.setupDevWorkspace.dependsOn setupDevWorkspace
rootProject.setupCiWorkspace.dependsOn setupCiWorkspace
} else {
//noinspection GroovyAssignabilityCheck
project.tasks.withType(Jar) { jarTask ->
jarTask.appendix = project.name
}
}
rootProject.build.dependsOn build
}