-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle.kts
149 lines (126 loc) · 4.87 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript {
// needs to be defined in here because otherwise tutteli-publish plugin does not have this information when applied
rootProject.group = "ch.tutteli.niok"
rootProject.version = "1.6.0-SNAPSHOT"
rootProject.description = "API for java.nio.file in a Kotlin idiomatic way"
}
plugins {
kotlin("jvm") version "2.0.21"
id("org.jetbrains.dokka") version "1.9.20"
val tutteliGradleVersion = "5.0.3"
id("ch.tutteli.gradle.plugins.dokka") version tutteliGradleVersion
id("ch.tutteli.gradle.plugins.kotlin.module.info") version tutteliGradleVersion
id("ch.tutteli.gradle.plugins.publish") version tutteliGradleVersion
id("ch.tutteli.gradle.plugins.spek") version tutteliGradleVersion
id("io.gitlab.arturbosch.detekt") version "1.23.7"
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
}
repositories {
mavenCentral()
}
val jdkDefaultVersion = "11"
kotlin {
// reading JAVA_VERSION from env to enable jdk17 build in CI
val jdkVersion = System.getenv("JAVA_VERSION")?.toIntOrNull() ?: jdkDefaultVersion.toInt()
jvmToolchain(jdkVersion)
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = jdkDefaultVersion
}
tasks.withType<JavaCompile> {
sourceCompatibility = jdkDefaultVersion
targetCompatibility = jdkDefaultVersion
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
apiVersion = "1.4"
languageVersion = "1.4"
}
}
dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("reflect"))
val excludeNiokAndKotlin: ExternalModuleDependency.() -> Unit = {
exclude(group = "ch.tutteli.niok")
exclude(group = "org.jetbrains.kotlin")
}
testImplementation("ch.tutteli.atrium:atrium-fluent:1.2.0", excludeNiokAndKotlin)
testImplementation("ch.tutteli.spek:tutteli-spek-extensions:1.2.1", excludeNiokAndKotlin)
}
detekt {
allRules = true
config.from(files("${rootProject.projectDir}/gradle/scripts/detekt.yml"))
}
tasks.withType<io.gitlab.arturbosch.detekt.Detekt> {
reports {
xml.required.set(true)
html.required.set(false)
sarif.required.set(false)
txt.required.set(false)
}
}
nexusPublishing {
repositories {
sonatype()
}
}
/*
Release & deploy a commit
--------------------------------
1. generate dokka
a) gr dokkaHtml
b) check if output/links are still good (use intellij's http server via -> right click -> open in -> browser)
2. update main:
Either use the following commands or the manual steps below
export NIOK_PREVIOUS_VERSION=1.5.0
export NIOK_VERSION=1.6.0
find ./ -name "*.md" | xargs perl -0777 -i \
-pe "s@$NIOK_PREVIOUS_VERSION@$NIOK_VERSION@g;" \
-pe "s@tree/v1.5.0@tree/v$NIOK_VERSION@g;"
perl -0777 -i \
-pe "s@$NIOK_PREVIOUS_VERSION@$NIOK_VERSION@g;" \
-pe "s/rootProject.version = \"$NIOK_VERSION-SNAPSHOT\"/rootProject.version = \"$NIOK_VERSION\"/;" \
./build.gradle.kts
perl -0777 -i \
-pe "s@$NIOK_PREVIOUS_VERSION@$NIOK_VERSION@g;" \
-pe 's/(<!-- for main -->\n)\n([\S\s]*?)(\n<!-- for a specific release -->\n)<!--\n([\S\s]*?)-->\n(\n# Niok)/$1<!--\n$2-->$3\n$4\n$5/;' \
./README.md
git commit -a -m "v$NIOK_VERSION"
git tag "v$NIOK_VERSION"
alternatively the manual steps:
a) search for X.Y.Z-SNAPSHOT and replace with X.Y.Z
b) adjust badges in readme
c) commit (modified build.gradle and README.md)
3. prepare release on github
a) git tag vX.Y.Z
b) git push origin vX.Y.Z
3. deploy to maven central:
(assumes you have an alias named gr pointing to ./gradlew)
a) java -version 2>&1 | grep "version \"11" && CI=true gr clean publishToSonatype closeAndReleaseSonatypeStagingRepository
b) Log into https://oss.sonatype.org/#stagingRepositories
c) check if staging repo is ok
d) gr closeAndReleaseSonatypeStagingRepository (currently fails with `No staging repository with name sonatype created` needs to be done manually via Nexus gui)
4. create release on github
Prepare next dev cycle
-----------------------
export NIOK_VERSION=1.5.0
export NIOK_NEXT_VERSION=1.6.0
find ./ -name "*.md" | xargs perl -0777 -i \
-pe "s@tree/v$NIOK_VERSION@tree/v1.5.0@g;";
perl -0777 -i \
-pe "s/rootProject.version = \"$NIOK_VERSION\"/rootProject.version = \"$NIOK_NEXT_VERSION-SNAPSHOT\"/;" \
-pe "s/NIOK_VERSION=$NIOK_VERSION/NIOK_VERSION=$NIOK_NEXT_VERSION/;" \
./build.gradle.kts
perl -0777 -i \
-pe 's/(<!-- for main -->\n)<!--\n([\S\s]*?)-->(\n<!-- for a specific release -->)\n([\S\s]*?)\n(\n# Niok)/$1\n$2$3\n<!--$4-->\n$5/;' \
./README.md
git commit -a -m "prepare dev cycle of $NIOK_NEXT_VERSION"
alternatively the manual steps:
1. point to main
a) search for `tag=vX.Y.Z` and replace it with `branch=main`
b) search for `tree/vX.Y.Z` and replace it with `tree/master`
2. search for X.Y.Z and replace with X.Y.Z-SNAPSHOT
3. adjust badges in readme
4. commit & push changes
*/