Skip to content

Commit

Permalink
use self-hosted & subprojects 9
Browse files Browse the repository at this point in the history
Signed-off-by: BAStos525 <jungle.vas@yandex.ru>
  • Loading branch information
BAStos525 committed Oct 16, 2024
1 parent 0c57c6c commit ccf4083
Showing 1 changed file with 67 additions and 166 deletions.
233 changes: 67 additions & 166 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ subprojects {
apply plugin: 'org.jmailen.kotlinter'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'jacoco'
apply plugin: 'org.sonarqube'

publishing {
publications {
Expand All @@ -57,6 +56,10 @@ 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 @@ -97,184 +100,82 @@ subprojects {
// it is disabled by default to publish original version by CI, not a fat jar
tasks.shadowJar.enabled = false

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"
}

reports {
xml.required = true
html.required = true
}
task allShadowJars {
subprojects { pr -> allShadowJars.dependsOn("${pr.path}:shadowJar") }
}

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.*'
]

executionData tasks.withType(Test)
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
sourceSets sourceSets.main

// 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"]
// )
}
check {
dependsOn "installKotlinterPrePushHook"
}

test {
useJUnitPlatform()
failFast = true
testLogging {
events "passed", "skipped", "failed"
}
reports {
junitXml.required = true
}
finalizedBy testCoverage
jacoco {
toolVersion = "0.8.8"
reportsDirectory = file("$buildDir/reports/")
}

task testCoverage(type: JacocoReport) {
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")

subprojects.each {
sourceSets it.sourceSets.main
}

// 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"
}
reports {
xml.required = true
html.required = true
}
}


test {
useJUnitPlatform()
dependsOn testCoverage
}

jacoco {
toolVersion = "0.8.8"
reportsDirectory = file("$buildDir/reports/")
sonar {
properties {
property "sonar.projectKey", "hyperledger:iroha-java"
property "sonar.host.url", "https://sonar.katana.soramitsu.co.jp"
property "sonar.java.coveragePlugin", "jacoco"
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.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"
}
}

tasks.named('testCoverage') {
dependsOn ":admin-client:processTestResources"
}

task allShadowJars {
subprojects { pr -> allShadowJars.dependsOn("${pr.path}:shadowJar") }
tasks.named('testCoverage') {
dependsOn ":block:compileTestKotlin"
}

check {
dependsOn "installKotlinterPrePushHook"
tasks.named('testCoverage') {
dependsOn ":block:test"
}

// jacoco {
// toolVersion = "0.8.8"
// reportsDirectory = file("$buildDir/reports/")
// }
tasks.named('testCoverage') {
dependsOn ":block:processTestResources"
}

// task testCoverage(type: JacocoReport) {
// executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")

// subprojects.each {
// sourceSets it.sourceSets.main
// }

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

// test {
// useJUnitPlatform()
// finalizedBy testCoverage
// }



// tasks.configureEach {
// tasks.named('testCoverage') {
// dependsOn ":$name:processTestResources"
// }
// tasks.named('testCoverage') {
// dependsOn ":$name:compileTestKotlin"
// }
// tasks.named('testCoverage') {
// dependsOn ":$name:test"
// }
// }

// tasks.named('testCoverage') {
// dependsOn ":admin-client:processTestResources"
// }

// tasks.named('testCoverage') {
// dependsOn ":block:compileTestKotlin"
// }

// tasks.named('testCoverage') {
// dependsOn ":block:test"
// }

// tasks.named('testCoverage') {
// dependsOn ":block:processTestResources"
// }

// tasks.named('testCoverage') {
// dependsOn ":client:processTestResources"
// }

// tasks.named('testCoverage') {
// dependsOn ":codegen:test"
// }

// tasks.named('testCoverage') {
// dependsOn ":model:test"
// }

// tasks.named('testCoverage') {
// dependsOn ":test-tools:processTestResources"
// }
tasks.named('testCoverage') {
dependsOn ":client:processTestResources"
}

tasks.named('testCoverage') {
dependsOn ":codegen:test"
}

tasks.named('testCoverage') {
dependsOn ":model:test"
}

tasks.named('testCoverage') {
dependsOn ":test-tools:processTestResources"
}

0 comments on commit ccf4083

Please sign in to comment.