Skip to content

Commit

Permalink
Release 0.7.3
Browse files Browse the repository at this point in the history
PR #439

Co-authored-by: Leonid Startsev <sandwwraith@users.noreply.github.com>
  • Loading branch information
shanshin and sandwwraith committed Jul 27, 2023
1 parent a74f3ba commit 0855c64
Show file tree
Hide file tree
Showing 18 changed files with 140 additions and 113 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,19 @@
0.7.3 / 2023-07-26
===================
## Kover Gradle Plugin
### Features
* Added ability to specify verification rules in the root of reports config
* [`#423`](https://github.com/Kotlin/kotlinx-kover/issues/423) Implemented task of generating binary report

### Bugfixes
* [`#405`](https://github.com/Kotlin/kotlinx-kover/issues/405) Fixed lookup for tests if unit tests are disabled in Android config
* [`#415`](https://github.com/Kotlin/kotlinx-kover/issues/415) Fixed usage of Kover Gradle Plugin in buildSrc directory
* [`#431`](https://github.com/Kotlin/kotlinx-kover/issues/431) Fixed excluding of companion object by annotation from report

## Kover Offline
### Features
* Added API for getting coverage inside a running application, instrumented offline

0.7.2 / 2023-06-26
===================
### Features
Expand Down
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -36,7 +36,7 @@ Add the following to your top-level build file:

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

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

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

Expand All @@ -88,7 +88,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'org.jetbrains.kotlinx:kover-gradle-plugin:0.7.2'
classpath 'org.jetbrains.kotlinx:kover-gradle-plugin:0.7.3'
}
}
Expand Down
99 changes: 99 additions & 0 deletions build.gradle.kts
Expand Up @@ -14,8 +14,107 @@
* limitations under the License.
*/

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

plugins {
kotlin("jvm") apply false
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)
}

6 changes: 3 additions & 3 deletions docs/gradle-plugin/index.md
Expand Up @@ -44,7 +44,7 @@ Add the following to your top-level build file:

```kotlin
plugins {
id("org.jetbrains.kotlinx.kover") version "0.7.2"
id("org.jetbrains.kotlinx.kover") version "0.7.3"
}
```

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

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

Expand All @@ -78,7 +78,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'org.jetbrains.kotlinx:kover-gradle-plugin:0.7.2'
classpath 'org.jetbrains.kotlinx:kover-gradle-plugin:0.7.3'
}
}
Expand Down
6 changes: 3 additions & 3 deletions docs/gradle-plugin/migrations/migration-to-0.7.0.md
@@ -1,7 +1,7 @@
# Kover migration guide from 0.6.x to 0.7.2
# Kover migration guide from 0.6.x to 0.7.3

## Migration steps
To migrate to version `0.7.2`, you must follow all steps below if they are applicable to your project.
To migrate to version `0.7.3`, you must follow all steps below if they are applicable to your project.

### Merge reports config was removed
Now all Kotlin report tasks (`koverHtmlReport`, `koverXmlReport`, `koverVerify`) are in single copy, they can be both single-project or merged cross-projects reports.
Expand Down Expand Up @@ -612,7 +612,7 @@ kover {

---

### Could not find org.jetbrains.kotlinx:kover:0.7.2
### Could not find org.jetbrains.kotlinx:kover:0.7.3
_Solution_

rename dependencies in _buildSrc_ from `org.jetbrains.kotlinx:kover:` to `org.jetbrains.kotlinx:kover-gradle-plugin:`
Expand Down
4 changes: 2 additions & 2 deletions docs/offline-instrumentation/index.md
Expand Up @@ -62,8 +62,8 @@ configurations.register("koverCli") {
}
dependencies {
runtimeOnly("org.jetbrains.kotlinx:kover-offline-runtime:0.7.2")
add("koverCli", "org.jetbrains.kotlinx:kover-cli:0.7.2")
runtimeOnly("org.jetbrains.kotlinx:kover-offline-runtime:0.7.3")
add("koverCli", "org.jetbrains.kotlinx:kover-cli:0.7.3")
testImplementation(kotlin("test"))
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
@@ -1,6 +1,6 @@
version=0.7.3-SNAPSHOT
version=0.8.0-SNAPSHOT
group=org.jetbrains.kotlinx

# version of the latest release
kover.release.version=0.7.2
kover.release.version=0.7.3
kotlin.code.style=official
88 changes: 0 additions & 88 deletions kover-gradle-plugin/build.gradle.kts
@@ -1,7 +1,5 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import java.time.LocalDate
import java.time.format.DateTimeFormatter
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

Expand Down Expand Up @@ -189,89 +187,3 @@ gradlePlugin {
}
}
}


