-
Notifications
You must be signed in to change notification settings - Fork 80
/
build.gradle
160 lines (127 loc) · 4.33 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
plugins {
id 'org.jetbrains.kotlin.jvm' version '2.0.10'
id 'org.jetbrains.kotlin.plugin.serialization' version '2.0.10'
id 'net.mamoe.mirai-console' version '2.16.0'
}
apply plugin: "maven-publish"
apply plugin: "java"
group = 'xmmt.dituon'
version = '6.2'
repositories {
maven { url 'https://maven.aliyun.com/repository/public' }
mavenCentral()
}
dependencies {
compileOnly 'org.projectlombok:lombok:1.18.34'
annotationProcessor 'org.projectlombok:lombok:1.18.34'
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1'
implementation "com.madgag:animated-gif-lib:1.4"
implementation "net.coobird:thumbnailator:0.4.19"
implementation 'com.jhlabs:filters:2.0.235-1'
implementation "org.java-websocket:Java-WebSocket:1.5.3"
implementation "org.luaj:luaj-jse:3.0.1"
testImplementation "junit:junit:4.11"
testImplementation 'org.codehaus.groovy:groovy-json:3.0.18'
testCompileOnly 'org.projectlombok:lombok:1.18.34'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.34'
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
mirai { jvmTarget = JavaVersion.VERSION_11 }
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier.set("sources")
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
publishing {
publications {
mavenJava(MavenPublication) {
// useless for jitpack: groupId = GROUP
artifactId = "petpet-share"
// useless for jitpack: version = VERSION
from components.java
}
}
}
jar {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
manifest {
attributes 'Main-Class': 'moe.dituon.petpet.Main'
}
from {
(configurations.runtimeClasspath).collect {
it.isDirectory() ? it : zipTree(it)
}
}
}
task wsJar(type: Jar) {
group = 'build'
description = 'build jar, excluding the websocket lib & webui'
archiveClassifier.set("no-ws")
exclude '**/petpet/websocket/**'
exclude '**/org/java_websocket/**'
exclude '**/index.html'
manifest {
attributes 'Main-Class': 'moe.dituon.petpet.Main'
}
with jar
}
def dataPath = 'data/xmmt.dituon.petpet'
def fontsPathName = 'fonts'
task generateIndexJson {
def dataSubDirs = new File("$rootDir/$dataPath")
.listFiles({ file -> file.isDirectory() && file.name != fontsPathName } as FileFilter)
def dataTemplateNames = dataSubDirs.collect({ dir -> dir.getName() })
def fontsNames = new File("$rootDir/$dataPath/$fontsPathName")
.listFiles({ file -> file.isFile() } as FileFilter).collect({ file -> file.getName() })
def jsonData = [
version: Float.parseFloat(project.version),
dataList: dataTemplateNames,
fontList: fontsNames
]
new File("$rootDir/index.json").withWriter { writer ->
writer << new groovy.json.JsonBuilder(jsonData).toPrettyString()
}
def lengthIndex = dataSubDirs.collectEntries { dir ->
[
(dir.getName()): dir.listFiles({ file ->
file.isFile() && file.getName().endsWith(".png")
} as FileFilter)?.length ?: 0
]
}
def aliasIndex = [:]
def typeIndex = [:]
dataSubDirs.each { dir ->
if (dir.name != fontsPathName) {
def dataJsonFile = new File("$rootDir/$dataPath/${dir.name}/data.json")
if (dataJsonFile.exists()) {
def dataJson = new groovy.json.JsonSlurper().parse(dataJsonFile)
aliasIndex[dir.name] = dataJson.alias ?: []
typeIndex[dir.name] = dataJson.type ?: "Unknown"
} else {
aliasIndex[dir.name] = []
typeIndex[dir.name] = "Unknown"
}
}
}
def indexMapJsonData = new groovy.json.JsonBuilder([
length: lengthIndex,
alias: aliasIndex.collectEntries { key, value -> [(key): value] },
type: typeIndex.collectEntries { key, value -> [(key): value] }
]).toString()
new File("$rootDir/index.map.json").withWriter { writer ->
writer << indexMapJsonData
}
}
mirai {
excludeDependency("org.java-websocket", "Java-WebSocket")
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}