-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.gradle.kts
120 lines (97 loc) · 3.35 KB
/
build.gradle.kts
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
plugins {
id("java-library")
id("maven-publish")
id("com.diffplug.spotless") version "6.12.1"
id("pmd")
id("io.freefair.lombok") version "6.6.1"
}
description = "darkbot-common"
tasks.wrapper {
gradleVersion = "7.5.1"
// without gradle javadocs and sources
distributionType = Wrapper.DistributionType.BIN
}
dependencies {
api(project(":darkbot-util"))
api(project(":darkbot-api"))
api(project(":darkbot-shared"))
}
val apiVersion = "0.9.7"
allprojects {
group = "eu.darkbot"
version = apiVersion
apply(plugin = "java-library")
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
withSourcesJar()
withJavadocJar()
}
apply(plugin = "com.diffplug.spotless")
spotless {
format("misc") {
// define the files to apply `misc` to
target("*.gradle", "*.md", ".gitignore")
// define the steps to apply to those files
trimTrailingWhitespace()
indentWithTabs() // or spaces. Takes an integer argument if you don't like 4
endWithNewline()
}
java {
importOrder("", "javax|java", "\\#")
removeUnusedImports()
formatAnnotations()
indentWithSpaces(4)
trimTrailingWhitespace()
endWithNewline()
toggleOffOn()
custom("noWildcardImports") {str ->
for (line in str.split("\n").drop(1)) {
// No longer reading imports, break early
if (!line.startsWith("import") && line.isNotBlank()) break
if (!line.startsWith("import static") // Static imports allow wildcards
&& !line.contains(Regex(" javax?.(awt|swing).")) // awt/swing allow wildcards
&& line.endsWith(".*;")) { // Prevent any other wildcard
throw Exception("No wildcard imports allowed")
}
}
str;
}
}
}
apply(plugin="pmd")
pmd {
isConsoleOutput = true
rulesMinimumPriority.set(5)
ruleSets = listOf() // Remove built-in, we define our own
ruleSetFiles = files(rootDir.path + "/config/pmd/pmd-rules.xml")
}
apply(plugin="io.freefair.lombok")
apply(plugin = "maven-publish")
publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
}
}
}
dependencies {
compileOnly("org.jetbrains:annotations:23.1.0")
testCompileOnly("org.jetbrains:annotations:23.1.0")
compileOnly("com.google.code.gson:gson:2.10.1")
testImplementation("com.google.code.gson:gson:2.10.1")
testImplementation("org.junit.jupiter:junit-jupiter:5.9.2")
testImplementation("org.mockito:mockito-core:4.11.0")
}
tasks.test {
useJUnitPlatform()
}
val javadocOpts = tasks.javadoc.get().options as StandardJavadocDocletOptions
javadocOpts.addStringOption("Xdoclint:none", "-quiet") // no warnings about missing docs
tasks.withType(JavaCompile::class) {
options.isDeprecation = false // disable deprecation warnings
}
tasks.withType(PublishToMavenLocal::class) {
dependsOn("check")
}
}