This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
/
build.gradle
256 lines (219 loc) · 6.16 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
plugins {
id 'java'
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'fabric-loom' version '0.5-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.11.0"
static def mcVersion = "1.16.5"
static def yarnVersion = "+build.1"
}
version = Globals.baseVersion //+ "+" + (ENV.BUILD_NUMBER ? ("build." + ENV.BUILD_NUMBER) : "local") + "-" + getBranch()
logger.lifecycle("Building Patchwork: " + version)
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'
apply plugin: 'com.jfrog.bintray'
sourceCompatibility = 1.8
targetCompatibility = 1.8
group = "net.patchworkmc.patchwork-api"
loom {
shareCaches = true
}
repositories {
maven { url 'https://maven.patchworkmc.net' }
}
dependencies {
minecraft "com.mojang:minecraft:$Globals.mcVersion"
mappings "net.fabricmc:yarn:${Globals.mcVersion}${Globals.yarnVersion}:v2"
modImplementation "net.fabricmc:fabric-loader:0.11.1"
modImplementation "net.fabricmc.fabric-api:fabric-api:0.30.0+1.16"
implementation 'net.patchworkmc:event-racecar:1.0.1:with-typetools'
implementation 'com.electronwill.night-config:toml:3.6.2'
implementation 'org.cadixdev:lorenz:0.5.7'
}
configurations {
dev
}
jar {
classifier = "dev"
}
afterEvaluate {
remapJar {
input.set(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.39'
}
}
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 {
create("${archivesBaseName}_mavenJava", MavenPublication) {
afterEvaluate {
artifact(file("${project.buildDir}/libs/$archivesBaseName-${version}-maven.jar")) {
builtBy remapMavenJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}
}
}
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 = ["${archivesBaseName}_mavenJava"]
pkg {
repo = project.bintrayRepo
name = archivesBaseName
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()
}
}
}
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
}
}
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://maven.patchworkmc.net' }
}
dependencies {
afterEvaluate {
subprojects.each {
compile project(path: ":${it.name}", configuration: "dev")
include project("${it.name}:")
}
}
include 'com.electronwill.night-config:core:3.6.2'
include 'com.electronwill.night-config:toml:3.6.2'
include 'net.patchworkmc:event-racecar:1.0.1:with-typetools'
include 'org.cadixdev:lorenz:0.5.7'
include 'org.cadixdev:bombe:0.3.4'
}
loom {
shareCaches = true
}
task copyIdeaFiles(type: Copy) {
if (file(".idea/").exists()) {
from "idea-docs/"
into ".idea/"
}
}
copyIdeaFiles