generated from micronaut-projects/micronaut-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit reworks how the model class is "shared" between the annotation processor and the jazzer plugin. Instead of using a symlink, the code is now generated by a common build plugin. In practice, the 2 modules use the same record, but in a different package. It's also cleaner in the sense that there's no dependency between the plugin and the annotation processor, which would have led to too many classes on classpath. Fixes #101
- Loading branch information
Showing
20 changed files
with
125 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
plugins { | ||
id 'groovy-gradle-plugin' | ||
} | ||
|
||
dependencies { | ||
implementation(gradleApi()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name = "build-logic" |
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
build-logic/src/main/groovy/io.micronaut.build.internal.fuzzing-model.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
File renamed without changes.
60 changes: 60 additions & 0 deletions
60
build-logic/src/main/java/io/micronaut/build/internal/tasks/GenerateModelClasses.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> 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<String> dictionary, | ||
List<String> dictionaryResources, | ||
boolean enableImplicitly | ||
) { | ||
public static final String DIRECTORY = "io.micronaut.fuzzing.fuzz-targets"; | ||
} | ||
"""); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")) | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
...-annotation-processor/src/main/java/io/micronaut/fuzzing/processor/DefinedFuzzTarget.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
projectDesc=A Gradle plugin integrating with Jazzer | ||
micronautVersion=4.7.1 | ||
micronautTestVersion=4.6.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/JazzerTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/PrepareClusterFuzzTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
jazzer-plugin/src/main/java/io/micronaut/fuzzing/processor/DefinedFuzzTarget.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters