From 0f6979e5bf13edb6b48be50bdfe3402a50a5a8ad Mon Sep 17 00:00:00 2001 From: Robert Czechowski Date: Fri, 20 Dec 2024 09:54:30 +0100 Subject: [PATCH] ci: Build sources and docs jar for jazzer-api and jazzer-junit for maven deployment --- deploy/BUILD.bazel | 7 +++++-- deploy/deploy.sh | 14 +++++++++++--- .../com/code_intelligence/jazzer/junit/BUILD.bazel | 13 +++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/deploy/BUILD.bazel b/deploy/BUILD.bazel index 99b9270fe..c4ed5f883 100644 --- a/deploy/BUILD.bazel +++ b/deploy/BUILD.bazel @@ -38,7 +38,6 @@ java_export( ], maven_coordinates = "com.code-intelligence:jazzer-api:$(JAZZER_VERSION)", pom_template = "//deploy:jazzer-api.pom", - tags = ["no-sources"], toolchains = [":jazzer_version"], visibility = ["//visibility:public"], runtime_deps = ["//src/main/java/com/code_intelligence/jazzer/api"], @@ -71,6 +70,11 @@ alias( actual = "//src/main/java/com/code_intelligence/jazzer:jazzer-sources", ) +alias( + name = "jazzer-junit-docs", + actual = "//src/main/java/com/code_intelligence/jazzer/junit:jazzer-junit-docs", +) + java_export( name = "jazzer-junit", # Exclude the unshaded classes comprising com.code-intelligence:jazzer since the java_library @@ -90,7 +94,6 @@ java_export( maven_coordinates = "com.code-intelligence:jazzer-junit:$(JAZZER_VERSION)", pom_template = "jazzer-junit.pom", tags = [ - "no-sources", # Generating javadocs breaks the build due to weird dependency issues. # Deactivate it for now. "no-javadocs", diff --git a/deploy/deploy.sh b/deploy/deploy.sh index ccaa86d9e..310f7190c 100755 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -67,12 +67,20 @@ JAZZER_DOCS_PATH=$PWD/$(bazel cquery --output=files //deploy:jazzer-docs) JAZZER_SOURCES_PATH=$PWD/$(bazel cquery --output=files //deploy:jazzer-sources) JAZZER_POM_PATH=$PWD/$(bazel cquery --output=files //deploy:jazzer-pom) +## For Junit we currently have to do similar tricks because the docs will not build automatically +bazel build //deploy:jazzer-junit //deploy:jazzer-junit-docs //deploy:jazzer-junit-sources //deploy:jazzer-junit-pom + +JAZZER_JUNIT_JAR_PATH=$PWD/$(bazel cquery --output=files //deploy:jazzer-junit-maven-artifact) +JAZZER_JUNIT_DOCS_PATH=$PWD/$(bazel cquery --output=files //deploy:jazzer-junit-docs) +JAZZER_JUNIT_SOURCES_PATH=$PWD/$(bazel cquery --output=files //deploy:jazzer-junit-maven-source) +JAZZER_JUNIT_POM_PATH=$PWD/$(bazel cquery --output=files //deploy:jazzer-junit-pom) + bazel run --define "maven_repo=${MAVEN_REPO}" --define "maven_user=${MAVEN_USER}" \ --define "maven_password=${MAVEN_PASSWORD}" --define gpg_sign=true \ //deploy:jazzer-api.publish MAVEN_REPO="$MAVEN_REPO" GPG_SIGN="true" MAVEN_USER="$MAVEN_USER" MAVEN_PASSWORD="$MAVEN_PASSWORD" \ bazel run @rules_jvm_external//private/tools/java/com/github/bazelbuild/rules_jvm_external/maven:MavenPublisher -- \ "$JAZZER_COORDINATES" "$JAZZER_POM_PATH" "$JAZZER_JAR_PATH" "sources=${JAZZER_SOURCES_PATH},javadoc=${JAZZER_DOCS_PATH}" -bazel run --define "maven_repo=${MAVEN_REPO}" --define "maven_user=${MAVEN_USER}" \ - --define "maven_password=${MAVEN_PASSWORD}" --define gpg_sign=true \ - //deploy:jazzer-junit.publish +MAVEN_REPO="$MAVEN_REPO" GPG_SIGN="true" MAVEN_USER="$MAVEN_USER" MAVEN_PASSWORD="$MAVEN_PASSWORD" \ + bazel run @rules_jvm_external//private/tools/java/com/github/bazelbuild/rules_jvm_external/maven:MavenPublisher -- \ + "$JAZZER_COORDINATES" "$JAZZER_JUNIT_POM_PATH" "$JAZZER_JUNIT_JAR_PATH" "sources=${JAZZER_JUNIT_SOURCES_PATH},javadoc=${JAZZER_JUNIT_DOCS_PATH}" diff --git a/src/main/java/com/code_intelligence/jazzer/junit/BUILD.bazel b/src/main/java/com/code_intelligence/jazzer/junit/BUILD.bazel index 613862316..8c80e9034 100644 --- a/src/main/java/com/code_intelligence/jazzer/junit/BUILD.bazel +++ b/src/main/java/com/code_intelligence/jazzer/junit/BUILD.bazel @@ -1,4 +1,5 @@ load("@rules_jni//jni:defs.bzl", "java_jni_library") +load("@rules_jvm_external//:defs.bzl", "javadoc") java_library( name = "junit", @@ -174,3 +175,15 @@ java_library( "@maven//:org_junit_jupiter_junit_jupiter_params", ], ) + +javadoc( + name = "jazzer-junit-docs", + doc_deps = ["//deploy:jazzer-api-docs"], + doc_url = "https://codeintelligencetesting.github.io/jazzer-docs/jazzer-junit/", + javadocopts = [ + "-link", + "https://docs.oracle.com/en/java/javase/17/docs/api/", + ], + visibility = ["//deploy:__pkg__"], + deps = [":fuzz_test"], +)