HHH-13870 - Extract task action in Gradle plugin to fix up-to-date checks

Lambdas are not allowed and cause the compile task to be always out of date
This commit is contained in:
Christoph Dreis 2020-02-19 16:18:03 +01:00 committed by Steve Ebersole
parent 1042f23bee
commit 5ea5bd12b0
1 changed files with 23 additions and 3 deletions

View File

@ -6,6 +6,7 @@
*/
package org.hibernate.orm.tooling.gradle;
import org.gradle.api.Action;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
@ -43,10 +44,29 @@ public class HibernatePlugin implements Plugin<Project> {
final Task compileTask = project.getTasks().findByName( sourceSet.getCompileJavaTaskName() );
assert compileTask != null;
compileTask.doLast(
task -> EnhancementHelper.enhance( sourceSet, hibernateExtension.enhance, project )
);
compileTask.doLast(new EnhancerAction( sourceSet, hibernateExtension, project ));
}
}
private static class EnhancerAction implements Action<Task> {
private final SourceSet sourceSet;
private final HibernateExtension hibernateExtension;
private final Project project;
private EnhancerAction(SourceSet sourceSet, HibernateExtension hibernateExtension, Project project) {
this.sourceSet = sourceSet;
this.hibernateExtension = hibernateExtension;
this.project = project;
}
@Override
public void execute(Task task) {
EnhancementHelper.enhance( sourceSet, hibernateExtension.enhance, project );
}
}
}