forked from pdinklag/MinecraftStats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
174 lines (148 loc) · 4.22 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
plugins {
id 'application'
id 'java'
id 'org.gradlewebtools.minify' version '1.3.2'
}
application {
mainClass = 'de.pdinklag.mcstats.cli.MinecraftStatsCLI'
}
repositories {
mavenCentral()
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url 'https://oss.sonatype.org/content/repositories/central' }
maven { url 'https://repo.codemc.org/repository/maven-releases' }
}
dependencies {
implementation 'org.json:json:20220924'
compileOnly 'org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT'
compileOnly 'net.skinsrestorer:skinsrestorer-api:14.2.10'
}
task concatJs {
inputs.files(
'www/js/dev/mcstats.js',
'www/js/dev/mcstats-localization.js',
'www/js/dev/mcstats-widgets.js',
'www/js/dev/mcstats-awardlist.js',
'www/js/dev/mcstats-awardview.js',
'www/js/dev/mcstats-eventlist.js',
'www/js/dev/mcstats-eventview.js',
'www/js/dev/mcstats-playerlist.js',
'www/js/dev/mcstats-playerview.js',
'www/js/dev/mcstats-hof.js',
'www/js/dev/mcstats-loader.js',
'www/js/dev/mcstats-start.js')
outputs.file("build/js/mcstats.js" )
doLast {
outputs.files.singleFile.withOutputStream { out ->
for (file in inputs.files) file.withInputStream { out << it << '\n' }
}
}
}
task minifyJs(type: org.gradlewebtools.minify.JsMinifyTask) {
dependsOn concatJs
srcDir = project.file('build/js')
dstDir = project.file('build/www/js')
options.createSourceMaps = true
options.emitUseStrict = false
}
task minifyCss(type: org.gradlewebtools.minify.CssMinifyTask) {
srcDir = project.file('www/css')
dstDir = project.file('build/www')
}
task copyWww(type: Copy) {
dependsOn minifyJs
dependsOn minifyCss
from('www') {
include 'index.html'
include 'font/*.woff2'
include 'img/**/*.gif'
include 'img/**/*.png'
include 'js/lib/**'
include 'localization/*.json'
}
into 'build/www'
}
compileJava {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
def cliBaseName = 'MinecraftStatsCLI'
def pluginBaseName = 'MinecraftStats'
def libsDir = 'build/libs'
def releaseDir = 'build/release'
def resourcesDir = 'build/resources'
def cliResources = "${resourcesDir}/cli"
def pluginResources = "${resourcesDir}/plugin"
def version = project.file('version.txt').text
task resourcesCli (type: Copy) {
from('.') {
include 'version.txt'
}
into cliResources
}
task jarCli (type: Jar) {
archiveBaseName = cliBaseName
dependsOn resourcesCli
dependsOn compileJava
manifest {
attributes(
'Main-Class': application.mainClass
)
}
from sourceSets.main.runtimeClasspath.collect { it.getName().endsWith('.jar') ? zipTree(it) : it }
exclude 'de/pdinklag/mcstats/bukkit'
from cliResources
}
task resourcesPlugin (type: Copy) {
from('config/plugin') {
include '*.yml'
}
into pluginResources
filter { line -> line.replaceAll('@@MCSTATS_VERSION@@', version) }
}
task jarPlugin (type: Jar) {
archiveBaseName = pluginBaseName
dependsOn resourcesPlugin
dependsOn copyWww
dependsOn compileJava
from('build') {
include 'www/**/*'
}
from sourceSets.main.runtimeClasspath.collect { it.getName().endsWith('.jar') ? zipTree(it) : it }
exclude 'de/pdinklag/mcstats/cli'
from pluginResources
from('.') {
include 'stats/**/*.json'
}
}
task releaseCli (type: Zip) {
dependsOn jarCli
from(libsDir) {
include "${cliBaseName}.jar"
}
from 'config/cli'
from('.') {
include 'stats/**/*.json'
}
archiveBaseName = cliBaseName
destinationDirectory = file(releaseDir)
}
task releasePlugin (type: Copy) {
dependsOn jarPlugin
from(libsDir) {
include "${pluginBaseName}.jar"
}
into releaseDir
}
task releaseWeb (type: Zip) {
dependsOn copyWww
from 'build/www/'
archiveBaseName = 'MinecraftStatsWeb'
destinationDirectory = file(releaseDir)
}
task release {
dependsOn releaseCli
dependsOn releasePlugin
dependsOn releaseWeb
}