This repository has been archived by the owner on Mar 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.gradle
155 lines (135 loc) · 5.26 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
apply plugin: "java-library"
apply plugin: "maven-publish"
// Plugin config
compileJava.options.encoding = 'UTF-8'
ext.pluginNameUpper = "NyaaUtils"
ext.pluginNameLower = ext.pluginNameUpper.toLowerCase()
ext.majorVersion = 8
ext.minorVersion = 1
ext.minecraftVersion = "1.17"
sourceCompatibility = 16
targetCompatibility = 16
// Suppiled by Jenkins
ext.buildNumber = System.env.BUILD_NUMBER == null ? "x" : "$System.env.BUILD_NUMBER"
ext.mavenDirectory = System.env.MAVEN_DIR == null ? "$projectDir/repo" : "$System.env.MAVEN_DIR"
ext.jdDirectory = System.env.JAVADOCS_DIR == null ? null : "$System.env.JAVADOCS_DIR"
// Search for spigot nms jar file
String spigotNmsPath = ""
if (System.env.NMS_JAR != null) {
// use NMS_JAR if it's explicitly specified
spigotNmsPath = "$System.env.NMS_JAR"
if (new File(spigotNmsPath).exists()) {
logger.warn("NMS jar is set manually: ${spigotNmsPath}")
} else {
throw new GradleException("NMS jar not found: ${spigotNmsPath}")
}
} else if (new File("${mavenDirectory}/spigot-${minecraftVersion}-latest.jar").exists()) {
// ci environment
spigotNmsPath = "${mavenDirectory}/spigot-${minecraftVersion}-latest.jar"
} else {
// check local dir (dev environment)
spigotNmsPath = "${projectDir}/../nms_binaries/spigot-${minecraftVersion}.jar"
if (!(new File(spigotNmsPath).exists())) {
// nms not found, download from nyaaci
def f = new File(spigotNmsPath)
println "Downloading spigot-${minecraftVersion}.jar"
f.getParentFile().mkdirs()
new URL("https://ci.nyaacat.com/maven/spigot-${minecraftVersion}-latest.jar").withInputStream{ i -> f.withOutputStream{ it << i }}
}
}
println ("Found NMS jar: ${spigotNmsPath}")
// Version used for distribution. Different from maven repo
group = "cat.nyaa"
archivesBaseName = "${pluginNameUpper}-mc$minecraftVersion"
version = "$majorVersion.$minorVersion.$buildNumber".toString()
repositories {
mavenCentral()
maven { name 'Spigot'; url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { name 'Sonatype'; url 'https://oss.sonatype.org/content/groups/public' }
maven { name 'sk89q'; url 'https://maven.sk89q.com/artifactory/repo/' }
maven { name 'vault-repo'; url 'https://jitpack.io' }
maven { name 'NyaaCat'; url 'https://ci.nyaacat.com/maven/' }
maven { name 'EssentialsX'; url 'https://ci.ender.zone/plugin/repository/everything' }
maven { name 'aikar'; url 'https://repo.aikar.co/content/groups/aikar/' }
}
dependencies {
// spigot dependencies
compileOnly "org.spigotmc:spigot-api:$minecraftVersion-R0.1-SNAPSHOT"
compileOnly files(spigotNmsPath)
// Nyaa plugins
if (gradle.hasProperty("useLocalDependencies") && gradle.useLocalDependencies) {
compileOnly project(":NyaaCore")
compileOnly project(":LockettePro")
} else {
compileOnly "cat.nyaa:nyaacore:${majorVersion}.${minorVersion}-SNAPSHOT"
compileOnly "me.crafter.mc:lockettepro:2.9-SNAPSHOT"
}
// Other plugins
compileOnly('net.ess3:EssentialsX:2.18.0') { transitive = false }
compileOnly ('com.sk89q.worldedit:worldedit-bukkit:7.1.0-SNAPSHOT') {
exclude group: 'io.papermc', module: 'paperlib'
exclude group: 'org.bstats.bStats-Metrics', module: 'bstats-bukkit'
exclude group: 'org.bukkit', module: 'bukkit'
exclude group: 'com.destroystokyo.paper', module: 'paper-api'
}
}
// source file modification (modify version string)
processResources {
filesMatching("**/plugin.yml") {
expand 'version': project.version
}
}
// source file jar
task sourcesJar(type: Jar) {
archiveClassifier.set("sources")
from sourceSets.main.allSource
}
// javadoc generation options
javadoc {
// javadoc output folder
if (project.jdDirectory != null) destinationDir = file("${jdDirectory}/${pluginNameLower}-${version}")
(options as StandardJavadocDocletOptions).with {
links 'https://docs.oracle.com/en/java/javase/16/docs/api/'
links 'https://hub.spigotmc.org/javadocs/spigot/'
links 'https://google.github.io/guava/releases/21.0/api/docs/'
links 'https://ci.md-5.net/job/BungeeCord/ws/chat/target/apidocs/'
locale 'en_US'
encoding 'UTF-8'
docEncoding 'UTF-8'
addBooleanOption('keywords', true)
addStringOption('Xdoclint:none', '-quiet')
addBooleanOption('html5', true)
windowTitle = "${pluginNameUpper} Javadoc"
docTitle = "${pluginNameUpper} (mc$minecraftVersion-${project.version})"
}
}
// javadoc jar
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set("javadoc")
from javadoc.destinationDir
}
// compile options
compileJava {
options.compilerArgs += ["-Xlint:deprecation"]
}
// maven publish
publishing {
publications {
mavenJava(MavenPublication) {
group project.group
artifactId pluginNameLower
version "$majorVersion.$minorVersion-SNAPSHOT"
from components.java
artifact sourcesJar
artifact javadocJar
}
}
repositories {
maven {
url mavenDirectory
}
}
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}