forked from zaproxy/community-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
140 lines (114 loc) · 4.21 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
import org.zaproxy.gradle.addon.AddOnPlugin
import org.zaproxy.gradle.addon.AddOnStatus
import org.zaproxy.gradle.addon.misc.ConvertMarkdownToHtml
import org.zaproxy.gradle.addon.misc.CreateGitHubRelease
import org.zaproxy.gradle.addon.misc.ExtractLatestChangesFromChangelog
plugins {
`java-library`
id("org.zaproxy.add-on") version "0.3.0"
id("com.diffplug.gradle.spotless") version "3.15.0"
}
repositories {
mavenCentral()
}
version = "10"
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.10.0")
addOnStatus.set(AddOnStatus.ALPHA)
releaseLink.set("https://github.com/zaproxy/community-scripts/compare/v@PREVIOUS_VERSION@...v@CURRENT_VERSION@")
unreleasedLink.set("https://github.com/zaproxy/community-scripts/compare/v@CURRENT_VERSION@...HEAD")
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)
}
}
val jupiterVersion = "5.7.0-M1"
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:$jupiterVersion")
testImplementation("org.junit.jupiter:junit-jupiter-params:$jupiterVersion")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$jupiterVersion")
testImplementation("commons-io:commons-io:2.6")
testImplementation("org.assertj:assertj-core:3.11.0")
testImplementation("org.apache.commons:commons-lang3:3.8")
// The following versions should match the ones of the add-ons.
testImplementation("org.codehaus.groovy:groovy-all:2.4.14")
testImplementation("org.jruby:jruby-complete:1.7.4")
testImplementation("org.mozilla:zest:0.14.0")
testImplementation("org.python:jython-standalone:2.7.1")
}
tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
options.compilerArgs = listOf("-Xlint:all", "-Xlint:-options", "-Werror")
}
tasks.withType<Test>().configureEach {
useJUnitPlatform()
}
var scriptTypes = listOf(
"active",
"authentication",
"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)
}
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
sourceSets["main"].output.dir(mapOf("builtBy" to syncScriptsDirTask), scriptsDir)
spotless {
java {
licenseHeaderFile("$rootDir/gradle/spotless/license.java")
googleJavaFormat().aosp()
}
}
System.getenv("GITHUB_REF")?.let { ref ->
if ("refs/tags/" !in ref) {
return@let
}
tasks.register<CreateGitHubRelease>("createReleaseFromGitHubRef") {
val targetTag = ref.removePrefix("refs/tags/")
val targetAddOnVersion = targetTag.removePrefix("v")
authToken.set(System.getenv("GITHUB_TOKEN"))
repo.set(System.getenv("GITHUB_REPOSITORY"))
tag.set(targetTag)
title.set(provider { "Version ${zapAddOn.addOnVersion.get()}" })
bodyFile.set(tasks.named<ExtractLatestChangesFromChangelog>("extractLatestChanges").flatMap { it.latestChanges })
assets {
register("add-on") {
file.set(tasks.named<Jar>(AddOnPlugin.JAR_ZAP_ADD_ON_TASK_NAME).flatMap { it.archiveFile })
}
}
doFirst {
val addOnVersion = zapAddOn.addOnVersion.get()
require(addOnVersion == targetAddOnVersion) {
"Version of the tag $targetAddOnVersion does not match the version of the add-on $addOnVersion"
}
}
}
}