Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.8.1 #627

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
0.8.1 / 2024-06-07
===================
## Kover Gradle Plugin

### Features
* [`#600`](https://github.com/Kotlin/kotlinx-kover/issues/600) Apply recommendations for improving DSL
* Added DSL to copy one report variant
sandwwraith marked this conversation as resolved.
Show resolved Hide resolved

### Bugfixes
* [`#610`](https://github.com/Kotlin/kotlinx-kover/issues/610) Fixed `KoverCriticalException` with a certain order of applying of plugins

0.8.0 / 2024-05-15
===================
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.
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Add the following to your top-level build file:

```kotlin
plugins {
id("org.jetbrains.kotlinx.kover") version "0.8.0"
id("org.jetbrains.kotlinx.kover") version "0.8.1"
}
```
</details>
Expand All @@ -47,7 +47,7 @@ plugins {

```groovy
plugins {
id 'org.jetbrains.kotlinx.kover' version '0.8.0'
id 'org.jetbrains.kotlinx.kover' version '0.8.1'
}
```
</details>
Expand All @@ -72,7 +72,7 @@ buildscript {
}

dependencies {
classpath("org.jetbrains.kotlinx:kover-gradle-plugin:0.8.0")
classpath("org.jetbrains.kotlinx:kover-gradle-plugin:0.8.1")
}
}

Expand All @@ -91,7 +91,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'org.jetbrains.kotlinx:kover-gradle-plugin:0.8.0'
classpath 'org.jetbrains.kotlinx:kover-gradle-plugin:0.8.1'
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

import java.time.LocalDate
import java.time.format.DateTimeFormatter

// ====================
// Release preparation
// ====================
tasks.register("prepareRelease") {
doLast {
if (!project.hasProperty("releaseVersion")) {
throw GradleException("Property 'releaseVersion' is required to run this task")
}
val releaseVersion = project.property("releaseVersion") as String
val prevReleaseVersion = project.property("kover.release.version") as String

val projectDir = layout.projectDirectory

if (project.path == Project.PATH_SEPARATOR) {
projectDir.file("gradle.properties").asFile.patchProperties(releaseVersion)
projectDir.file("CHANGELOG.md").asFile.patchChangeLog(releaseVersion)

projectDir.file("README.md").asFile.replaceInFile(prevReleaseVersion, releaseVersion)
} else {
// replace versions in examples
projectDir.dir("examples").patchExamples(releaseVersion, prevReleaseVersion)

// replace versions in docs
projectDir.dir("docs").patchDocs(releaseVersion, prevReleaseVersion)
}


}
}

fun Directory.patchExamples(releaseVersion: String, prevReleaseVersion: String) {
asFileTree.matching {
include("**/*gradle")
include("**/*gradle.kts")
}.files.forEach {
it.replaceInFile(prevReleaseVersion, releaseVersion)
}
}

fun Directory.patchDocs(releaseVersion: String, prevReleaseVersion: String) {
asFileTree.files.forEach {
it.replaceInFile(prevReleaseVersion, releaseVersion)
}
}

fun File.patchChangeLog(releaseVersion: String) {
val oldContent = readText()
writer().use {
it.appendLine("$releaseVersion / ${LocalDate.now().format(DateTimeFormatter.ISO_DATE)}")
it.appendLine("===================")
it.appendLine("TODO add changelog!")
it.appendLine()
it.append(oldContent)
}
}

fun File.patchProperties(releaseVersion: String) {
val oldLines = readLines()
writer().use { writer ->
oldLines.forEach { line ->
when {
line.startsWith("version=") -> writer.append("version=")
.appendLine(increaseSnapshotVersion(releaseVersion))

line.startsWith("kover.release.version=") -> writer.append("kover.release.version=")
.appendLine(releaseVersion)

else -> writer.appendLine(line)
}
}
}
}

// modify version '1.2.3' to '1.2.4' and '1.2.3-Beta' to '1.2.3-SNAPSHOT'
fun increaseSnapshotVersion(releaseVersion: String): String {
// remove postfix like '-Alpha'
val correctedVersion = releaseVersion.substringBefore('-')
if (correctedVersion != releaseVersion) {
return "$correctedVersion-SNAPSHOT"
}

// split version 0.0.0 to int parts
val parts = correctedVersion.split('.')
val newVersion = parts.mapIndexed { index, value ->
if (index == parts.size - 1) {
(value.toInt() + 1).toString()
} else {
value
}
}.joinToString(".")

return "$newVersion-SNAPSHOT"
}

fun File.replaceInFile(old: String, new: String) {
if (name.endsWith(".png")) return
sandwwraith marked this conversation as resolved.
Show resolved Hide resolved

val newContent = readText().replace(old, new)
writeText(newContent)
}

99 changes: 1 addition & 98 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,107 +14,10 @@
* limitations under the License.
*/

import java.time.LocalDate
import java.time.format.DateTimeFormatter

plugins {
kotlin("jvm") apply false
id("kover-release-conventions")
alias(libs.plugins.kotlinx.dokka) apply false
alias(libs.plugins.kotlinx.binaryCompatibilityValidator) apply false
}



// ====================
// Release preparation
// ====================
tasks.register("prepareRelease") {

doLast {
if (!project.hasProperty("releaseVersion")) {
throw GradleException("Property 'releaseVersion' is required to run this task")
}
val releaseVersion = project.property("releaseVersion") as String
val prevReleaseVersion = project.property("kover.release.version") as String

val projectDir = layout.projectDirectory

projectDir.file("gradle.properties").asFile.patchProperties(releaseVersion)
projectDir.file("CHANGELOG.md").asFile.patchChangeLog(releaseVersion)

projectDir.file("README.md").asFile.replaceInFile(prevReleaseVersion, releaseVersion)

// replace versions in examples
projectDir.dir("kover-gradle-plugin").dir("examples").patchExamples(releaseVersion, prevReleaseVersion)
projectDir.dir("kover-offline-runtime").dir("examples").patchExamples(releaseVersion, prevReleaseVersion)

// replace versions in docs
projectDir.dir("docs").patchDocs(releaseVersion, prevReleaseVersion)
}
}

fun Directory.patchExamples(releaseVersion: String, prevReleaseVersion: String) {
asFileTree.matching {
include("**/*gradle")
include("**/*gradle.kts")
}.files.forEach {
it.replaceInFile(prevReleaseVersion, releaseVersion)
}
}

fun Directory.patchDocs(releaseVersion: String, prevReleaseVersion: String) {
asFileTree.files.forEach {
it.replaceInFile(prevReleaseVersion, releaseVersion)
}
}

fun File.patchChangeLog(releaseVersion: String) {
val oldContent = readText()
writer().use {
it.appendLine("$releaseVersion / ${LocalDate.now().format(DateTimeFormatter.ISO_DATE)}")
it.appendLine("===================")
it.appendLine("TODO add changelog!")
it.appendLine()
it.append(oldContent)
}
}

fun File.patchProperties(releaseVersion: String) {
val oldLines = readLines()
writer().use { writer ->
oldLines.forEach { line ->
when {
line.startsWith("version=") -> writer.append("version=").appendLine(increaseSnapshotVersion(releaseVersion))
line.startsWith("kover.release.version=") -> writer.append("kover.release.version=").appendLine(releaseVersion)
else -> writer.appendLine(line)
}
}
}
}

// modify version '1.2.3' to '1.2.4' and '1.2.3-Beta' to '1.2.3-SNAPSHOT'
fun increaseSnapshotVersion(releaseVersion: String): String {
// remove postfix like '-Alpha'
val correctedVersion = releaseVersion.substringBefore('-')
if (correctedVersion != releaseVersion) {
return "$correctedVersion-SNAPSHOT"
}

// split version 0.0.0 to int parts
val parts = correctedVersion.split('.')
val newVersion = parts.mapIndexed { index, value ->
if (index == parts.size - 1) {
(value.toInt() + 1).toString()
} else {
value
}
}.joinToString(".")

return "$newVersion-SNAPSHOT"
}

fun File.replaceInFile(old: String, new: String) {
val newContent = readText().replace(old, new)
writeText(newContent)
}

4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version=0.8.1-SNAPSHOT
version=0.8.2-SNAPSHOT
group=org.jetbrains.kotlinx

# version of the latest release
kover.release.version=0.8.0
kover.release.version=0.8.1
kotlin.code.style=official
1 change: 1 addition & 0 deletions kover-cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ plugins {
id("kover-publishing-conventions")
id("kover-docs-conventions")
id("kover-fat-jar-conventions")
id("kover-release-conventions")
sandwwraith marked this conversation as resolved.
Show resolved Hide resolved
}

extensions.configure<Kover_publishing_conventions_gradle.KoverPublicationExtension> {
Expand Down
1 change: 1 addition & 0 deletions kover-features-jvm/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ plugins {
kotlin("jvm")
alias(libs.plugins.kotlinx.binaryCompatibilityValidator)
id("kover-publishing-conventions")
id("kover-release-conventions")
}

extensions.configure<Kover_publishing_conventions_gradle.KoverPublicationExtension> {
Expand Down
1 change: 1 addition & 0 deletions kover-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ plugins {
alias(libs.plugins.gradle.pluginPublish)
id("kover-publishing-conventions")
id("kover-docs-conventions")
id("kover-release-conventions")
}

repositories {
Expand Down
16 changes: 8 additions & 8 deletions kover-gradle-plugin/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Add the following to your build file:

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

```kotlin
plugins {
id("org.jetbrains.kotlinx.kover") version "0.8.0"
id("org.jetbrains.kotlinx.kover") version "0.8.1"
}
```
It is recommended to apply the Kover Plugin in the root module, even if there is no source code or tests there.
Expand Down Expand Up @@ -225,7 +225,7 @@ Otherwise, the use of the plugin is identical to the use in the [multi-module Ko
Add the following to the build file only in the `app` module of your Gradle build:
```kotlin
plugins {
id("org.jetbrains.kotlinx.kover") version "0.8.0"
id("org.jetbrains.kotlinx.kover") version "0.8.1"
}
```

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

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

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

```kotlin
plugins {
id("org.jetbrains.kotlinx.kover") version "0.8.0"
id("org.jetbrains.kotlinx.kover") version "0.8.1"
}
```

Expand All @@ -777,7 +777,7 @@ buildscript {
}

dependencies {
classpath("org.jetbrains.kotlinx:kover-gradle-plugin:0.8.0")
classpath("org.jetbrains.kotlinx:kover-gradle-plugin:0.8.1")
}
}

Expand All @@ -793,7 +793,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'org.jetbrains.kotlinx:kover-gradle-plugin:0.8.0'
classpath 'org.jetbrains.kotlinx:kover-gradle-plugin:0.8.1'
}
}

Expand Down
Loading