Skip to content

Commit

Permalink
Update Gradle
Browse files Browse the repository at this point in the history
Update Gradle Wrapper and plugins to latest version.
Update actions in CI workflow.

Signed-off-by: thc202 <[email protected]>
  • Loading branch information
thc202 committed Jun 18, 2024
1 parent 29e6ab8 commit 994b326
Show file tree
Hide file tree
Showing 13 changed files with 214 additions and 183 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
- uses: gradle/wrapper-validation-action@v1
- uses: gradle/gradle-build-action@v2
- uses: gradle/actions/wrapper-validation@v3
- uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-includes: |
caches
Expand Down
101 changes: 58 additions & 43 deletions addOns/addOns.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,30 @@ import org.zaproxy.gradle.crowdin.CrowdinExtension
plugins {
eclipse
jacoco
id("org.cyclonedx.bom") version "1.8.1" apply false
id("org.cyclonedx.bom") version "1.8.2" apply false
id("org.rm3l.datanucleus-gradle-plugin") version "2.0.0" apply false
id("org.zaproxy.add-on") version "0.10.0" apply false
id("org.zaproxy.add-on") version "0.11.0" apply false
id("org.zaproxy.crowdin") version "0.4.0" apply false
id("me.champeau.gradle.japicmp") version "0.4.2" apply false
id("me.champeau.gradle.japicmp") version "0.4.3" apply false
}

description = "Common configuration of the add-ons."

val mandatoryAddOns = listOf(
"callhome",
"network",
)
val mandatoryAddOns =
listOf(
"callhome",
"network",
)

val parentProjects = listOf(
"webdrivers",
)
val parentProjects =
listOf(
"webdrivers",
)

val ghReleaseDataProvider = provider {
subprojects.first().zapAddOn.gitHubRelease
}
val ghReleaseDataProvider =
provider {
subprojects.first().zapAddOn.gitHubRelease
}
val generateReleaseStateLastCommit by tasks.registering(GenerateReleaseStateLastCommit::class)

