-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle.kts
150 lines (129 loc) · 4.5 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
146
147
148
149
150
import java.util.Calendar
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("app.cash.licensee:licensee-gradle-plugin:1.7.0")
}
}
apply(plugin = "app.cash.licensee")
plugins {
kotlin("jvm")
kotlin("kapt")
id("org.jetbrains.kotlin.plugin.noarg")
id("maven-publish")
id("com.diffplug.spotless")
id("io.gitlab.arturbosch.detekt")
}
val vertxVersion: String by project
val kotlinVersion: String by project
val projectVersion: String by project
val jacksonVersion: String by project
val jupiterVersion: String by project
group = "plus.sourceplus"
version = project.properties["protocolVersion"] as String? ?: projectVersion
repositories {
mavenCentral()
}
configure<app.cash.licensee.LicenseeExtension> {
allow("Apache-2.0")
allow("MIT")
}
val sourcesJar = tasks.register<Jar>("sourcesJar") {
archiveClassifier.set("sources")
from(project.the<SourceSetContainer>()["main"].allSource)
}
configure<PublishingExtension> {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/sourceplusplus/protocol")
credentials {
username = System.getenv("GH_PUBLISH_USERNAME")?.toString()
password = System.getenv("GH_PUBLISH_TOKEN")?.toString()
}
}
}
publishing {
publications {
create<MavenPublication>("maven") {
groupId = project.group.toString()
artifactId = "protocol"
version = project.version.toString()
from(components["kotlin"])
// Ship the sources jar
artifact(sourcesJar)
}
}
}
}
dependencies {
implementation("io.vertx:vertx-core:$vertxVersion")
implementation("io.vertx:vertx-codegen:$vertxVersion")
implementation("io.vertx:vertx-tcp-eventbus-bridge:$vertxVersion")
implementation("io.vertx:vertx-service-proxy:$vertxVersion")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:$jacksonVersion")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-guava:$jacksonVersion")
implementation("com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion")
testImplementation("org.junit.jupiter:junit-jupiter-engine:$jupiterVersion")
testImplementation("io.vertx:vertx-junit5:$vertxVersion")
testImplementation("io.vertx:vertx-core:$vertxVersion")
kapt("io.vertx:vertx-codegen:$vertxVersion:processor")
compileOnly("io.vertx:vertx-codegen:$vertxVersion")
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.1")
}
tasks.withType<JavaCompile> {
options.release.set(8)
sourceCompatibility = "1.8"
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.freeCompilerArgs = listOf("-Xjvm-default=all")
}
tasks.getByName<Test>("test") {
useJUnitPlatform()
}
detekt {
parallel = true
buildUponDefaultConfig = true
config.setFrom(arrayOf(File(project.rootDir, "detekt.yml")))
}
spotless {
kotlin {
target("**/*.kt")
val startYear = 2022
val currentYear = Calendar.getInstance().get(Calendar.YEAR)
val copyrightYears = if (startYear == currentYear) {
"$startYear"
} else {
"$startYear-$currentYear"
}
val protocolProject = findProject(":protocol") ?: rootProject
val licenseHeader = Regex("( . Copyright [\\S\\s]+)")
.find(File(protocolProject.projectDir, "LICENSE").readText())!!
.value.lines().joinToString("\n") {
if (it.trim().isEmpty()) {
" *"
} else {
" * " + it.trim()
}
}
val formattedLicenseHeader = buildString {
append("/*\n")
append(
licenseHeader.replace(
"Copyright [yyyy] [name of copyright owner]",
"Source++, the continuous feedback platform for developers.\n" +
" * Copyright (C) $copyrightYears CodeBrig, Inc."
).replace(
"http://www.apache.org/licenses/LICENSE-2.0",
" http://www.apache.org/licenses/LICENSE-2.0"
)
)
append("/")
}
licenseHeader(formattedLicenseHeader)
}
}