// ====================
// 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 dir = layout.projectDirectory
val rootDir = rootProject.layout.projectDirectory

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

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

// replace versions in examples
dir.dir("examples").asFileTree.matching {
include("**/*gradle")
include("**/*gradle.kts")
}.files.forEach {
it.replaceInFile(prevReleaseVersion, releaseVersion)
}

// replace versions in docs
rootDir.dir("docs").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)
}
Expand Up @@ -2,5 +2,5 @@ plugins {
id("com.android.application") version "7.4.0" apply false
id("com.android.library") version "7.4.0" apply false
id("org.jetbrains.kotlin.android") version "1.8.20" apply false
id("org.jetbrains.kotlinx.kover") version "0.7.2" apply false
id("org.jetbrains.kotlinx.kover") version "0.7.3" apply false
}
Expand Up @@ -2,5 +2,5 @@ plugins {
id 'com.android.application' version '7.4.0' apply false
id 'com.android.library' version '7.4.0' apply false
id 'org.jetbrains.kotlin.android' version '1.8.20' apply false
id 'org.jetbrains.kotlinx.kover' version '0.7.2' apply false
id 'org.jetbrains.kotlinx.kover' version '0.7.3' apply false
}
Expand Up @@ -2,5 +2,5 @@ plugins {
id("com.android.application") version "7.4.0" apply false
id("com.android.library") version "7.4.0" apply false
id("org.jetbrains.kotlin.android") version "1.8.20" apply false
id("org.jetbrains.kotlinx.kover") version "0.7.2" apply false
id("org.jetbrains.kotlinx.kover") version "0.7.3" apply false
}
Expand Up @@ -2,7 +2,7 @@ plugins {
id("com.android.application") version "7.4.0" apply false
id("com.android.library") version "7.4.0" apply false
kotlin("multiplatform") version ("1.8.20") apply false
id("org.jetbrains.kotlinx.kover") version "0.7.2"
id("org.jetbrains.kotlinx.kover") version "0.7.3"
}

dependencies {
Expand Down
Expand Up @@ -2,5 +2,5 @@ plugins {
id("com.android.application") version "7.4.0" apply false
id("com.android.library") version "7.4.0" apply false
id("org.jetbrains.kotlin.android") version "1.8.20" apply false
id("org.jetbrains.kotlinx.kover") version "0.7.2" apply false
id("org.jetbrains.kotlinx.kover") version "0.7.3" apply false
}
Expand Up @@ -2,5 +2,5 @@ plugins {
id("com.android.application") version "7.4.0" apply false
id("com.android.library") version "7.4.0" apply false
id("org.jetbrains.kotlin.android") version "1.8.20" apply false
id("org.jetbrains.kotlinx.kover") version "0.7.2" apply false
id("org.jetbrains.kotlinx.kover") version "0.7.3" apply false
}
2 changes: 1 addition & 1 deletion kover-gradle-plugin/examples/jvm/defaults/build.gradle.kts
@@ -1,6 +1,6 @@
plugins {
kotlin("jvm") version "1.7.10"
id("org.jetbrains.kotlinx.kover") version "0.7.2"
id("org.jetbrains.kotlinx.kover") version "0.7.3"
}

repositories {
Expand Down
2 changes: 1 addition & 1 deletion kover-gradle-plugin/examples/jvm/merged/build.gradle.kts
@@ -1,6 +1,6 @@
plugins {
kotlin("jvm") version "1.7.10"
id("org.jetbrains.kotlinx.kover") version "0.7.2"
id("org.jetbrains.kotlinx.kover") version "0.7.3"
}

repositories {
Expand Down
2 changes: 1 addition & 1 deletion kover-gradle-plugin/examples/jvm/minimal/build.gradle.kts
@@ -1,6 +1,6 @@
plugins {
kotlin("jvm") version "1.7.10"
id("org.jetbrains.kotlinx.kover") version "0.7.2"
id("org.jetbrains.kotlinx.kover") version "0.7.3"
}

repositories {
Expand Down

0 comments on commit 0855c64

Please sign in to comment.