-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented Kover Features artifact to integration with Android Gradl…
…e Plugin 1. Created published Kover artifact kover-features-jvm 2. Added Java API for offline instrumentation of single class 3. Created kotlinx.kover.features.jvm.KoverLegacyFeatures and put the methods used by the Kover CLI there 4. Removed the dependency on intellij-coverage-reporter from the Kover CLI and add the dependency on kover-features-jvm Resolves #534 PR #536 Co-authored-by: Leonid Startsev <sandwwraith@users.noreply.github.com>
- Loading branch information
1 parent
ec84816
commit 5380bc9
Showing
17 changed files
with
387 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
- [Kover Gradle Plugin](gradle-plugin) | ||
- [Kover Command Line Interface](cli) | ||
- [Kover Command Line Interface](cli) | ||
- [Kover offline instrumentation](offline-instrumentation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2000-2024 JetBrains s.r.o. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
plugins { | ||
java | ||
id("kover-publishing-conventions") | ||
} | ||
|
||
extensions.configure<Kover_publishing_conventions_gradle.KoverPublicationExtension> { | ||
description.set("Implementation of calling the main features of Kover programmatically") | ||
fatJar.set(true) | ||
} | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_1_7 | ||
targetCompatibility = JavaVersion.VERSION_1_7 | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
tasks.processResources { | ||
val version = if (project.hasProperty("releaseVersion")) { | ||
project.property("releaseVersion").toString() | ||
} else { | ||
project.version.toString() | ||
} | ||
|
||
filesMatching("**/kover.version") { | ||
filter { | ||
it.replace("\$version", version) | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(libs.intellij.reporter) | ||
} |
36 changes: 36 additions & 0 deletions
36
kover-features-jvm/src/main/java/kotlinx/kover/features/jvm/ConDySettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package kotlinx.kover.features.jvm; | ||
|
||
/** | ||
* Internal class to control JVM ConDy settings. | ||
*/ | ||
final class ConDySettings { | ||
|
||
private ConDySettings() { | ||
// no-op | ||
} | ||
|
||
private static final String CONDY_SYSTEM_PARAM_NAME = "coverage.condy.enable"; | ||
|
||
/** | ||
* Disable JVM ConDy during instrumentation. | ||
* | ||
* @return previous value of ConDy setting | ||
*/ | ||
static String disableConDy() { | ||
// disable ConDy for offline instrumentations | ||
return System.setProperty(CONDY_SYSTEM_PARAM_NAME, "false"); | ||
} | ||
|
||
/** | ||
* Restore previous value of JVM ConDy setting. | ||
* | ||
* @param prevValue new setting value | ||
*/ | ||
static void restoreConDy(String prevValue) { | ||
if (prevValue == null) { | ||
System.clearProperty(CONDY_SYSTEM_PARAM_NAME); | ||
} else { | ||
System.setProperty(CONDY_SYSTEM_PARAM_NAME, prevValue); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
kover-features-jvm/src/main/java/kotlinx/kover/features/jvm/KoverFeatures.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package kotlinx.kover.features.jvm; | ||
|
||
import java.io.InputStream; | ||
import java.util.Scanner; | ||
|
||
/** | ||
* A class for using features via Java calls. | ||
*/ | ||
public class KoverFeatures { | ||
private static final String koverVersion = readVersion(); | ||
|
||
/** | ||
* Getting the Kover version. | ||
* | ||
* @return The version of Kover used in these utilities. | ||
*/ | ||
public static String getVersion() { | ||
return koverVersion; | ||
} | ||
|
||
/** | ||
* Create instance to instrument already compiled class-files. | ||
* | ||
* @return instrumenter for offline instrumentation. | ||
*/ | ||
public static OfflineInstrumenter createOfflineInstrumenter() { | ||
return new OfflineInstrumenterImpl(false); | ||
} | ||
|
||
private static String readVersion() { | ||
String version = "unrecognized"; | ||
// read version from file in resources | ||
try (InputStream stream = KoverFeatures.class.getClassLoader().getResourceAsStream("kover.version")) { | ||
if (stream != null) { | ||
version = new Scanner(stream).nextLine(); | ||
} | ||
} catch (Throwable e) { | ||
// can't read | ||
} | ||
return version; | ||
} | ||
} |
Oops, something went wrong.