Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 22 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import com.github.vlsi.gradle.release.RepositoryType
import net.ltgt.gradle.errorprone.errorprone
import org.ajoberstar.grgit.Grgit
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.sonarqube.gradle.SonarQubeProperties
import org.sonarqube.gradle.SonarProperties

plugins {
java
Expand Down Expand Up @@ -141,6 +141,10 @@ releaseParams {
val jacocoReport by tasks.registering(JacocoReport::class) {
group = "Coverage reports"
description = "Generates an aggregate report from all subprojects"
reports {
xml.required.set(true)
html.required.set(true)
}
}

val jacocoEnabled by extra {
Expand Down Expand Up @@ -191,20 +195,23 @@ sonarqube {
}
}

fun SonarQubeProperties.add(name: String, valueProvider: () -> String) {
properties.getOrPut(name) { mutableSetOf<Any>() }
.also {
@Suppress("UNCHECKED_CAST")
(it as MutableCollection<Any>).add(object {
// SonarQube calls toString when converting properties to values
// (see SonarQubeProperties), so we use that to emulate "lazy properties"
override fun toString() = valueProvider()
})
}
fun SonarProperties.add(name: String, valueProvider: () -> String) {
val props = getProperties()
val valueHolder = object {
// SonarQube calls toString when converting properties to values
// so we use that to emulate "lazy properties"
override fun toString() = valueProvider()
}
val current = props[name]
when (current) {
null -> props[name] = mutableListOf(valueHolder)
is MutableCollection<*> -> (current as MutableCollection<Any>).add(valueHolder)
else -> props[name] = mutableListOf(current, valueHolder)
}
}

if (jacocoEnabled) {
val mergedCoverage = jacocoReport.get().reports.xml.destination.toString()
val mergedCoverage = jacocoReport.get().reports.xml.outputLocation.asFile.get().toString()

// For every module we pass merged coverage report
// That enables to see ":src:core" lines covered even in case they are covered from
Expand Down Expand Up @@ -249,7 +256,7 @@ if (enableSpotBugs) {
add("sonar.java.spotbugs.reportPaths") {
// Note: report is created with lower-case xml, and then
// the created entry MUST be retrieved as upper-case XML
reports.named("XML").get().destination.toString()
reports.named("xml").get().outputLocation.asFile.get().toString()
}
}
}
Expand Down Expand Up @@ -463,8 +470,8 @@ allprojects {

tasks.withType<JacocoReport>().configureEach {
reports {
html.isEnabled = reportsForHumans()
xml.isEnabled = !reportsForHumans()
html.required.set(reportsForHumans())
xml.required.set(!reportsForHumans())
}
}
// Add each project to combined report
Expand Down
26 changes: 2 additions & 24 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,45 +21,23 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
java
`kotlin-dsl` apply false
id("com.github.autostyle")
}

repositories {
gradlePluginPortal()
mavenCentral()
}

allprojects {
repositories {
gradlePluginPortal()
mavenCentral()
}
applyKotlinProjectConventions()
}

fun Project.applyKotlinProjectConventions() {
apply(plugin = "org.gradle.kotlin.kotlin-dsl")

tasks.withType<KotlinCompile> {
sourceCompatibility = "unused"
targetCompatibility = "unused"
kotlinOptions {
jvmTarget = "1.8"
}
}
apply(plugin = "com.github.autostyle")
autostyle {
kotlin {
ktlint {
userData(mapOf("disabled_rules" to "import-ordering"))
}
trimTrailingWhitespace()
endWithNewline()
}
kotlinGradle {
ktlint()
trimTrailingWhitespace()
endWithNewline()
}
}
}

dependencies {
Expand Down
63 changes: 1 addition & 62 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* 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.
*
*/

pluginManagement {
Expand All @@ -24,64 +23,4 @@ pluginManagement {
}

include("batchtest")

val upperCaseLetters = "\\p{Upper}".toRegex()

fun String.toKebabCase() =
replace(upperCaseLetters) { "-${it.value.toLowerCase()}" }

fun buildFileNameFor(projectDirName: String) =
"$projectDirName.gradle.kts"

for (project in rootProject.children) {
val projectDirName = project.name.toKebabCase()
project.projectDir = file("subprojects/$projectDirName")
project.buildFileName = buildFileNameFor(projectDirName)
assert(project.projectDir.isDirectory)
assert(project.buildFile.isFile)
}

buildscript {
dependencies {
classpath("com.github.vlsi.gradle:checksum-dependency-plugin:${settings.extra["com.github.vlsi.checksum-dependency.version"]}") {
// Gradle ships kotlin-stdlib which is good enough
exclude("org.jetbrains.kotlin", "kotlin-stdlib")
}
}
repositories {
gradlePluginPortal()
}
}

// Note: we need to verify the checksum for checksum-dependency-plugin itself
val expectedSha512 = mapOf(
"43BC9061DFDECA0C421EDF4A76E380413920E788EF01751C81BDC004BD28761FBD4A3F23EA9146ECEDF10C0F85B7BE9A857E9D489A95476525565152E0314B5B"
to "bcpg-jdk15on-1.62.jar",
"2BA6A5DEC9C8DAC2EB427A65815EB3A9ADAF4D42D476B136F37CD57E6D013BF4E9140394ABEEA81E42FBDB8FC59228C7B85C549ED294123BF898A7D048B3BD95"
to "bcprov-jdk15on-1.62.jar",
"17DAAF511BE98F99007D7C6B3762C9F73ADD99EAB1D222985018B0258EFBE12841BBFB8F213A78AA5300F7A3618ACF252F2EEAD196DF3F8115B9F5ED888FE827"
to "okhttp-4.1.0.jar",
"93E7A41BE44CC17FB500EA5CD84D515204C180AEC934491D11FC6A71DAEA761FB0EECEF865D6FD5C3D88AAF55DCE3C2C424BE5BA5D43BEBF48D05F1FA63FA8A7"
to "okio-2.2.2.jar",
settings.extra["com.github.vlsi.checksum-dependency.sha512"].toString()
to "checksum-dependency-plugin.jar"
)

fun File.sha512(): String {
val md = java.security.MessageDigest.getInstance("SHA-512")
forEachBlock { buffer, bytesRead ->
md.update(buffer, 0, bytesRead)
}
return BigInteger(1, md.digest()).toString(16).toUpperCase()
}

val violations =
buildscript.configurations["classpath"]
.resolve()
.sortedBy { it.name }
.associateWith { it.sha512() }
.filterNot { (_, sha512) -> expectedSha512.contains(sha512) }
.entries
.joinToString("\n ") { (file, sha512) -> "SHA-512(${file.name}) = $sha512 ($file)" }

apply(plugin = "com.github.vlsi.checksum-dependency")
project(":batchtest").projectDir = file("subprojects/batchtest")
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
*/

plugins {
`kotlin-dsl`
}

repositories {
gradlePluginPortal()
mavenCentral()
}

dependencies {
implementation("org.ajoberstar.grgit:grgit-gradle:4.1.0")
implementation("org.eclipse.jgit:org.eclipse.jgit:5.11.0.202103091610-r")
implementation("org.eclipse.jgit:org.eclipse.jgit:6.10.1.202505221210-r")
}

gradlePlugin {
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ spotbugs.version=4.1.2
velocity.version=1.7

# Plugins
com.github.autostyle.version=3.0
com.github.spotbugs.version=4.5.0
com.github.autostyle.version=4.0
com.github.spotbugs.version=6.0.4
com.github.vlsi.checksum-dependency.sha512=84572B7F654D1F9842DDD7E0D4331461DC55B92CDC1DA8EBA2269870CE027B021AB91D1942043145825B00521A92029C969BFA388A27BD63CC509BF7AB18E35F
com.github.vlsi.checksum-dependency.version=1.74
com.github.vlsi.vlsi-release-plugins.version=1.74
net.ltgt.errorprone.version=1.2.1
org.jetbrains.gradle.plugin.idea-ext.version=0.5
org.nosphere.apache.rat.version=0.7.0
org.sonarqube.version=3.0
com.github.vlsi.checksum-dependency.version=2.0.0
com.github.vlsi.vlsi-release-plugins.version=2.0.0
net.ltgt.errorprone.version=4.3.0
org.jetbrains.gradle.plugin.idea-ext.version=1.3
org.nosphere.apache.rat.version=0.8.1
org.sonarqube.version=4.4.1.3373

# Dependencies
accessors-smart.version=2.4.7
Expand Down
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=f581709a9c35e9cb92e16f585d2c4bc99b2b1a5f85d2badbd3dc6bff59e1e6dd
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
80 changes: 11 additions & 69 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ pluginManagement {
}

plugins {
`gradle-enterprise`
// Gradle Enterprise requires downloading a plugin from the Gradle portal, which might
// be blocked in restricted environments. Allow opting in via USE_GRADLE_ENTERPRISE=true
// so local/offline builds can proceed without trying to resolve the plugin.
if (System.getenv("USE_GRADLE_ENTERPRISE")?.equals("true", ignoreCase = true) == true) {
`gradle-enterprise`
}
}

// This is the name of a current project
Expand Down Expand Up @@ -92,83 +97,20 @@ fun property(name: String) =
else -> null
}

val useGradleEnterprise = System.getenv("USE_GRADLE_ENTERPRISE")?.toBool(nullAs = false, blankAs = false, default = false) ?: false
val useChecksumPlugin = System.getenv("USE_CHECKSUM_PLUGIN")?.toBool(nullAs = false, blankAs = false, default = false) ?: false

if (property("localReleasePlugins").toBool(nullAs = false, blankAs = true, default = false)) {
// This enables to use local clone of vlsi-release-plugins for debugging purposes
includeBuild("../vlsi-release-plugins")
}

val isCiServer = System.getenv().containsKey("CI")

if (isCiServer) {
gradleEnterprise {
buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
tag("CI")
}
}
}

// Checksum plugin sources can be validated at https://github.com/vlsi/vlsi-release-plugins
buildscript {
dependencies {
classpath("com.github.vlsi.gradle:checksum-dependency-plugin:${settings.extra["com.github.vlsi.checksum-dependency.version"]}") {
// Gradle ships kotlin-stdlib which is good enough
exclude("org.jetbrains.kotlin", "kotlin-stdlib")
}
}
repositories {
gradlePluginPortal()
}
if (useChecksumPlugin) {
println("USE_CHECKSUM_PLUGIN is enabled, but checksum verification is disabled in this environment.")
}

// Note: we need to verify the checksum for checksum-dependency-plugin itself
val expectedSha512 = mapOf(
"F7040C571C2A2727F2EED4EA772F5A7C5D9CB393828B7A2331F7167E467429486F5F3E9423883FE9A6D652FFB0484EAE722CDFB46D97180209BCBEEBF9C25DE3"
to "gradle-enterprise-gradle-plugin-3.4.jar",
"D5B49D90170DEA96E3D05D893B2B6C04E3B16F3DB6B6BB1DF82D3DE3247E5B0457721F232FAA237E689100980E97F4C04C1234FBEDBDAB7AE0CEAA91C40392C9"
to "gradle-enterprise-gradle-plugin-3.4.1.jar",
"AA8D06BDF95A6BAAEFE2B0DAE530FCD324A92238F7B790C0FF4A4B5C6454A6BE83D2C81BFEC013A7368697A0A9FC61B97E91775EF9948EF5572FA1DAA9E82052"
to "gradle-enterprise-gradle-plugin-3.5.jar",
"2A01A91008DF02AA0256D64EAB9238B23B85EA2A886E024E07C3880D642C5E4B96E66DE0D90832BCCEFE5F7C8EF045EBB9905B2A74398E38FAD6A5B28BEBA54D"
to "gradle-enterprise-gradle-plugin-3.6.jar",
"43BC9061DFDECA0C421EDF4A76E380413920E788EF01751C81BDC004BD28761FBD4A3F23EA9146ECEDF10C0F85B7BE9A857E9D489A95476525565152E0314B5B"
to "gradle-enterprise-gradle-plugin-3.6.3.jar",
"FA305ACAAF45D005F5032D93C4F37CD097936C802943885A8F2B9EC27DA24F148DB41748655347C9A707C62614087432B3D32CC1B297381D45F3D8063BFFFA6D"
to "bcpg-jdk15on-1.62.jar",
"2BA6A5DEC9C8DAC2EB427A65815EB3A9ADAF4D42D476B136F37CD57E6D013BF4E9140394ABEEA81E42FBDB8FC59228C7B85C549ED294123BF898A7D048B3BD95"
to "bcprov-jdk15on-1.62.jar",
"17DAAF511BE98F99007D7C6B3762C9F73ADD99EAB1D222985018B0258EFBE12841BBFB8F213A78AA5300F7A3618ACF252F2EEAD196DF3F8115B9F5ED888FE827"
to "okhttp-4.1.0.jar",
"93E7A41BE44CC17FB500EA5CD84D515204C180AEC934491D11FC6A71DAEA761FB0EECEF865D6FD5C3D88AAF55DCE3C2C424BE5BA5D43BEBF48D05F1FA63FA8A7"
to "okio-2.2.2.jar",
settings.extra["com.github.vlsi.checksum-dependency.sha512"].toString()
to "checksum-dependency-plugin.jar"
)

fun File.sha512(): String {
val md = java.security.MessageDigest.getInstance("SHA-512")
forEachBlock { buffer, bytesRead ->
md.update(buffer, 0, bytesRead)
}
return BigInteger(1, md.digest()).toString(16).toUpperCase()
}

val violations =
buildscript.configurations["classpath"]
.resolve()
.sortedBy { it.name }
.associateWith { it.sha512() }
.filterNot { (_, sha512) -> expectedSha512.contains(sha512) }
.entries
.joinToString("\n ") { (file, sha512) -> "SHA-512(${file.name}) = $sha512 ($file)" }

if (violations.isNotBlank()) {
throw GradleException("Buildscript classpath has files that were not explicitly permitted:\n $violations")
}

apply(plugin = "com.github.vlsi.checksum-dependency")

// This enables to try local Autostyle
property("localAutostyle")?.ifBlank { "../autostyle" }?.let {
println("Importing project '$it'")
Expand Down
3 changes: 2 additions & 1 deletion src/dist-check/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("DEPRECATION")

import com.github.vlsi.gradle.properties.dsl.props
import java.time.Duration
import org.apache.jmeter.buildtools.batchtest.BatchTest
import org.apache.jmeter.buildtools.batchtest.BatchTestServer

plugins {
jmeterbuild.batchtest
id("jmeterbuild.batchtest")
id("com.github.vlsi.gradle-extensions")
}

Expand Down
3 changes: 2 additions & 1 deletion src/dist/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("DEPRECATION")

import com.github.vlsi.gradle.crlf.CrLfSpec
import com.github.vlsi.gradle.crlf.LineEndings
Expand Down Expand Up @@ -595,7 +596,7 @@ val runGui by tasks.registering(JavaExec::class) {
dependsOn(createDist)

workingDir = File(project.rootDir, "bin")
main = "org.apache.jmeter.NewDriver"
mainClass.set("org.apache.jmeter.NewDriver")
classpath("$rootDir/bin/ApacheJMeter.jar")
jvmArgs("-Xss256k")
jvmArgs("-XX:MaxMetaspaceSize=256m")
Expand Down