allprojects {
apply plugin: 'jacoco'
repositories {
jcenter()
}
jacoco {
toolVersion = '0.8.1'
}
}
subprojects {
apply plugin: 'kotlin'
apply plugin: "kotlin-spring"
apply plugin: 'io.spring.dependency-management'
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/libs-snapshot' }
maven { url 'https://repo.spring.io/libs-milestone' }
}
dependencyManagement {
imports {
mavenBom "org.springframework.boot:spring-boot-dependencies:${spring_boot_version}"
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Finchley.M9'
}
}
dependencies {
compile "com.github.wnameless:json-flattener:0.5.0"
compile "com.google.guava:guava:$guava_version"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
testCompile "junit:junit:$junit_version"
testCompile "org.mockito:mockito-core:$mockito_version"
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
jacocoTestReport {
sourceDirectories = files(sourceSets.getByName("main").allSource.srcDirs.findAll{ dir -> dir.toString().contains("kotlin")})
classDirectories = files(sourceSets.getByName("main").output.findAll{ dir -> dir.toString().contains("kotlin") })
println("**********source files******")
println(sourceDirectories.files.toListString())
println(classDirectories.files.toListString())
println("********class files end")
reports {
html.enabled = true
xml.enabled = true
csv.enabled = false
}
}
}
//noinspection GroovyAssignabilityCheck
task jacoco(type:JacocoReport) {
dependsOn subprojects.collect { it.tasks.getByPath('check')}
sourceDirectories = files()
classDirectories = files()
executionData = files()
getSubprojects()
.findAll{ subproject ->
subproject.name == "service-activity" }
.forEach{
subproject ->
def coverageFileLocation = "${subproject.buildDir}/jacoco/test.exec"
if (new File(coverageFileLocation).exists()) {
executionData += subproject.tasks.findByName("jacocoTestReport").property("executionData")
sourceDirectories += subproject.tasks.findByName("jacocoTestReport").property("sourceDirectories")
classDirectories += subproject.tasks.findByName("jacocoTestReport").property("classDirectories")
}
}
reports {
xml.enabled = true
csv.enabled = false
html.enabled = true
}
}
task jacocoFix(type: Copy) {
from 'build/reports/jacoco/jacoco/jacoco.xml' into './'
filter {
line -> line.replaceAll("<package name=\"com/cd/activity\">", "<package name=\"service-activity/src/main/kotlin/com/cd/activity\">")
}
filter { line -> line.replaceAll("<sourcefile name=\"ServerResponseExtensions.kt\">", "<sourcefile name=\"ActivityWebHandlers.kt\">")
}
filter { line -> line.replaceAll("<sourcefile name=\"ServerRequestExtensions.kt\">", "<sourcefile name=\"ActivityWebHandlers.kt\">")
}
filter { line -> line.replaceAll("<sourcefile name=\"Extensions.kt\">", "<sourcefile name=\"ActivityWebHandlers.kt\">")
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.5.1' //version required
}I use jacocofix to fix the package name, but I have a lot subprojects, I can not do this. also I do not know why the Extenstions kt files are there.
this is gradle.build config for multi kotlin projects.
Thank you for your response in advance.
Michelle
--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/4ff3c538-f25a-47b2-8646-c9061bd614cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
def excludes = [
'**/**ActivityWebHandlers.kt',
'**/**ServerRequestExtensions.kt',
'**/**ServerResponseExtensions.kt',
]
def sourceDir = sourceSets.getByName("main").allSource.srcDirs.find{ dir -> dir.toString().contains("kotlin")}
def sourceTree = fileTree(
dir: sourceDir,
excludes: excludes
)
sourceDirectories = files([sourceTree])
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
Other wise please contact the grade project. We’re not doing the JaCoC integration for grade ourself.
task jacocoFix(type: Copy) {
from 'build/reports/jacoco/jacocoRootReport/jacocoRootReport.xml' into './'
rename { fileName -> "jacoco.xml"}
filter { line -> line.replaceAll("</sourcefile><sourcefile name=\"ServerResponseExtensions.kt\">", "")
}
filter { line -> line.replaceAll("</sourcefile><sourcefile name=\"ServerRequestExtensions.kt\">", "")
}
filter { line -> line.replaceAll("</sourcefile><sourcefile name=\"Extensions.kt\">", "")
}
}
Hey Evengy,I knew this, just think codeclimate will only read bar and ignore baz as now. Looks like the coverage report number is correct so far.However, I do not like this solution and like to have as possible as better one. the solution you told, I could not use it. Because class files does not include the Extensions.class. so even I do that, the The extensions.kt are still in the source files. Do you know any one have this similar issue? or should go ask Kotlin or Gradle?
Hey Evgeny,We know those files are created from AcitivityWebHandlers.kt, because of the serverRequest.bodyToMono<Activity>, it use library Extensions stuff. but might be a better way to do it or you have a better idea to help this.
Sure Evgeny, I attached the part of project, but can compile and create the jacoco.xml
I also added:afterEvaluate {
classDirectories = files(classDirectories.files.collect {
fileTree(dir: it, exclude: ['**/**WebHandlers.class'])
})
}in the jacocoTestReport, but did not see it works.We are having multi subprojects, do not know how does it affect. Also somewhere use excludes. Do they make difference or not.thank you!Michelle
At same time, I would be very appreciate if you can let me know how to do you find the compiled classes.