-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathbuild.gradle
More file actions
111 lines (98 loc) · 4.15 KB
/
Copy pathbuild.gradle
File metadata and controls
111 lines (98 loc) · 4.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
buildscript {
ext {
besuPluginDir = File.createTempDir("plugins")
releaseVersion = project.findProperty('releaseVersion') ?: 'SNAPSHOT'
distributionIdentifier = "linea-tracer"
distibutionBaseName = "linea-arithmetization"
}
}
plugins {
id 'java-library'
alias(libs.plugins.besuPluginLibrary)
alias(libs.plugins.besuPluginDistribution)
alias(libs.plugins.sonarQube)
alias(libs.plugins.testLogger)
}
allprojects {
plugins.withId('net.consensys.besu-plugin-library') {
besuPlugin {
besuVersion = rootProject.providers.provider { rootProject.ext.resolveBesuVersion() }
besuRepo = "https://artifacts.consensys.net/public/linea-besu/maven/"
}
}
}
def resolveSonarReport = { String tests ->
// Conditional xmlReportPaths based on tests property.
// Default is unit tests, which only use the unit-test Jacoco coverage report.
if (tests == null || tests == "Unit") {
return [
message: "Executing Sonarqube scanner Unit tests coverage report...",
xmlTestReport: "${project.projectDir}/arithmetization/build/reports/jacoco/test/jacocoTestReport.xml",
]
} else if (tests == "FastReplay") {
return [
message: "Executing Sonarqube scanner for FastReplay tests coverage report...",
xmlTestReport: "${project.projectDir}/arithmetization/build/reports/jacoco/jacocoFastReplayTestsReport/jacocoFastReplayTestsReport.xml",
]
} else if (tests == "Nightly") {
return [
message: "Executing Sonarqube scanner for Nightly tests coverage report...",
xmlTestReport: "${project.projectDir}/arithmetization/build/reports/jacoco/jacocoNightlyTestsReport/jacocoNightlyTestsReport.xml",
]
} else if (tests == "Weekly") {
return [
message: "Executing Sonarqube scanner for Weekly tests coverage report...",
xmlTestReport: "${project.projectDir}/arithmetization/build/reports/jacoco/jacocoWeeklyTestsReport/jacocoWeeklyTestsReport.xml",
]
} else if (tests == "PrcWeekly") {
return [
message: "Executing Sonarqube scanner for Weekly Prc Call tests coverage report...",
xmlTestReport: "${project.projectDir}/arithmetization/build/reports/jacoco/jacocoWeeklyTestsReport/jacocoPrcCallTestsReport.xml",
]
} else if (tests == "ReferenceBlockchain") {
return [
message: "Executing Sonarqube scanner for Reference Blockchain tests coverage report...",
xmlTestReport: "${project.projectDir}/reference-tests/build/reports/jacoco/jacocoReferenceBlockchainTestsReport/jacocoReferenceBlockchainTestsReport.xml",
]
} else if (tests == "ReferenceState") {
return [
message: "Executing Sonarqube scanner for Reference State tests coverage report...",
xmlTestReport: "${project.projectDir}/reference-tests/build/reports/jacoco/jacocoReferenceGeneralStateTestsReport/jacocoReferenceGeneralStateTestsReport.xml",
]
} else if (tests == "All") {
return [
message: "Executing Sonarqube scanner for Unit, FastReplay, Nightly, Weekly, Reference Blockchain and State tests coverage report...",
xmlTestReport: "${project.projectDir}/arithmetization/build/reports/jacocoConcatenate/test/jacocoTestReport.xml",
]
}
throw new GradleException(
"*** unknown tests property. Try '-Dtests=Unit', '-Dtests=FastReplay', '-Dtests=Nightly', '-Dtests=Weekly', '-Dtests=ReferenceBlockchain', '-Dtests=ReferenceState' or '-Dtests=All'"
)
}
def sonarReport = resolveSonarReport(System.getProperty("tests"))
sonar {
properties {
property "sonar.projectKey", "linea-tracer"
property "sonar.host.url", "localhost:80"
property "sonar.token", "your_token"
property "sonar.coverage.exclusions", "reference-tests/**/*, testing/**/*, **/*/Trace.java"
property "sonar.coverage.jacoco.xmlReportPaths", sonarReport.xmlTestReport
}
}
tasks.matching { it.name in ['sonar', 'sonarqube'] }.configureEach {
doFirst {
logger.lifecycle(sonarReport.message)
}
}
version = project.findProperty('releaseVersion') ?: "SNAPSHOT"
apply from: file("gradle/java.gradle")
jar {
archiveBaseName = distibutionBaseName
version = calculateVersion()
}
distributions {
main {
distributionBaseName = distibutionBaseName
version = calculateVersion()
}
}