forked from PatchworkMC/patchwork-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
272 lines (232 loc) · 6.89 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
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
plugins {
id 'java'
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'fabric-loom' version '0.4-SNAPSHOT' apply false
id 'net.minecrell.licenser' version '0.4.1'
id "org.ajoberstar.grgit" version "3.1.1"
id 'com.jfrog.bintray' version '1.8.4'
}
def ENV = System.getenv()
class Globals {
static def baseVersion = "0.6.0"
static def mcVersion = "1.14.4"
static def yarnVersion = "+build.16"
}
def getSubprojectVersion(project, version) {
if (grgit == null) {
return version + "+nogit"
}
def latestCommits = grgit.log(paths: [project.name], maxCommits: 1)
if (latestCommits.isEmpty()) {
return version + "+uncommited"
} else {
return version + "+" + latestCommits.get(0).id.substring(0, 8)
}
}
def getBranch() {
if (System.getenv().GIT_BRANCH) {
def branch = System.getenv().GIT_BRANCH
return branch.substring(branch.lastIndexOf("/") + 1)
}
if (grgit == null) {
return "unknown"
}
def branch = grgit.branch.current().name
return branch.substring(branch.lastIndexOf("/") + 1)
}
allprojects {
apply plugin: 'checkstyle'
apply plugin: 'maven-publish'
apply plugin: 'fabric-loom'
apply plugin: 'net.minecrell.licenser'
sourceCompatibility = 1.8
targetCompatibility = 1.8
group = "net.patchworkmc.patchwork-api"
dependencies {
minecraft "com.mojang:minecraft:$Globals.mcVersion"
mappings "net.fabricmc:yarn:${Globals.mcVersion}${Globals.yarnVersion}:v2"
modCompile "net.fabricmc:fabric-loader:0.8.4+build.198"
modCompile "net.fabricmc.fabric-api:fabric-api:0.4.2+build.246-1.14"
implementation 'net.patchworkmc:patchwork-eventbus:2.0.0:all'
implementation 'com.google.code.findbugs:jsr305:3.0.2'
// For EventBus
implementation 'net.jodah:typetools:0.6.0'
}
configurations {
dev
}
repositories {
maven { url 'https://dl.bintray.com/patchworkmc/Patchwork-Maven/' }
}
jar {
classifier = "dev"
}
afterEvaluate {
remapJar {
input = file("${project.buildDir}/libs/$archivesBaseName-${version}-dev.jar")
archiveName = "${archivesBaseName}-${version}.jar"
}
artifacts {
dev file: file("${project.buildDir}/libs/$archivesBaseName-${version}-dev.jar"), type: "jar", builtBy: jar
}
processResources {
inputs.property "version", project.version
from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
expand "version": project.version
}
from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
}
}
license {
header rootProject.file('HEADER')
include '**/*.java'
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
checkstyle {
configFile = rootProject.file("checkstyle.xml")
toolVersion = '8.25'
}
}
javadoc {
options.memberLevel = "PACKAGE"
allprojects.each {
source(it.sourceSets.main.allJava.srcDirs)
}
classpath = sourceSets.main.compileClasspath
}
subprojects {
task remapMavenJar(type: Copy, dependsOn: remapJar) {
afterEvaluate {
from("${project.buildDir}/libs/$archivesBaseName-${version}.jar")
into("${project.buildDir}/libs/")
rename {String fn -> "$archivesBaseName-${version}-maven.jar"}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact(file("${project.buildDir}/libs/$archivesBaseName-${version}-maven.jar")) {
builtBy remapMavenJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}
repositories {
maven {
url "http://mavenupload.modmuss50.me/"
if (project.hasProperty('mavenPass')) {
credentials {
username 'buildslave'
password project.getProperty('mavenPass')
}
}
}
}
}
javadoc.enabled = false
}
task remapMavenJar(type: net.fabricmc.loom.task.RemapJarTask, dependsOn: jar) {
afterEvaluate {
input = file("${project.buildDir}/libs/${archivesBaseName}-${version}-dev.jar")
archiveName = "${archivesBaseName}-${version}-maven.jar"
addNestedDependencies = false
}
}
bintray {
user = project.hasProperty('bintrayUser') ? project.getProperty('bintrayUser') : System.getenv('bintray_user')
key = project.hasProperty('bintrayKey') ? project.getProperty('bintrayKey') : System.getenv('bintray_key')
publish = true
override = true
publications = ['mavenJava']
pkg {
repo = project.bintrayRepo
name = project.name
user = bintray.user
userOrg = project.repoOwner
licenses = [project.codeLicense]
desc = project.description
websiteUrl = "https://github.com/${project.repoOwner}/${project.repoName}"
issueTrackerUrl = "https://github.com/${project.repoOwner}/${project.repoName}/issues"
vcsUrl = "https://github.com/${project.repoOwner}/${project.repoName}.git"
publicDownloadNumbers = true
githubRepo = "${project.repoOwner}/${project.repoName}"
version {
name = project.version
released = new Date()
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact(file("${project.buildDir}/libs/$archivesBaseName-${version}-maven.jar")) {
builtBy remapMavenJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
pom.withXml {
def depsNode = asNode().appendNode("dependencies")
subprojects.each {
def depNode = depsNode.appendNode("dependency")
depNode.appendNode("groupId", it.group)
depNode.appendNode("artifactId", it.name)
depNode.appendNode("version", it.version)
depNode.appendNode("scope", "compile")
}
}
}
}
}
task licenseFormatAll
subprojects {p -> licenseFormatAll.dependsOn("${p.path}:licenseFormat")}
subprojects.each {remapJar.dependsOn("${it.path}:remapJar")}
repositories {
flatDir {
dirs 'jars'
}
mavenCentral()
maven { url 'https://dl.bintray.com/patchworkmc/Patchwork-Maven/' }
}
dependencies {
afterEvaluate {
subprojects.each {
compile project(path: ":${it.name}", configuration: "dev")
include project("${it.name}:")
}
}
minecraft "com.mojang:minecraft:$Globals.mcVersion"
mappings "net.fabricmc:yarn:${Globals.mcVersion}${Globals.yarnVersion}:v2"
modCompile "net.fabricmc:fabric-loader:0.8.4+build.198"
modCompile "net.fabricmc.fabric-api:fabric-api:0.4.2+build.246-1.14"
implementation 'com.electronwill.night-config:toml:3.6.2'
include 'com.electronwill.night-config:core:3.6.2'
include 'com.electronwill.night-config:toml:3.6.2'
include 'net.patchworkmc:patchwork-eventbus:2.0.0:all'
fileTree(dir: 'jars', include: '*.jar').each {
String baseName = it.name.replace(".jar", "")
String version = "0.1.0"
int split = baseName.lastIndexOf('-')
if (split != -1) {
version = baseName.substring(split + 1)
baseName = baseName.substring(0, split)
}
String name = "testmod:${baseName}:${version}"
System.out.println("Found test mod: " + it.name.replace(".jar", "") + " -> " + name)
modCompileOnly name
modRuntime name
}
}
version = Globals.baseVersion //+ "+" + (ENV.BUILD_NUMBER ? ("build." + ENV.BUILD_NUMBER) : "local") + "-" + getBranch()
logger.lifecycle("Building Patchwork: " + version)
apply from: 'https://github.com/FabricMC/fabric-docs/raw/master/gradle/ideconfig.gradle'