Skip to content

Commit

Permalink
Remove project from task extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Clayton Walker committed May 31, 2024
1 parent f2b7bcb commit dd353f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class JavaGeneratorPlugin implements Plugin<Project> {
@Override
public void apply(Project project) {
// create an extension for the plugin
project.getExtensions().create(JavaGeneratorPluginExtension.NAME, JavaGeneratorPluginExtension.class, project);
project.getExtensions().create(JavaGeneratorPluginExtension.NAME, JavaGeneratorPluginExtension.class);
// register tasks
project.getTasks().register(JavaGeneratorCrd2JavaTask.NAME, JavaGeneratorCrd2JavaTask.class,
JavaGeneratorPluginExtension.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.fabric8.java.generator.Config;
import org.gradle.api.Project;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.file.ProjectLayout;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.provider.ListProperty;

Expand All @@ -29,12 +30,12 @@
public abstract class JavaGeneratorPluginExtension {

public static final String NAME = "javaGen";
protected Project gradleProject;
protected final ProjectLayout layout;

private Config javaGeneratorConfig = Config.builder().build();

public JavaGeneratorPluginExtension(Project gradleProject) {
this.gradleProject = gradleProject;
public JavaGeneratorPluginExtension(ProjectLayout layout) {
this.layout = layout;
}

public Config getConfig() {
Expand Down Expand Up @@ -68,7 +69,7 @@ public List<String> getUrlsOrDefault() {

public File getDownloadTargetOrDefault() {
return this.getDownloadTarget().getAsFile()
.getOrElse(this.gradleProject.getLayout().getProjectDirectory()
.getOrElse(layout.getProjectDirectory()
.dir("build")
.dir("crds")
.getAsFile());
Expand All @@ -82,7 +83,7 @@ public File getDownloadTargetOrDefault() {

public File getTargetOrDefault() {
return this.getTarget().getAsFile()
.getOrElse(this.gradleProject.getLayout().getProjectDirectory()
.getOrElse(layout.getProjectDirectory()
.dir("build")
.dir("generated")
.dir("sources").getAsFile());
Expand Down

0 comments on commit dd353f7

Please sign in to comment.