forked from GraxCode/threadtear
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
145 lines (129 loc) · 4.97 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
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
import com.github.vlsi.gradle.crlf.CrLfSpec
import com.github.vlsi.gradle.crlf.LineEndings
import com.github.vlsi.gradle.properties.dsl.props
plugins {
id("eclipse")
id("com.github.autostyle")
id("com.github.vlsi.crlf")
id("com.github.vlsi.gradle-extensions")
}
val skipAutostyle by props(true) // Remove true if formatting is configured.
val String.v: String get() = rootProject.extra["$this.version"] as String
val projectVersion = "threadtear".v
allprojects {
group = "me.nov.threadtear"
version = projectVersion
repositories {
mavenCentral()
maven {
url = uri("https://jitpack.io")
}
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
}
}
configurations {
all { resolutionStrategy.cacheChangingModulesFor(0, "seconds") }
}
if (!skipAutostyle) {
apply(plugin = "com.github.autostyle")
autostyle {
kotlinGradle {
ktlint()
}
format("markdown") {
filter.include("**/*.md")
endWithNewline()
}
}
}
tasks.withType<AbstractArchiveTask>().configureEach {
// Ensure builds are reproducible
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
dirMode = "775".toInt(8)
fileMode = "664".toInt(8)
}
plugins.withType<JavaLibraryPlugin> {
dependencies {
val bom = platform(project(":threadtear-dependencies-bom"))
"api"(bom)
}
}
plugins.withType<JavaPlugin> {
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
if (!skipAutostyle) {
autostyle {
java {
importOrder("java", "javax", "org", "com")
removeUnusedImports()
eclipse {
configFile("${project.rootDir}/threadtear.eclipseformat.xml")
}
}
}
}
tasks {
withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
}
withType<ProcessResources>().configureEach {
from(source) {
include("**/*.properties")
filteringCharset = "UTF-8"
// apply native2ascii conversion since Java 8 expects properties to have ascii symbols only
filter(org.apache.tools.ant.filters.EscapeUnicode::class)
}
}
withType<Javadoc>().configureEach {
(options as StandardJavadocDocletOptions).apply {
quiet()
locale = "en"
docEncoding = "UTF-8"
charSet = "UTF-8"
encoding = "UTF-8"
docTitle = "Threadtear ${project.name} API"
windowTitle = "Threadtear ${project.name} API"
header = "<b>Threadtear</b>"
addBooleanOption("Xdoclint:none", true)
addStringOption("source", "8")
if (JavaVersion.current().isJava9Compatible) {
addBooleanOption("html5", true)
links("https://docs.oracle.com/javase/9/docs/api/")
} else {
links("https://docs.oracle.com/javase/8/docs/api/")
}
}
}
withType<Jar>().configureEach {
manifest {
attributes["Bundle-License"] = "GPL-3.0"
attributes["Implementation-Title"] = project.name
attributes["Implementation-Version"] = project.version
attributes["Specification-Vendor"] = "Threadtear"
attributes["Specification-Version"] = project.version
attributes["Specification-Title"] = "Threadtear"
attributes["Implementation-Vendor"] = "Threadtear"
attributes["Implementation-Vendor-Id"] = project.group
}
CrLfSpec(LineEndings.LF).run {
into("META-INF") {
filteringCharset = "UTF-8"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
// This includes either project-specific license or a default one
if (file("$projectDir/LICENSE").exists()) {
textFrom("$projectDir/LICENSE")
rename { s -> "${project.name.toUpperCase()}_LICENSE" }
} else {
textFrom("$rootDir/LICENSE")
rename { s -> "${rootProject.name.toUpperCase()}_LICENSE" }
}
}
}
}
}
}
}