-
-
Notifications
You must be signed in to change notification settings - Fork 239
/
build.gradle.kts
156 lines (132 loc) · 4.65 KB
/
build.gradle.kts
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import org.gradle.api.internal.provider.TransformBackedProvider
import org.zaproxy.gradle.addon.AddOnPlugin
import org.zaproxy.gradle.addon.AddOnStatus
import org.zaproxy.gradle.addon.internal.model.ProjectInfo
import org.zaproxy.gradle.addon.internal.model.ReleaseState
import org.zaproxy.gradle.addon.internal.tasks.GenerateReleaseStateLastCommit
import org.zaproxy.gradle.addon.misc.ConvertMarkdownToHtml
plugins {
`java-library`
id("org.zaproxy.add-on") version "0.11.0"
id("org.zaproxy.crowdin") version "0.4.0"
id("com.diffplug.spotless")
id("com.github.node-gradle.node") version "7.0.2"
id("org.zaproxy.common")
}
description = "Useful ZAP scripts written by the ZAP community."
val scriptsDir = layout.buildDirectory.dir("scripts")
zapAddOn {
addOnId.set("communityScripts")
addOnName.set("Community Scripts")
zapVersion.set("2.15.0")
addOnStatus.set(AddOnStatus.ALPHA)
releaseLink.set("https://github.com/zaproxy/community-scripts/compare/v@[email protected]@CURRENT_VERSION@")
unreleasedLink.set("https://github.com/zaproxy/community-scripts/compare/v@[email protected]")
manifest {
author.set("ZAP Community")
url.set("https://www.zaproxy.org/docs/desktop/addons/community-scripts/")
repo.set("https://github.com/zaproxy/community-scripts/")
changesFile.set(tasks.named<ConvertMarkdownToHtml>("generateManifestChanges").flatMap { it.html })
files.from(scriptsDir)
}
}
crowdin {
credentials {
token.set(System.getenv("CROWDIN_AUTH_TOKEN"))
}
configuration {
file.set(file("gradle/crowdin.yml"))
tokens.set(mutableMapOf("%addOnId%" to zapAddOn.addOnId.get()))
}
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation("commons-io:commons-io:2.16.1")
testImplementation("org.assertj:assertj-core:3.26.0")
testImplementation("org.apache.commons:commons-lang3:3.14.0")
// The following versions should match the ones of the add-ons.
testImplementation("org.codehaus.groovy:groovy-all:3.0.14")
val graalJsVersion = "22.3.3"
testImplementation("org.graalvm.js:js:$graalJsVersion")
testImplementation("org.graalvm.js:js-scriptengine:$graalJsVersion")
testImplementation("org.jruby:jruby-complete:1.7.4")
testImplementation("org.zaproxy:zest:0.21.0")
testImplementation("org.python:jython-standalone:2.7.2")
}
tasks.withType<Test>().configureEach {
useJUnitPlatform()
}
var scriptTypes =
listOf(
"active",
"authentication",
"encode-decode",
"extender",
"httpfuzzerprocessor",
"httpsender",
"passive",
"payloadgenerator",
"payloadprocessor",
"proxy",
"selenium",
"sequence",
"session",
"standalone",
"targeted",
"variant",
"websocketfuzzerprocessor",
"websocketpassive",
)
val syncScriptsDirTask by tasks.creating(Sync::class) {
into(scriptsDir.get().dir(project.name))
scriptTypes.forEach {
from(it) {
into(it)
}
}
}
tasks.named(AddOnPlugin.GENERATE_MANIFEST_TASK_NAME) {
dependsOn(syncScriptsDirTask)
}
java {
val javaVersion = JavaVersion.VERSION_11
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
sourceSets["main"].output.dir(mapOf("builtBy" to syncScriptsDirTask), scriptsDir)
node {
version = "20.12.1"
download = true
}
spotless {
kotlinGradle {
ktlint()
}
javascript {
target("**/*.js")
targetExclude("extender/HTTP Message Logger.js", "extender/ScanMonitor.js", "standalone/domainFinder.js")
// get the npm executable path from gradle-node-plugin
val npmDir = (tasks.named("npmSetup").get().property("npmDir") as TransformBackedProvider<*, *>).get().toString()
val npmExecutable = if (System.getProperty("os.name").lowercase().contains("windows")) "/npm.cmd" else "/bin/npm"
prettier().npmExecutable(npmDir.plus(npmExecutable))
}
}
tasks.named("spotlessJavascript").configure {
dependsOn("nodeSetup", "npmSetup")
}
val projectInfo = ProjectInfo.from(project)
val generateReleaseStateLastCommit by tasks.registering(GenerateReleaseStateLastCommit::class) {
projects.set(listOf(projectInfo))
}
repositories {
mavenCentral()
}
val releaseAddOn by tasks.registering {
if (ReleaseState.read(projectInfo).isNewRelease()) {
dependsOn("createRelease")
dependsOn("handleRelease")
dependsOn("createPullRequestNextDevIter")
dependsOn("crowdinUploadSourceFiles")
}
}