Skip to content

Commit

Permalink
Workaround for #1193
Browse files Browse the repository at this point in the history
  • Loading branch information
larsgrefer committed Oct 10, 2024
1 parent 87051cf commit ccea540
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,24 +153,6 @@ private void handleLombokConfig(SourceSet sourceSet, TaskProvider<JavaCompile> c

TaskProvider<LombokConfig> lombokConfigTask = ConfigUtil.getLombokConfigTask(project, sourceSet);

// Workaround https://github.com/freefair/gradle-plugins/issues/1193
if (sourceSet.getName().equals("contractTest")) {
project.getTasks().configureEach(task -> {
if (task.getName().equals("generateContractTests")) {
lombokConfigTask.get().mustRunAfter(task);
}
});
}

// Workaround https://github.com/freefair/gradle-plugins/issues/1193
if (sourceSet.getName().equals("main")) {
project.getTasks().configureEach(task -> {
if (task.getName().equals("openApiGenerate")) {
lombokConfigTask.get().mustRunAfter(task);
}
});
}

compileTaskProvider.configure(javaCompile -> {
javaCompile.getInputs().file(lombokConfigTask.get().getOutputFile())
.withPropertyName("lombok.config")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.FileSystemOperations;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.internal.file.FileOperations;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Optional;
Expand Down Expand Up @@ -43,6 +44,9 @@ public abstract class LombokConfig extends DefaultTask implements LombokTask {
@Inject
protected abstract FileSystemOperations getFileSystemOperations();

@Inject
protected abstract FileOperations getFileOperations();

@Inject
protected abstract ExecOperations getExecOperations();

Expand Down Expand Up @@ -81,8 +85,7 @@ public abstract class LombokConfig extends DefaultTask implements LombokTask {
/**
* Paths to java files or directories the configuration is to be printed for.
*/
@InputFiles
@PathSensitive(PathSensitivity.RELATIVE)
@Internal
public abstract ConfigurableFileCollection getPaths();

@OutputFile
Expand All @@ -100,6 +103,19 @@ public LombokConfig() {
getOutputs().doNotCacheIf("Config Imports were used", t -> ((LombokConfig) t).getConfigFiles() == null);
}

@Input
protected Set<String> getInputPaths() {
HashSet<String> paths = new HashSet<>();
for (File path : getPaths()) {
try {
paths.add(getFileOperations().relativePath(path));
} catch (Exception e) {
paths.add(path.toString());
}
}
return paths;
}

@InputFiles
@Optional
@Nullable
Expand Down Expand Up @@ -181,13 +197,11 @@ public void exec() throws IOException {
Duration duration = Duration.ofNanos(System.nanoTime() - start);
if (duration.getSeconds() > 1) {
getLogger().warn("lombok config {} took {}ms", args, duration.toMillis());
}
else {
} else {
getLogger().info("lombok config {} took {}ms", args, duration.toMillis());
}
}
}
else {
} else {
getWorkerExecutor()
.classLoaderIsolation(cl -> cl.getClasspath().from(getLombokClasspath()))
.submit(LombokConfigAction.class, params -> {
Expand Down

0 comments on commit ccea540

Please sign in to comment.