-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.gradle
136 lines (113 loc) · 4.13 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
import proguard.gradle.ProGuardTask
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.guardsquare:proguard-gradle:7.2.2'
}
}
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.0'
id 'java'
id "org.jetbrains.kotlin.jvm" version "1.5.31"
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
group = 'io.github.mdsimmo'
version = '0.8.3'
repositories {
mavenCentral()
maven {
// bukkits repo
url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
}
maven {
// world edit repo
url "https://maven.enginehub.org/repo"
}
maven {
// PlaceholderAPI
url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/'
}
maven {
name = "sonatype-oss-snapshots"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
url 'https://libraries.minecraft.net/'
}
}
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.31'
implementation "net.objecthunter:exp4j:0.4.8"
compileOnly "org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT"
testImplementation "org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT"
compileOnly "com.sk89q.worldedit:worldedit-bukkit:7.2.8"
testImplementation "com.sk89q.worldedit:worldedit-bukkit:7.2.8"
compileOnly 'me.clip:placeholderapi:2.11+'
testImplementation 'me.clip:placeholderapi:2.11+'
testImplementation "junit:junit:4.13.+"
testImplementation "org.mockito:mockito-core:3.3.+"
}
shadowJar {
relocate 'net.objecthunter', 'io.github.mdsimmo.bomberman.lib.net.objecthunter'
relocate 'kotlin', 'io.github.mdsimmo.bomberman.lib.kotlin'
relocate 'org.jetbrains', 'io.github.mdsimmo.bomberman.lib.org.jetbrains'
relocate 'org.intellij', 'io.github.mdsimmo.bomberman.lib.org.intellij'
}
processResources {
// auto assign values in the plugin.yml
filesMatching("plugin.yml") {
filter {
line -> line.replace('${version}', version)
}
}
}
task minify(type: ProGuardTask, dependsOn: shadowJar) {
injars shadowJar.outputs.files
outjars "build/libs/Bomberman-${version}-min.jar"
// Automatically handle the Java version of this build.
if (System.getProperty('java.version').startsWith('1.')) {
// Before Java 9, the runtime classes were packaged in a single jar file.
libraryjars "${System.getProperty('java.home')}/lib/rt.jar"
} else {
// As of Java 9, the runtime classes are packaged in modular jmod files.
libraryjars "${System.getProperty('java.home')}/jmods/java.base.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
libraryjars "${System.getProperty('java.home')}/jmods/java.logging.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
}
libraryjars files(configurations.compileOnly.collect())
// only remove unused library code (mostly kotlin)
keep(["includedescriptorclasses": true], "public class !io.github.mdsimmo.bomberman.lib.** { *; }")
// Don't rename anything
dontobfuscate
dontoptimize
}
task clearOldPluginJar( type: Delete ) {
description 'Deletes any old bomberman plugins from the server'
if ( project.hasProperty("serverLocation" ) ) {
delete project.fileTree( "$serverLocation/plugins/update" ) {
include '*omberman*.jar'
}
}
}
task copyToServer(type: Copy, dependsOn: [minify, clearOldPluginJar] ) {
description 'Copies the plugin to the server'
if ( project.hasProperty("serverLocation" ) ) {
from minify
into "$serverLocation/plugins/update"
logger.info("Installing to '$serverLocation/plugins/update'")
} else {
logger.warn("No server location defined")
}
}
task install( dependsOn: [minify, copyToServer] ) {
description 'Compiles, tests and copies the code to the server'
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
kotlinOptions {
jvmTarget = "1.8"
}
}