fix aggregateJavadoc destinationDir
package io.freefair.gradle.plugins.maven.javadoc;
-import java.io.File;
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
import lombok.Getter;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
@@ -17,6 +11,10 @@ import org.gradle.api.tasks.TaskProvider;
import org.gradle.api.tasks.javadoc.Javadoc;
import org.gradle.external.javadoc.StandardJavadocDocletOptions;
+import java.io.File;
+import java.util.Optional;
+import java.util.concurrent.Callable;
+
@Getter
public class AggregateJavadocPlugin implements Plugin<Project> {
@@ -24,9 +22,19 @@ public class AggregateJavadocPlugin implements Plugin<Project> {
@Override
public void apply(Project project) {
- aggregateJavadoc = project.getTasks().register("aggregateJavadoc", Javadoc.class, aggregateJavadoc ->
- aggregateJavadoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP)
- );
+
+ aggregateJavadoc = project.getTasks().register("aggregateJavadoc", Javadoc.class, aggregateJavadoc -> {
+ aggregateJavadoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);
+ aggregateJavadoc.getConventionMapping().map("destinationDir", new Callable<Object>() {
+ @Override
+ public Object call() {
+ File docsDir = Optional.ofNullable(project.getConvention().findPlugin(JavaPluginConvention.class))
+ .map(JavaPluginConvention::getDocsDir)
+ .orElse(new File(project.getBuildDir(), "docs"));
+ return new File(docsDir, "aggregateJavadoc");
+ }
+ });
+ });
project.allprojects(p ->
p.getPlugins().withType(JavaPlugin.class, jp ->
@@ -66,15 +74,5 @@ public class AggregateJavadocPlugin implements Plugin<Project> {
})
)
);
-
- project.afterEvaluate(p -> aggregateJavadoc.configure(aggregateJavadoc -> {
- if (aggregateJavadoc.getDestinationDir() == null) {
- File docsDir = Optional.ofNullable(project.getConvention().findPlugin(JavaPluginConvention.class))
- .map(JavaPluginConvention::getDocsDir)
- .orElse(new File(project.getBuildDir(), "docs"));
-
- aggregateJavadoc.setDestinationDir(new File(docsDir, "aggregateJavadoc"));
- }
- }));
}
}