val handleRelease by tasks.registering(HandleRelease::class) {
Expand All @@ -59,9 +62,10 @@ val createPullRequestNextDevIter by tasks.registering(CreatePullRequest::class)
commitSummary.set("Prepare next dev iteration(s)")
commitDescription.set(
provider {
"Update version and changelog for:\n" + releasedProjects.map {
" - ${it.zapAddOn.addOnName.get()}"
}.sorted().joinToString("\n")
"Update version and changelog for:\n" +
releasedProjects.map {
" - ${it.zapAddOn.addOnName.get()}"
}.sorted().joinToString("\n")
},
)

Expand All @@ -73,9 +77,10 @@ val allJarsForBom by tasks.registering {
dependsOn(project(":testutils").tasks.named(JavaPlugin.JAR_TASK_NAME))
}

val crowdinExcludedProjects = setOf(
childProjects.get("dev"),
)
val crowdinExcludedProjects =
setOf(
childProjects.get("dev"),
)

subprojects {
if (parentProjects.contains(project.name)) {
Expand Down Expand Up @@ -156,7 +161,9 @@ subprojects {
val apiGenClasspath = configurations.detachedConfiguration(dependencies.create(zapGav))

zapAddOn {
releaseLink.set(project.provider { "https://github.com/zaproxy/zap-extensions/releases/${zapAddOn.addOnId.get()}-v@CURRENT_VERSION@" })
releaseLink.set(
project.provider { "https://github.com/zaproxy/zap-extensions/releases/${zapAddOn.addOnId.get()}-v@CURRENT_VERSION@" },
)

manifest {
zapVersion.set("2.15.0")
Expand Down Expand Up @@ -233,7 +240,13 @@ subprojects {

assets {
register("bom") {
file.set(cyclonedxBom.map { project.layout.projectDirectory.file(File(it.destination.get(), "${it.outputName.get()}.json").absolutePath) })
file.set(
cyclonedxBom.map {
project.layout.projectDirectory.file(
File(it.destination.get(), "${it.outputName.get()}.json").absolutePath,
)
},
)
contentType.set("application/json")
}
}
Expand Down Expand Up @@ -394,12 +407,13 @@ subprojects {

val crowdinUploadSourceFiles by tasks.registering {
System.getenv("ADD_ON_IDS")?.let {
val projects = splitAddOnIds(it).map { name ->
val project = subprojects.find { it.name == name }
require(project != null) { "Add-on with project name $name not found." }
val projects =
splitAddOnIds(it).map { name ->
val project = subprojects.find { it.name == name }
require(project != null) { "Add-on with project name $name not found." }

project
}.filter { !crowdinExcludedProjects.contains(it) }
project
}.filter { !crowdinExcludedProjects.contains(it) }

projects.forEach {
dependsOn(it.tasks.named("crowdinUploadSourceFiles"))
Expand All @@ -409,11 +423,12 @@ val crowdinUploadSourceFiles by tasks.registering {

val createPullRequestRelease by tasks.registering(CreatePullRequest::class) {
System.getenv("ADD_ON_IDS")?.let {
val projects = splitAddOnIds(it).map { name ->
val project = subprojects.find { it.name == name }
require(project != null) { "Add-on with project name $name not found." }
project
}
val projects =
splitAddOnIds(it).map { name ->
val project = subprojects.find { it.name == name }
require(project != null) { "Add-on with project name $name not found." }
project
}

projects.forEach {
dependsOn(it.tasks.named("prepareRelease"))
Expand All @@ -426,9 +441,10 @@ val createPullRequestRelease by tasks.registering(CreatePullRequest::class) {
commitSummary.set("Release add-on(s)")
commitDescription.set(
provider {
"Release the following add-ons:\n" + projects.map {
" - ${it.zapAddOn.addOnName.get()} version ${it.zapAddOn.addOnVersion.get()}"
}.sorted().joinToString("\n")
"Release the following add-ons:\n" +
projects.map {
" - ${it.zapAddOn.addOnName.get()} version ${it.zapAddOn.addOnVersion.get()}"
}.sorted().joinToString("\n")
},
)
}
Expand Down Expand Up @@ -502,20 +518,17 @@ val jacocoReport by tasks.registering(JacocoReport::class) {
}
}

fun Project.java(configure: JavaPluginExtension.() -> Unit): Unit =
(this as ExtensionAware).extensions.configure("java", configure)
fun Project.java(configure: JavaPluginExtension.() -> Unit): Unit = (this as ExtensionAware).extensions.configure("java", configure)

fun Project.jacoco(configure: JacocoPluginExtension.() -> Unit): Unit =
(this as ExtensionAware).extensions.configure("jacoco", configure)
fun Project.jacoco(configure: JacocoPluginExtension.() -> Unit): Unit = (this as ExtensionAware).extensions.configure("jacoco", configure)

fun Project.publishing(configure: PublishingExtension.() -> Unit): Unit =
(this as ExtensionAware).extensions.configure("publishing", configure)

val Project.publishing: PublishingExtension get() =
(this as ExtensionAware).extensions.getByName("publishing") as PublishingExtension

fun Project.signing(configure: SigningExtension.() -> Unit): Unit =
(this as ExtensionAware).extensions.configure("signing", configure)
fun Project.signing(configure: SigningExtension.() -> Unit): Unit = (this as ExtensionAware).extensions.configure("signing", configure)

fun Project.zapAddOn(configure: AddOnPluginExtension.() -> Unit): Unit =
(this as ExtensionAware).extensions.configure("zapAddOn", configure)
Expand All @@ -526,8 +539,7 @@ val Project.zapAddOn: AddOnPluginExtension get() =
val AddOnPluginExtension.gitHubRelease: GitHubReleaseExtension get() =
(this as ExtensionAware).extensions.getByName("gitHubRelease") as GitHubReleaseExtension

fun Project.crowdin(configure: CrowdinExtension.() -> Unit): Unit =
(this as ExtensionAware).extensions.configure("crowdin", configure)
fun Project.crowdin(configure: CrowdinExtension.() -> Unit): Unit = (this as ExtensionAware).extensions.configure("crowdin", configure)

val Project.crowdin: CrowdinExtension get() =
(this as ExtensionAware).extensions.getByName("crowdin") as CrowdinExtension
Expand All @@ -545,7 +557,10 @@ fun mandatoryProjects() =
project
}

fun Project.hasProperty(name: String, value: String) = hasProperty(name) && property(name) == value
fun Project.hasProperty(
name: String,
value: String,
) = hasProperty(name) && property(name) == value

fun Project.addOnJar(version: String): File {
val oldGroup = group
Expand Down
5 changes: 4 additions & 1 deletion addOns/formhandler/formhandler.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import org.zaproxy.gradle.addon.AddOnStatus

description = "This Value Generator Add-on allows a user to define field names and values to be used when submitting values to an app. Fields can be added, modified, enabled/disabled, and deleted."
description = (
"This Value Generator Add-on allows a user to define field names and values to be used when submitting values to an app. " +
"Fields can be added, modified, enabled/disabled, and deleted."
)

zapAddOn {
addOnName.set("Value Generator")
Expand Down
5 changes: 4 additions & 1 deletion addOns/openapi/openapi.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ zapAddOn {
addOnStatus.set(AddOnStatus.BETA)

manifest {
author.set("ZAP Dev Team plus Joanna Bona, Nathalie Bouchahine, Artur Grzesica, Mohammad Kamar, Markus Kiss, Michal Materniak, Marcin Spiewak, and SDA SE Open Industry Solutions")
author.set(
"ZAP Dev Team plus Joanna Bona, Nathalie Bouchahine, Artur Grzesica, Mohammad Kamar, " +
"Markus Kiss, Michal Materniak, Marcin Spiewak, and SDA SE Open Industry Solutions",
)
url.set("https://www.zaproxy.org/docs/desktop/addons/openapi-support/")
extensions {
register("org.zaproxy.zap.extension.openapi.automation.ExtensionOpenApiAutomation") {
Expand Down
9 changes: 5 additions & 4 deletions addOns/spiderAjax/spiderAjax.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ zapAddOn {
}
}

val apiGenClasspath = configurations.detachedConfiguration(
dependencies.create("org.zaproxy:zap:${zapVersion.get()}"),
dependencies.create(parent!!.childProjects.get("selenium")!!),
)
val apiGenClasspath =
configurations.detachedConfiguration(
dependencies.create("org.zaproxy:zap:${zapVersion.get()}"),
dependencies.create(parent!!.childProjects.get("selenium")!!),
)

apiClientGen {
api.set("org.zaproxy.zap.extension.spiderAjax.AjaxSpiderAPI")
Expand Down
31 changes: 18 additions & 13 deletions addOns/webdrivers/webdrivers.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ description = "Common configuration of the WebDriver add-ons."
val geckodriverVersion = "0.34.0"
val chromeDriverVersion = "126.0.6478.61"

fun configureDownloadTask(outputDir: File, targetOs: DownloadWebDriver.OS, task: DownloadWebDriver) {
fun configureDownloadTask(
outputDir: File,
targetOs: DownloadWebDriver.OS,
task: DownloadWebDriver,
) {
val geckodriver = task.browser.get() == DownloadWebDriver.Browser.FIREFOX
var path = "webdriver/"
path += when (targetOs) {
DownloadWebDriver.OS.LINUX -> "linux"
DownloadWebDriver.OS.MAC -> "macos"
DownloadWebDriver.OS.WIN -> "windows"
}
path +=
when (targetOs) {
DownloadWebDriver.OS.LINUX -> "linux"
DownloadWebDriver.OS.MAC -> "macos"
DownloadWebDriver.OS.WIN -> "windows"
}
path += "/"
path += getArchPath(task)
path += "/"
Expand Down Expand Up @@ -64,12 +69,13 @@ subprojects {
val webdriversDir = layout.buildDirectory.dir("webdrivers")
val targetOs = project.extra["targetOs"] as DownloadWebDriver.OS

val downloadTasks = tasks.withType<DownloadWebDriver>().also {
it.configureEach {
configureDownloadTask(webdriversDir.get().asFile, targetOs, this)
webdriverClasspath.from(wdm)
val downloadTasks =
tasks.withType<DownloadWebDriver>().also {
it.configureEach {
configureDownloadTask(webdriversDir.get().asFile, targetOs, this)
webdriverClasspath.from(wdm)
}
}
}

sourceSets["main"].output.dir(mapOf("builtBy" to downloadTasks), webdriversDir)

Expand All @@ -90,8 +96,7 @@ fun Project.zapAddOn(configure: AddOnPluginExtension.() -> Unit): Unit =
fun AddOnPluginExtension.manifest(configure: ManifestExtension.() -> Unit): Unit =
(this as ExtensionAware).extensions.configure("manifest", configure)

fun Project.crowdin(configure: CrowdinExtension.() -> Unit): Unit =
(this as ExtensionAware).extensions.configure("crowdin", configure)
fun Project.crowdin(configure: CrowdinExtension.() -> Unit): Unit = (this as ExtensionAware).extensions.configure("crowdin", configure)

val Project.crowdin: CrowdinExtension get() =
(this as ExtensionAware).extensions.getByName("crowdin") as CrowdinExtension
18 changes: 9 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ import org.zaproxy.gradle.spotless.ValidateImports

plugins {
id("com.diffplug.spotless")
id("org.zaproxy.common") version "0.2.0" apply false
id("org.zaproxy.common") version "0.3.0" apply false
id("com.github.ben-manes.versions") version "0.50.0"
id("org.sonarqube") version "4.3.0.3225"
id("net.ltgt.errorprone") version "3.1.0"
}

apply(from = "$rootDir/gradle/ci.gradle.kts")

val validateImports = ValidateImports(
mapOf(
"import org.apache.commons.lang." to
"Import/use classes from Commons Lang 3, instead of Lang 2.",
),
)
val validateImports =
ValidateImports(
mapOf(
"import org.apache.commons.lang." to
"Import/use classes from Commons Lang 3, instead of Lang 2.",
),
)

allprojects {
apply(plugin = "com.diffplug.spotless")
Expand Down Expand Up @@ -77,5 +78,4 @@ sonarqube {
}
}

fun Project.java(configure: JavaPluginExtension.() -> Unit): Unit =
(this as ExtensionAware).extensions.configure("java", configure)
fun Project.java(configure: JavaPluginExtension.() -> Unit): Unit = (this as ExtensionAware).extensions.configure("java", configure)
6 changes: 3 additions & 3 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
`kotlin-dsl`
id("com.diffplug.spotless") version "6.20.0"
id("org.zaproxy.common") version "0.2.0"
id("com.diffplug.spotless") version "6.25.0"
id("org.zaproxy.common") version "0.3.0"
}

repositories {
Expand All @@ -23,5 +23,5 @@ dependencies {
implementation("io.github.bonigarcia:webdrivermanager:5.7.0") {
exclude("com.fasterxml.jackson.core")
}
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.20.0")
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0")
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=c16d517b50dd28b3f5838f0e844b7520b8f1eb610f2f29de7e4e04a1b7c9c79b
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
distributionSha256Sum=f8b4f4772d302c8ff580bc40d0f56e715de69b163546944f787c87abf209c961
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down
Loading

0 comments on commit 994b326

Please sign in to comment.