-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
118 lines (102 loc) · 3.12 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
plugins {
id 'java'
id 'java-library'
id 'maven-publish'
id 'application'
id 'com.github.johnrengelman.shadow' version '7.1.0'
}
group 'cc.sukazyo'
version VERSION
project.ext.archiveBaseName = 'System_iCee'
project.ext.artifactId = 'icee-core'
mainClassName = 'cc.sukazyo.icee.iCee'
repositories {
mavenCentral()
google()
maven { name '-ws'; url 'https://mvn.sukazyo.cc/releases' }
}
dependencies {
// 单元测试核心类库
testImplementation platform("org.junit:junit-bom:${junitJupiterVersion}")
testImplementation "org.junit.jupiter:junit-jupiter:${junitJupiterVersion}"
// javax.annotation.Nonnull&Nullable ..yes.
compileOnlyApi "com.github.spotbugs:spotbugs-annotations:${spotbugsVersion}"
// (好像没用了..?)
implementation "com.google.code.gson:gson:${gsonVersion}"
// 配置文件 hocon 解析类库
implementation "com.typesafe:config:${typesafeVersion}"
// log 核心类库
compileOnlyApi "org.apache.logging.log4j:log4j-api:${log4jVersion}"
implementation "org.apache.logging.log4j:log4j-core:${log4jVersion}"
// jar内资源文件读取
implementation "cc.sukazyo:resource-tools:${resToolsVersion}"
}
static String localMacAddress () {
try {
byte[] mac = NetworkInterface.getByInetAddress(InetAddress.getLocalHost()).getHardwareAddress()
StringBuilder ax = new StringBuilder('new byte[]{')
for (int i = 0; i < 6; i++) {
ax.append(mac[i])
if (i != 5) ax.append(',')
}
ax.append('}')
return ax.toString()
} catch (Exception ignored) {
return "null"
}
}
task updateGradleConfigurations {
ant.replaceregexp(match:'VERSION = ["a-zA-Z0-9.\\-_+@]+;', replace:"VERSION = \"$project.version\";", flags:'g', byline:true) {
fileset(dir: 'src/main/java/cc/sukazyo/icee', includes: 'GradleProjectConfigurations.java')
}
ant.replaceregexp(match:'COMPILE_TIMESTAMP = [0-9]+L;', replace:"COMPILE_TIMESTAMP = ${System.currentTimeMillis()}L;", flags:'g', byline:true) {
fileset(dir: 'src/main/java/cc/sukazyo/icee', includes: 'GradleProjectConfigurations.java')
}
ant.replaceregexp(match:'COMPILER_MAC_ADDRESS = [a-zA-Z0-9\\[\\]{},. ]+;', replace:"COMPILER_MAC_ADDRESS = ${localMacAddress()};", flags:'g', byline:true) {
fileset(dir: 'src/main/java/cc/sukazyo/icee', includes: 'GradleProjectConfigurations.java')
} // new byte[]{0,0,0,0,0,0};
}
compileJava.dependsOn updateGradleConfigurations
java {
withSourcesJar()
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
tasks.withType(Javadoc) {
options.encoding = 'UTF-8'
options.docEncoding = 'UTF-8'
options.charSet = 'UTF-8'
}
tasks.test {
useJUnitPlatform()
}
shadowJar {
archiveBaseName.set("${project.ext.archiveBaseName}")
archiveVersion.set("${VERSION}")
archiveClassifier.set("fat")
}
publishing {
repositories{
maven {
name 'builds'
url = "file://" + new File("./build/publishing").getAbsolutePath()
}
maven {
name '-ws-'
url publishMvnRepoUrl
credentials {
username publishMvnRepoUsername
password publishMvnRepoPassword
}
}
}
publications {
main (MavenPublication) {
from components.java
groupId = project.group
artifactId = project.ext.artifactId
version = project.version
}
}
}