Skip to content

Commit 44e2328

Browse files
authored
Release 0.8.1
PR #627
1 parent 0f5de01 commit 44e2328

File tree

27 files changed

+165
-138
lines changed

27 files changed

+165
-138
lines changed

Diff for: CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
0.8.1 / 2024-06-07
2+
===================
3+
## Kover Gradle Plugin
4+
5+
### Features
6+
* [`#600`](https://github.com/Kotlin/kotlinx-kover/issues/600) Apply recommendations for improving DSL
7+
* Added DSL to copy one report variant
8+
9+
### Bugfixes
10+
* [`#610`](https://github.com/Kotlin/kotlinx-kover/issues/610) Fixed `KoverCriticalException` with a certain order of applying of plugins
11+
112
0.8.0 / 2024-05-15
213
===================
314
This release introduces DSL rework to simplify the work with Android build variants, adds the possibility of lazy configuration, allows for the creation of custom report variants, and expands the ability of reports filtering.

Diff for: README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Add the following to your top-level build file:
3737

3838
```kotlin
3939
plugins {
40-
id("org.jetbrains.kotlinx.kover") version "0.8.0"
40+
id("org.jetbrains.kotlinx.kover") version "0.8.1"
4141
}
4242
```
4343
</details>
@@ -47,7 +47,7 @@ plugins {
4747

4848
```groovy
4949
plugins {
50-
id 'org.jetbrains.kotlinx.kover' version '0.8.0'
50+
id 'org.jetbrains.kotlinx.kover' version '0.8.1'
5151
}
5252
```
5353
</details>
@@ -72,7 +72,7 @@ buildscript {
7272
}
7373

7474
dependencies {
75-
classpath("org.jetbrains.kotlinx:kover-gradle-plugin:0.8.0")
75+
classpath("org.jetbrains.kotlinx:kover-gradle-plugin:0.8.1")
7676
}
7777
}
7878

@@ -91,7 +91,7 @@ buildscript {
9191
mavenCentral()
9292
}
9393
dependencies {
94-
classpath 'org.jetbrains.kotlinx:kover-gradle-plugin:0.8.0'
94+
classpath 'org.jetbrains.kotlinx:kover-gradle-plugin:0.8.1'
9595
}
9696
}
9797
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
* Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
import java.time.LocalDate
6+
import java.time.format.DateTimeFormatter
7+
8+
// ====================
9+
// Release preparation
10+
// ====================
11+
tasks.register("prepareRelease") {
12+
doLast {
13+
if (!project.hasProperty("releaseVersion")) {
14+
throw GradleException("Property 'releaseVersion' is required to run this task")
15+
}
16+
val releaseVersion = project.property("releaseVersion") as String
17+
val prevReleaseVersion = project.property("kover.release.version") as String
18+
19+
val projectDir = layout.projectDirectory
20+
21+
if (project.path == Project.PATH_SEPARATOR) {
22+
projectDir.file("gradle.properties").asFile.patchProperties(releaseVersion)
23+
projectDir.file("CHANGELOG.md").asFile.patchChangeLog(releaseVersion)
24+
25+
projectDir.file("README.md").asFile.replaceInFile(prevReleaseVersion, releaseVersion)
26+
} else {
27+
// replace versions in examples
28+
projectDir.dir("examples").patchExamples(releaseVersion, prevReleaseVersion)
29+
30+
// replace versions in docs
31+
projectDir.dir("docs").patchDocs(releaseVersion, prevReleaseVersion)
32+
}
33+
34+
35+
}
36+
}
37+
38+
fun Directory.patchExamples(releaseVersion: String, prevReleaseVersion: String) {
39+
asFileTree.matching {
40+
include("**/*gradle")
41+
include("**/*gradle.kts")
42+
}.files.forEach {
43+
it.replaceInFile(prevReleaseVersion, releaseVersion)
44+
}
45+
}
46+
47+
fun Directory.patchDocs(releaseVersion: String, prevReleaseVersion: String) {
48+
asFileTree.files.forEach {
49+
it.replaceInFile(prevReleaseVersion, releaseVersion)
50+
}
51+
}
52+
53+
fun File.patchChangeLog(releaseVersion: String) {
54+
val oldContent = readText()
55+
writer().use {
56+
it.appendLine("$releaseVersion / ${LocalDate.now().format(DateTimeFormatter.ISO_DATE)}")
57+
it.appendLine("===================")
58+
it.appendLine("TODO add changelog!")
59+
it.appendLine()
60+
it.append(oldContent)
61+
}
62+
}
63+
64+
fun File.patchProperties(releaseVersion: String) {
65+
val oldLines = readLines()
66+
writer().use { writer ->
67+
oldLines.forEach { line ->
68+
when {
69+
line.startsWith("version=") -> writer.append("version=")
70+
.appendLine(increaseSnapshotVersion(releaseVersion))
71+
72+
line.startsWith("kover.release.version=") -> writer.append("kover.release.version=")
73+
.appendLine(releaseVersion)
74+
75+
else -> writer.appendLine(line)
76+
}
77+
}
78+
}
79+
}
80+
81+
// modify version '1.2.3' to '1.2.4' and '1.2.3-Beta' to '1.2.3-SNAPSHOT'
82+
fun increaseSnapshotVersion(releaseVersion: String): String {
83+
// remove postfix like '-Alpha'
84+
val correctedVersion = releaseVersion.substringBefore('-')
85+
if (correctedVersion != releaseVersion) {
86+
return "$correctedVersion-SNAPSHOT"
87+
}
88+
89+
// split version 0.0.0 to int parts
90+
val parts = correctedVersion.split('.')
91+
val newVersion = parts.mapIndexed { index, value ->
92+
if (index == parts.size - 1) {
93+
(value.toInt() + 1).toString()
94+
} else {
95+
value
96+
}
97+
}.joinToString(".")
98+
99+
return "$newVersion-SNAPSHOT"
100+
}
101+
102+
fun File.replaceInFile(old: String, new: String) {
103+
if (name.endsWith(".png")) return
104+
105+
val newContent = readText().replace(old, new)
106+
writeText(newContent)
107+
}
108+

Diff for: build.gradle.kts

+1-98
Original file line numberDiff line numberDiff line change
@@ -14,107 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
import java.time.LocalDate
18-
import java.time.format.DateTimeFormatter
19-
2017
plugins {
2118
kotlin("jvm") apply false
19+
id("kover-release-conventions")
2220
alias(libs.plugins.kotlinx.dokka) apply false
2321
alias(libs.plugins.kotlinx.binaryCompatibilityValidator) apply false
2422
}
2523

26-
27-
28-
// ====================
29-
// Release preparation
30-
// ====================
31-
tasks.register("prepareRelease") {
32-
33-
doLast {
34-
if (!project.hasProperty("releaseVersion")) {
35-
throw GradleException("Property 'releaseVersion' is required to run this task")
36-
}
37-
val releaseVersion = project.property("releaseVersion") as String
38-
val prevReleaseVersion = project.property("kover.release.version") as String
39-
40-
val projectDir = layout.projectDirectory
41-
42-
projectDir.file("gradle.properties").asFile.patchProperties(releaseVersion)
43-
projectDir.file("CHANGELOG.md").asFile.patchChangeLog(releaseVersion)
44-
45-
projectDir.file("README.md").asFile.replaceInFile(prevReleaseVersion, releaseVersion)
46-
47-
// replace versions in examples
48-
projectDir.dir("kover-gradle-plugin").dir("examples").patchExamples(releaseVersion, prevReleaseVersion)
49-
projectDir.dir("kover-offline-runtime").dir("examples").patchExamples(releaseVersion, prevReleaseVersion)
50-
51-
// replace versions in docs
52-
projectDir.dir("docs").patchDocs(releaseVersion, prevReleaseVersion)
53-
}
54-
}
55-
56-
fun Directory.patchExamples(releaseVersion: String, prevReleaseVersion: String) {
57-
asFileTree.matching {
58-
include("**/*gradle")
59-
include("**/*gradle.kts")
60-
}.files.forEach {
61-
it.replaceInFile(prevReleaseVersion, releaseVersion)
62-
}
63-
}
64-
65-
fun Directory.patchDocs(releaseVersion: String, prevReleaseVersion: String) {
66-
asFileTree.files.forEach {
67-
it.replaceInFile(prevReleaseVersion, releaseVersion)
68-
}
69-
}
70-
71-
fun File.patchChangeLog(releaseVersion: String) {
72-
val oldContent = readText()
73-
writer().use {
74-
it.appendLine("$releaseVersion / ${LocalDate.now().format(DateTimeFormatter.ISO_DATE)}")
75-
it.appendLine("===================")
76-
it.appendLine("TODO add changelog!")
77-
it.appendLine()
78-
it.append(oldContent)
79-
}
80-
}
81-
82-
fun File.patchProperties(releaseVersion: String) {
83-
val oldLines = readLines()
84-
writer().use { writer ->
85-
oldLines.forEach { line ->
86-
when {
87-
line.startsWith("version=") -> writer.append("version=").appendLine(increaseSnapshotVersion(releaseVersion))
88-
line.startsWith("kover.release.version=") -> writer.append("kover.release.version=").appendLine(releaseVersion)
89-
else -> writer.appendLine(line)
90-
}
91-
}
92-
}
93-
}
94-
95-
// modify version '1.2.3' to '1.2.4' and '1.2.3-Beta' to '1.2.3-SNAPSHOT'
96-
fun increaseSnapshotVersion(releaseVersion: String): String {
97-
// remove postfix like '-Alpha'
98-
val correctedVersion = releaseVersion.substringBefore('-')
99-
if (correctedVersion != releaseVersion) {
100-
return "$correctedVersion-SNAPSHOT"
101-
}
102-
103-
// split version 0.0.0 to int parts
104-
val parts = correctedVersion.split('.')
105-
val newVersion = parts.mapIndexed { index, value ->
106-
if (index == parts.size - 1) {
107-
(value.toInt() + 1).toString()
108-
} else {
109-
value
110-
}
111-
}.joinToString(".")
112-
113-
return "$newVersion-SNAPSHOT"
114-
}
115-
116-
fun File.replaceInFile(old: String, new: String) {
117-
val newContent = readText().replace(old, new)
118-
writeText(newContent)
119-
}
120-

Diff for: gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
version=0.8.1-SNAPSHOT
1+
version=0.8.2-SNAPSHOT
22
group=org.jetbrains.kotlinx
33

44
# version of the latest release
5-
kover.release.version=0.8.0
5+
kover.release.version=0.8.1
66
kotlin.code.style=official

Diff for: kover-cli/build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ plugins {
2121
id("kover-publishing-conventions")
2222
id("kover-docs-conventions")
2323
id("kover-fat-jar-conventions")
24+
id("kover-release-conventions")
2425
}
2526

2627
extensions.configure<Kover_publishing_conventions_gradle.KoverPublicationExtension> {

Diff for: kover-features-jvm/build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ plugins {
2222
kotlin("jvm")
2323
alias(libs.plugins.kotlinx.binaryCompatibilityValidator)
2424
id("kover-publishing-conventions")
25+
id("kover-release-conventions")
2526
}
2627

2728
extensions.configure<Kover_publishing_conventions_gradle.KoverPublicationExtension> {

Diff for: kover-gradle-plugin/build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ plugins {
1414
alias(libs.plugins.gradle.pluginPublish)
1515
id("kover-publishing-conventions")
1616
id("kover-docs-conventions")
17+
id("kover-release-conventions")
1718
}
1819

1920
repositories {

Diff for: kover-gradle-plugin/docs/index.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Add the following to your build file:
5555

5656
```kotlin
5757
plugins {
58-
id("org.jetbrains.kotlinx.kover") version "0.8.0"
58+
id("org.jetbrains.kotlinx.kover") version "0.8.1"
5959
}
6060
```
6161
For more information about application of the plugin, refer to the [relevant section](#apply-kover-gradle-plugin-in-project)
@@ -127,7 +127,7 @@ Add the following line to build file in each module of your Gradle build:
127127

128128
```kotlin
129129
plugins {
130-
id("org.jetbrains.kotlinx.kover") version "0.8.0"
130+
id("org.jetbrains.kotlinx.kover") version "0.8.1"
131131
}
132132
```
133133
It is recommended to apply the Kover Plugin in the root module, even if there is no source code or tests there.
@@ -225,7 +225,7 @@ Otherwise, the use of the plugin is identical to the use in the [multi-module Ko
225225
Add the following to the build file only in the `app` module of your Gradle build:
226226
```kotlin
227227
plugins {
228-
id("org.jetbrains.kotlinx.kover") version "0.8.0"
228+
id("org.jetbrains.kotlinx.kover") version "0.8.1"
229229
}
230230
```
231231

@@ -378,7 +378,7 @@ Add the following to build file in each module of your Gradle build:
378378

379379
```kotlin
380380
plugins {
381-
id("org.jetbrains.kotlinx.kover") version "0.8.0"
381+
id("org.jetbrains.kotlinx.kover") version "0.8.1"
382382
}
383383
```
384384
It is recommended to apply the Kover Plugin in the root module, even if there is no source code or tests there.
@@ -582,7 +582,7 @@ Add the following to build file in each module of your Gradle build:
582582

583583
```kotlin
584584
plugins {
585-
id("org.jetbrains.kotlinx.kover") version "0.8.0"
585+
id("org.jetbrains.kotlinx.kover") version "0.8.1"
586586
}
587587
```
588588
It is recommended to apply the Kover Plugin in the root module, even if there is no source code or tests there.
@@ -759,7 +759,7 @@ Add the following to your build file:
759759

760760
```kotlin
761761
plugins {
762-
id("org.jetbrains.kotlinx.kover") version "0.8.0"
762+
id("org.jetbrains.kotlinx.kover") version "0.8.1"
763763
}
764764
```
765765

@@ -777,7 +777,7 @@ buildscript {
777777
}
778778

779779
dependencies {
780-
classpath("org.jetbrains.kotlinx:kover-gradle-plugin:0.8.0")
780+
classpath("org.jetbrains.kotlinx:kover-gradle-plugin:0.8.1")
781781
}
782782
}
783783

@@ -793,7 +793,7 @@ buildscript {
793793
mavenCentral()
794794
}
795795
dependencies {
796-
classpath 'org.jetbrains.kotlinx:kover-gradle-plugin:0.8.0'
796+
classpath 'org.jetbrains.kotlinx:kover-gradle-plugin:0.8.1'
797797
}
798798
}
799799

0 commit comments

Comments
 (0)