Skip to content

Commit

Permalink
Remove Ant build and set up Gradle build
Browse files Browse the repository at this point in the history
Remove Ant build files and libraries (`build` directory), the add-ons
will be built with Gradle.
Remove Eclipse files (`.classpath` and `.project`), they are generated
when the project is imported to Eclipse.
Remove all main libraries (`lib` directory) except fuzz add-on, they
will be obtained from Maven repository (Maven Central by default).
Rename the fuzz add-on to have `jar` extension (to be properly consumed
by IDEs).
Add Gradle wrapper and main build files.
Add top level project, `addOns`, to contain and configure the add-ons.
Each add-on will be relocated to be under `addOns` and have the
following directory layout:
 - `src/main/java/` for main Java source files;
 - `src/main/resources/` for main resource files;
 - `src/main/javahelp/` for JavaHelp files;
 - `src/main/zapHomeFiles/` for home files;
 - `src/test/java/` for test Java source files;
 - `src/test/resources/` for test resource files.

Update Travis CI configuration file for Gradle build.
Update `.gitignore` for Gradle and common IDE files.
Update `README.md` with instructions on how to build the add-ons.
Move example add-on manifest (`ZapAddOn.xml`) to top level directory
`docs`.
  • Loading branch information
thc202 committed Apr 3, 2019
1 parent 0ceff13 commit 1349779
Show file tree
Hide file tree
Showing 48 changed files with 491 additions and 688 deletions.
39 changes: 0 additions & 39 deletions .classpath

This file was deleted.

45 changes: 33 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
# Intellij
.idea/
*.iml
*.iws
*.eml
out/
/bin/
build/build/
build/buildtest/
build/results/
build/temp/
build/zap-exts/
# Gradle
#-------
.gradle
/build
/buildSrc/build
/addOns/**/build

# IDEA
# ----
.idea
.shelf
/*.iml
/*.ipr
/*.iws
/buildSrc/*.iml
/buildSrc/*.ipr
/buildSrc/*.iws
/buildSrc/out
/out

# Eclipse
# -------
*.classpath
*.project
*.settings
/bin
/buildSrc/bin
/addOns/**/bin

# NetBeans
# --------
.nb-gradle
.nb-gradle-properties
17 changes: 0 additions & 17 deletions .project

This file was deleted.

11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
language: java
script: ant -buildfile build/build.xml test

jdk:
- oraclejdk8
- openjdk11

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/

cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.m2/repository/webdriver/
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,21 @@ If you are using the latest version of ZAP then you can browse and download add-
You can also import add-ons you have downloaded manually from https://github.com/zaproxy/zap-extensions/releases via the "File / Load Add-on File..." menu option.

Please see the [wiki](https://github.com/zaproxy/zap-extensions/wiki) for more details.

## Building

The add-ons are built with [Gradle], each add-on has its own project which is located under the `addOns` project/directory.

To build all add-ons, simply run:

./gradlew build

in the main directory of the project, the add-ons will be placed in the directory `build/zapAddOn/bin/` of each project.

To build an add-on individually run:

./gradlew :addOns:<name>:build

replacing `<name>` with the name of the add-on (e.g. `reveal`).

[Gradle]: https://gradle.org/
101 changes: 101 additions & 0 deletions addOns/addOns.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import org.zaproxy.gradle.addon.AddOnPlugin
import org.zaproxy.gradle.addon.AddOnPluginExtension
import org.zaproxy.gradle.addon.manifest.ManifestExtension
import org.zaproxy.gradle.addon.manifest.tasks.ConvertChangelogToChanges
import org.zaproxy.gradle.addon.wiki.WikiGenExtension
import org.zaproxy.gradle.addon.zapversions.ZapVersionsExtension

plugins {
id("org.zaproxy.add-on") version "0.1.0" apply false
}

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

val zapCoreHelpWikiDir = "$rootDir/../zap-core-help-wiki/"
val zapExtensionsWikiDir = "$rootDir/../zap-extensions-wiki/"

val parentProjects = listOf(
)

val mainAddOns = listOf(
)
val weeklyAddOns = mainAddOns + listOf(
)

mapOf("main" to mainAddOns, "weekly" to weeklyAddOns).forEach { entry ->
tasks {
val name = entry.key
val nameCapitalized = name.capitalize()
register("copy${nameCapitalized}AddOns") {
group = "ZAP"
description = "Copies the $name release add-ons to zaproxy project."
subprojects(entry.value) {
dependsOn(it.tasks.named(AddOnPlugin.COPY_ADD_ON_TASK_NAME))
}
}

register("list${nameCapitalized}AddOns") {
group = "ZAP"
description = "Lists the $name release add-ons."
doLast {
subprojects(entry.value) { println(it.name) }
}
}
}
}

subprojects {
if (parentProjects.contains(project.name)) {
return@subprojects
}

apply(plugin = "java-library")
apply(plugin = "org.zaproxy.add-on")

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

val generateManifestChanges by tasks.registering(ConvertChangelogToChanges::class) {
changelog.set(file("CHANGELOG.md"))
manifestChanges.set(file("$buildDir/zapAddOn/manifest-changes.html"))
}

zapAddOn {
manifest {
changesFile.set(generateManifestChanges.flatMap { it.manifestChanges })
}

wikiGen {
wikiFilesPrefix.set("HelpAddons${zapAddOn.addOnId.get().capitalize()}")
wikiDir.set(project.provider { project.layout.projectDirectory.dir(if (mainAddOns.contains(zapAddOn.addOnId.get())) zapCoreHelpWikiDir else zapExtensionsWikiDir) })
}

zapVersions {
downloadUrl.set("https://github.com/zaproxy/zap-extensions/releases/download/2.7")
}
}
}

fun subprojects(addOns: List<String>, action: (Project) -> Unit) {
subprojects.filter { !parentProjects.contains(it.name) && addOns.contains(it.zapAddOn.addOnId.get()) }.forEach(action)
}

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

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

val Project.zapAddOn: AddOnPluginExtension get() =
(this as ExtensionAware).extensions.getByName("zapAddOn") as AddOnPluginExtension

fun AddOnPluginExtension.manifest(configure: ManifestExtension.() -> Unit): Unit =
(this as ExtensionAware).extensions.configure("manifest", configure)

fun AddOnPluginExtension.wikiGen(configure: WikiGenExtension.() -> Unit): Unit =
(this as ExtensionAware).extensions.configure("wikiGen", configure)

fun AddOnPluginExtension.zapVersions(configure: ZapVersionsExtension.() -> Unit): Unit =
(this as ExtensionAware).extensions.configure("zapVersions", configure)
22 changes: 22 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins {
id("com.diffplug.gradle.spotless") version "3.20.0"
}

allprojects {
apply(plugin = "com.diffplug.gradle.spotless")

repositories {
mavenCentral()
}

spotless {
kotlinGradle {
ktlint()
}
}

tasks.withType<JavaCompile>().configureEach {
options.encoding = "utf-8"
options.compilerArgs = listOf("-Xlint:all", "-Xlint:-path", "-Xlint:-options", "-Werror")
}
}
2 changes: 0 additions & 2 deletions build/.gitignore

This file was deleted.

Loading

0 comments on commit 1349779

Please sign in to comment.