-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
executable file
·179 lines (156 loc) · 5.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
173
174
175
176
177
178
179
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
name = "Fabric"
url = "http://maven.modmuss50.me/"
}
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "net.fabricmc:fabric-loom:0.2.6-SNAPSHOT"
//Don't backdate before 0.2.0; features in this version prevent messy workarounds!
classpath "com.github.jengelman.gradle.plugins:shadow:5.0.0"
}
}
plugins {
id "com.jfrog.artifactory" version "4.9.0"
}
apply plugin: net.fabricmc.loom.LoomGradlePlugin
apply plugin: 'maven-publish'
apply from: "project.gradle"
if (ext.needsShadow) {
apply plugin: "com.github.johnrengelman.shadow"
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
archivesBaseName = ext.projectName
group = ext.group
version = ext.version + ((ext.snapshot) ? "-SNAPSHOT" : "")
repositories {
mavenCentral()
maven {
url "http://server.bbkr.space:8081/artifactory/libs-snapshot"
}
maven {
url "http://server.bbkr.space:8081/artifactory/libs-release"
}
}
dependencies {
minecraft "com.mojang:minecraft:" + project.ext.minecraft
mappings "net.fabricmc:yarn:" + project.ext.mappings
modCompile "net.fabricmc:fabric-loader:" + project.ext.loader
if (project.ext.fabricMod != null) {
modCompile "net.fabricmc.fabric-api:fabric-api:" + project.ext.fabricMod
}
if (project.ext.silkMod != null) {
modCompile "io.github.prospector.silk:SilkAPI:" + project.ext.silkMod
}
if (project.ext.cotton != null) {
modCompile "io.github.cottonmc.cotton:cotton:" + project.ext.cotton
}
if (project.ext.jankson != null) {
if (needsShadow) {
//Jankson will be shadowed
shadow "blue.endless:jankson:" + project.ext.jankson
implementation "blue.endless:jankson:" + project.ext.jankson
} else {
System.out.println("#################################################################")
System.out.println("# Shadow is disabled. Jankson will be ommitted from this build! #")
System.out.println("#################################################################")
}
}
}
task sourcesJar(type: Jar) {
baseName = archivesBaseName
classifier = "sources"
from sourceSets.main.allSource
from sourceSets.main.resources
}
shadowJar {
if (project.ext.jankson != null) {
relocate 'blue.endless.jankson', 'io.github.cottonmc.repackage.blue.endless.jankson'
}
classifier = 'dev'
configurations = [project.configurations.shadow]
}
remapJar.dependsOn shadowJar
if (ext.needsShadow) { //If we're using shadow, we need to let remap know it's remapping the shadowJar
remapJar {
dependsOn shadowJar
}
}
if (rootProject.file('private.gradle').exists()) { //Publishing details
apply from: 'private.gradle'
}
publishing {
publications {
maven(MavenPublication) {
from components.java
artifactId = project.ext.projectName
pom.withXml {
def pomFile = asNode()
def depsNode = pomFile.get("dependencies")
pomFile.remove(depsNode)
def newDeps = pomFile.appendNode("dependencies")
configurations.modCompile.getResolvedConfiguration().getFirstLevelModuleDependencies().each {
def artifactNode = newDeps.appendNode("dependency")
artifactNode.appendNode('groupId', it.moduleGroup)
artifactNode.appendNode('artifactId', it.moduleName)
artifactNode.appendNode('version', it.moduleVersion)
}
}
artifacts = [
artifact("${project.buildDir.absolutePath}/libs/${archivesBaseName}-${project.version}-shadow.jar") {
//release jar - file location not provided anywhere in loom
classifier null
builtBy remapJar
},
artifact("${project.buildDir.absolutePath}/libs/${archivesBaseName}-${project.version}-shadow-dev.jar") {
//release jar - file location not provided anywhere in loom
classifier "dev"
builtBy remapJar
},
artifact(tasks.sourcesJar)
]
}
}
/* Supply an ext block in private.gradle like so:
ext { mavenSnapshotDir="file:///some_local_directory_path" }
* and then just run "./gradlew publish" to save the artifacts to the specified directory, in a way that they can be
* served by apache or your favorite httpd and behave like a maven repo. Complete with verification hashes.
*/
repositories {
if (rootProject.ext.has("localMavenUrl")) {
maven {
url = rootProject.ext.localMavenUrl
}
}
}
}
artifactory {
if (project.hasProperty("artifactoryUsername")) {
contextUrl = 'http://server.bbkr.space:8081/artifactory/'
publish {
repository {
if (version.contains("SNAPSHOT")) {
repoKey = "libs-snapshot"
} else {
repoKey = "libs-release"
}
username = artifactoryUsername
password = artifactoryPassword
}
defaults {
publications('maven')
publishArtifacts = true
publishPom = true
}
}
} else {
println "Cannot configure artifactory; please define ext.artifactoryUsername and ext.artifactoryPassword before running artifactoryPublish"
}
}