Skip to content

Commit

Permalink
put sonar into subprojects 1
Browse files Browse the repository at this point in the history
Signed-off-by: BAStos525 <[email protected]>
  • Loading branch information
BAStos525 committed Oct 16, 2024
1 parent b83ce66 commit d1f9f7a
Showing 1 changed file with 67 additions and 14 deletions.
81 changes: 67 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ plugins {
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'org.sonarqube' version "5.1.0.4882"
id 'jacoco'
// id 'jacoco'
}

allprojects {
Expand Down Expand Up @@ -56,10 +56,6 @@ subprojects {
group = 'jp.co.soramitsu.iroha2-java'
version = 'git rev-parse --short HEAD'.execute().text.trim()

test {
useJUnitPlatform()
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
Expand Down Expand Up @@ -106,33 +102,90 @@ subprojects {
dependsOn "${project.path}:processTestResources"
dependsOn "${project.path}:compileTestKotlin"

executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")

sourceSets sourceSets.main

reports {
xml.required = true
html.required = true
}

def excludes = [
'**/R.class',
'**/R$*.class',
'**/BuildConfig.*',
'**/Manifest*.*',
'**/*Test*.*',
'android/**/*.*',
'androidx/**/*.*',
'**/*$ViewInjector*.*',
'**/*Dagger*.*',
'**/*MembersInjector*.*',
'**/*_Factory.*',
'**/*_Provide*Factory*.*',
'**/*_ViewBinding*.*',
'**/AutoValue_*.*',
'**/R2.class',
'**/R2$*.class',
'**/*Directions$*',
'**/*Directions.*',
'**/*Binding.*'
]
def kotlinClasses = fileTree(dir: "${project.projectDir}/build/classes", excludes: excludes)

classDirectories.from = files([kotlinClasses])
def sourceDirs = [
"${project.projectDir}/src/main/java",
"${project.projectDir}/src/main/kotlin",
"${project.projectDir}/src/debug/java",
"${project.projectDir}/src/debug/kotlin"
]
sourceDirectories.from = files(sourceDirs)

executionData.from = files(
["${project.buildDir}/jacoco/test.exec", "${project.buildDir}/jacoco/integrationTest.exec"]
)
}

tasks.named('testCoverage') {
// Add specific dependencies for tasks that weren't covered
mustRunAfter ":${project.path}:processTestResources"
mustRunAfter ":${project.path}:compileTestKotlin"
mustRunAfter ":${project.path}:test"
test {
useJUnitPlatform()
failFast = true
testLogging {
events "passed", "skipped", "failed"
}
reports {
junitXml.required = true
}
finalizedBy testCoverage
}

// task testCoverage(type: JacocoReport) {
// // Ensure all necessary tasks are complete before running testCoverage
// dependsOn "${project.path}:test"
// dependsOn "${project.path}:processTestResources"
// dependsOn "${project.path}:compileTestKotlin"

// executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")

// sourceSets sourceSets.main

// reports {
// xml.required = true
// html.required = true
// }
// }


sonar {
properties {
property "sonar.projectKey", "hyperledger:iroha-java"
property "sonar.host.url", "https://sonar.katana.soramitsu.co.jp"
property "sonar.projectName", "${project.group}:${rootProject.name}.${project.name}"
property "sonar.sources", "${project.projectDir}/src/main/java"
property "sonar.tests", "${project.projectDir}/src/test"
property "sonar.java.binaries", "${project.projectDir}/build/classes"
property "sonar.java.libraries", "${project.projectDir}/build/libs"
property "sonar.java.test.binaries", "${project.projectDir}/build/test-results/test/binary"
property "sonar.junit.reportPaths", "${project.projectDir}/build/test-results/test/"
property "sonar.coverage.jacoco.xmlReportPaths", "${project.projectDir}/build/reports/testCoverage/*.xml"
property "sonar.exclusions", "${project.projectDir}/**/*.txt"
}
}

Expand Down

0 comments on commit d1f9f7a

Please sign in to comment.