diff --git a/build-logic/build.gradle b/build-logic/build.gradle new file mode 100644 index 0000000..9478b37 --- /dev/null +++ b/build-logic/build.gradle @@ -0,0 +1,7 @@ +plugins { + id 'groovy-gradle-plugin' +} + +dependencies { + implementation(gradleApi()) +} diff --git a/build-logic/settings.gradle b/build-logic/settings.gradle new file mode 100644 index 0000000..7fbbd44 --- /dev/null +++ b/build-logic/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "build-logic" diff --git a/buildSrc/src/main/groovy/io.micronaut.build.internal.fuzzing-base.gradle b/build-logic/src/main/groovy/io.micronaut.build.internal.fuzzing-base.gradle similarity index 100% rename from buildSrc/src/main/groovy/io.micronaut.build.internal.fuzzing-base.gradle rename to build-logic/src/main/groovy/io.micronaut.build.internal.fuzzing-base.gradle diff --git a/build-logic/src/main/groovy/io.micronaut.build.internal.fuzzing-model.gradle b/build-logic/src/main/groovy/io.micronaut.build.internal.fuzzing-model.gradle new file mode 100644 index 0000000..c55ed68 --- /dev/null +++ b/build-logic/src/main/groovy/io.micronaut.build.internal.fuzzing-model.gradle @@ -0,0 +1,13 @@ +import io.micronaut.build.internal.tasks.GenerateModelClasses + +def generateModel = tasks.register("generateModel", GenerateModelClasses) { + group = "build" + description = "Generate the model for the fuzzing module" + outputDirectory = layout.buildDirectory.dir("generated/sources/model") +} + +sourceSets { + main { + java.srcDir(generateModel) + } +} diff --git a/buildSrc/src/main/groovy/io.micronaut.build.internal.fuzzing-module.gradle b/build-logic/src/main/groovy/io.micronaut.build.internal.fuzzing-module.gradle similarity index 100% rename from buildSrc/src/main/groovy/io.micronaut.build.internal.fuzzing-module.gradle rename to build-logic/src/main/groovy/io.micronaut.build.internal.fuzzing-module.gradle diff --git a/build-logic/src/main/java/io/micronaut/build/internal/tasks/GenerateModelClasses.java b/build-logic/src/main/java/io/micronaut/build/internal/tasks/GenerateModelClasses.java new file mode 100644 index 0000000..962ecfc --- /dev/null +++ b/build-logic/src/main/java/io/micronaut/build/internal/tasks/GenerateModelClasses.java @@ -0,0 +1,60 @@ +/* + * Copyright 2003-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.micronaut.build.internal.tasks; + +import org.gradle.api.DefaultTask; +import org.gradle.api.file.DirectoryProperty; +import org.gradle.api.provider.Property; +import org.gradle.api.tasks.Input; +import org.gradle.api.tasks.OutputDirectory; +import org.gradle.api.tasks.TaskAction; + +import java.io.IOException; +import java.io.PrintWriter; +import java.nio.file.Files; + +public abstract class GenerateModelClasses extends DefaultTask { + @OutputDirectory + public abstract DirectoryProperty getOutputDirectory(); + + @Input + public abstract Property getPackageName(); + + @TaskAction + public void generateModelClasses() throws IOException { + var packageName = getPackageName().get(); + var packageDir = + getOutputDirectory().get().getAsFile().toPath().resolve(packageName.replace('.', '/')); + Files.createDirectories(packageDir); + var model = packageDir.resolve("DefinedFuzzTarget.java"); + try (var writer = new PrintWriter(Files.newBufferedWriter(model))) { + writer.println("package " + packageName + ";"); + writer.println(); + writer.println(""" + import java.util.List; + + public record DefinedFuzzTarget( + String targetClass, + List dictionary, + List dictionaryResources, + boolean enableImplicitly + ) { + public static final String DIRECTORY = "io.micronaut.fuzzing.fuzz-targets"; + } + """); + } + } +} diff --git a/build.gradle b/build.gradle.kts similarity index 54% rename from build.gradle rename to build.gradle.kts index 2f92fda..291801e 100644 --- a/build.gradle +++ b/build.gradle.kts @@ -1,17 +1,17 @@ plugins { - id "io.micronaut.build.internal.docs" - id "io.micronaut.build.internal.quality-reporting" + id("io.micronaut.build.internal.docs") + id("io.micronaut.build.internal.quality-reporting") } // These tasks are used in the release workflow, but the jazzer plugin is an included build -["publishAllPublicationsToBuildRepository", "publishToSonatype", "closeAndReleaseSonatypeStagingRepository"].each {t -> +listOf("publishAllPublicationsToBuildRepository", "publishToSonatype", "closeAndReleaseSonatypeStagingRepository").forEach {t -> if (tasks.names.find { it == t } == null) { tasks.register(t) { - dependsOn(gradle.includedBuilds.find { it.name == "micronaut-jazzer-plugin" }.task(":$t")) + dependsOn(gradle.includedBuilds.find { it.name == "micronaut-jazzer-plugin" }?.task(":$t")) } } else { tasks.named(t) { - dependsOn(gradle.includedBuilds.find { it.name == "micronaut-jazzer-plugin" }.task(":$t")) + dependsOn(gradle.includedBuilds.find { it.name == "micronaut-jazzer-plugin" }?.task(":$t")) } } } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle deleted file mode 100644 index 6784052..0000000 --- a/buildSrc/build.gradle +++ /dev/null @@ -1,3 +0,0 @@ -plugins { - id 'groovy-gradle-plugin' -} diff --git a/fuzzing-annotation-processor/build.gradle.kts b/fuzzing-annotation-processor/build.gradle.kts index 259f96c..fafb047 100644 --- a/fuzzing-annotation-processor/build.gradle.kts +++ b/fuzzing-annotation-processor/build.gradle.kts @@ -1,5 +1,8 @@ +import io.micronaut.build.internal.tasks.GenerateModelClasses + plugins { id("io.micronaut.build.internal.fuzzing-module") + id("io.micronaut.build.internal.fuzzing-model") } dependencies { @@ -9,3 +12,9 @@ dependencies { testImplementation(mn.micronaut.inject.java.test) } + +tasks { + generateModel { + packageName = "io.micronaut.fuzzing.processor" + } +} diff --git a/fuzzing-annotation-processor/src/main/java/io/micronaut/fuzzing/processor/DefinedFuzzTarget.java b/fuzzing-annotation-processor/src/main/java/io/micronaut/fuzzing/processor/DefinedFuzzTarget.java deleted file mode 100644 index cea5136..0000000 --- a/fuzzing-annotation-processor/src/main/java/io/micronaut/fuzzing/processor/DefinedFuzzTarget.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2017-2025 original authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.micronaut.fuzzing.processor; - -import java.util.List; - -// TODO: this is symlinked to the plugin project... find a better way to share it -public record DefinedFuzzTarget( - String targetClass, - List dictionary, - List dictionaryResources, - boolean enableImplicitly -) { - public static final String DIRECTORY = "io.micronaut.fuzzing.fuzz-targets"; -} diff --git a/fuzzing-tests/build.gradle.kts b/fuzzing-tests/build.gradle.kts index 634e139..0ad0f1a 100644 --- a/fuzzing-tests/build.gradle.kts +++ b/fuzzing-tests/build.gradle.kts @@ -18,15 +18,15 @@ dependencies { implementation(mn.micronaut.jackson.databind) implementation(mn.reactor) - implementation("ch.qos.logback:logback-classic:1.4.14") + implementation(mnLogging.logback.classic) implementation(projects.micronautFuzzingApi) annotationProcessor(mn.micronaut.inject.java) annotationProcessor(projects.micronautFuzzingAnnotationProcessor) - testImplementation("org.junit.jupiter:junit-jupiter-engine:5.11.4") - testImplementation("org.junit.jupiter:junit-jupiter-params:5.11.4") + testImplementation(mnTest.junit.jupiter.engine) + testImplementation(mnTest.junit.jupiter.params) testImplementation(mn.micronaut.http.client) testImplementation(mnTest.micronaut.test.junit5) testAnnotationProcessor(mn.micronaut.inject.java) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 07bc397..2ad4e34 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -18,7 +18,8 @@ [versions] micronaut = "4.7.5" micronaut-docs = "2.0.0" -micronaut-test = "4.1.0" +micronaut-test = "4.6.2" +micronaut-logging = "1.5.1" groovy = "4.0.15" spock = "2.3-groovy-4.0" @@ -31,7 +32,7 @@ managed-jazzer = "0.23.0" [libraries] # Core micronaut-core = { module = 'io.micronaut:micronaut-core-bom', version.ref = 'micronaut' } - +micronaut-logging = { module = "io.micronaut.logging:micronaut-logging-bom", version.ref = "micronaut-logging" } # # Managed dependencies appear in the BOM # diff --git a/jazzer-plugin/build.gradle.kts b/jazzer-plugin/build.gradle.kts index 7ba41fd..9579545 100644 --- a/jazzer-plugin/build.gradle.kts +++ b/jazzer-plugin/build.gradle.kts @@ -1,6 +1,7 @@ plugins { id("java-gradle-plugin") id("io.micronaut.build.internal.publishing") + id("io.micronaut.build.internal.fuzzing-model") } repositories { @@ -8,15 +9,19 @@ repositories { } dependencies { - // todo: bom dependencies - implementation("com.fasterxml.jackson.core:jackson-databind:2.18.2") + implementation(mn.jackson.databind) - testImplementation("org.junit.jupiter:junit-jupiter:5.11.4") - testImplementation("org.junit.jupiter:junit-jupiter-engine:5.11.4") + testImplementation(mnTest.junit.jupiter.api) + testImplementation(mnTest.junit.jupiter.engine) } -tasks.test { - useJUnitPlatform() +tasks{ + test { + useJUnitPlatform() + } + generateModel { + packageName = "io.micronaut.fuzzing.model" + } } gradlePlugin { diff --git a/jazzer-plugin/gradle.properties b/jazzer-plugin/gradle.properties index af041f8..88aa7ba 100644 --- a/jazzer-plugin/gradle.properties +++ b/jazzer-plugin/gradle.properties @@ -1 +1,3 @@ projectDesc=A Gradle plugin integrating with Jazzer +micronautVersion=4.7.1 +micronautTestVersion=4.6.2 diff --git a/jazzer-plugin/settings.gradle.kts b/jazzer-plugin/settings.gradle.kts index 217521f..e59acf5 100644 --- a/jazzer-plugin/settings.gradle.kts +++ b/jazzer-plugin/settings.gradle.kts @@ -1,3 +1,7 @@ +pluginManagement { + includeBuild("../build-logic") +} + rootProject.name = "micronaut-jazzer-plugin" plugins { @@ -6,7 +10,7 @@ plugins { enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") -configure { - useStandardizedProjectNames = false +micronautBuild { + useStandardizedProjectNames = true importMicronautCatalog() } diff --git a/jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/BaseJazzerTask.java b/jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/BaseJazzerTask.java index 4c8b32c..da704b9 100644 --- a/jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/BaseJazzerTask.java +++ b/jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/BaseJazzerTask.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import io.micronaut.fuzzing.processor.DefinedFuzzTarget; +import io.micronaut.fuzzing.model.DefinedFuzzTarget; import org.gradle.api.DefaultTask; import org.gradle.api.file.ConfigurableFileCollection; import org.gradle.api.provider.ListProperty; diff --git a/jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/JazzerTask.java b/jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/JazzerTask.java index 881dce8..5b64560 100644 --- a/jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/JazzerTask.java +++ b/jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/JazzerTask.java @@ -1,6 +1,6 @@ package io.micronaut.fuzzing.jazzer; -import io.micronaut.fuzzing.processor.DefinedFuzzTarget; +import io.micronaut.fuzzing.model.DefinedFuzzTarget; import org.gradle.api.file.DirectoryProperty; import org.gradle.api.file.RegularFileProperty; import org.gradle.api.provider.Property; diff --git a/jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/PrepareClusterFuzzTask.java b/jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/PrepareClusterFuzzTask.java index 69cd33d..6b4820c 100644 --- a/jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/PrepareClusterFuzzTask.java +++ b/jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/PrepareClusterFuzzTask.java @@ -1,6 +1,6 @@ package io.micronaut.fuzzing.jazzer; -import io.micronaut.fuzzing.processor.DefinedFuzzTarget; +import io.micronaut.fuzzing.model.DefinedFuzzTarget; import org.gradle.api.Action; import org.gradle.api.file.DirectoryProperty; import org.gradle.api.provider.SetProperty; diff --git a/jazzer-plugin/src/main/java/io/micronaut/fuzzing/processor/DefinedFuzzTarget.java b/jazzer-plugin/src/main/java/io/micronaut/fuzzing/processor/DefinedFuzzTarget.java deleted file mode 120000 index fe10ba5..0000000 --- a/jazzer-plugin/src/main/java/io/micronaut/fuzzing/processor/DefinedFuzzTarget.java +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../fuzzing-annotation-processor/src/main/java/io/micronaut/fuzzing/processor/DefinedFuzzTarget.java \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 3d0da2e..6caf325 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -3,6 +3,7 @@ pluginManagement { gradlePluginPortal() mavenCentral() } + includeBuild("build-logic") includeBuild("jazzer-plugin") { name = "micronaut-jazzer-plugin" } @@ -20,10 +21,9 @@ include("fuzzing-tests") enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") -configure { +micronautBuild { useStandardizedProjectNames = true importMicronautCatalog() - requiresDevelopmentVersion("micronaut-core", "4.8.x") }