org.gradle.api.tasks.javadoc.Javadoc Java Examples

The following examples show how to use org.gradle.api.tasks.javadoc.Javadoc. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OptionalDependenciesPlugin.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Override
public void apply(Project project) {
	Configuration optional = project.getConfigurations().create(OPTIONAL_CONFIGURATION_NAME);
	optional.attributes((attributes) -> attributes.attribute(Usage.USAGE_ATTRIBUTE,
			project.getObjects().named(Usage.class, Usage.JAVA_RUNTIME)));
	project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> {
		SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class)
		                                       .getSourceSets();
		sourceSets.all((sourceSet) -> {
			sourceSet.setCompileClasspath(sourceSet.getCompileClasspath().plus(optional));
			sourceSet.setRuntimeClasspath(sourceSet.getRuntimeClasspath().plus(optional));
		});
		project.getTasks().withType(Javadoc.class)
		       .all((javadoc) -> javadoc.setClasspath(javadoc.getClasspath().plus(optional)));
	});
	project.getPlugins().withType(EclipsePlugin.class,
			(eclipsePlugin) -> project.getExtensions().getByType(EclipseModel.class)
			                          .classpath((classpath) -> classpath.getPlusConfigurations().add(optional)));
}
 
Example #2
Source File: JavaBasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureJavaDoc(final Project project, final JavaPluginConvention convention) {
    project.getTasks().withType(Javadoc.class, new Action<Javadoc>() {
        public void execute(Javadoc javadoc) {
            javadoc.getConventionMapping().map("destinationDir", new Callable<Object>() {
                public Object call() throws Exception {
                    return new File(convention.getDocsDir(), "javadoc");
                }
            });
            javadoc.getConventionMapping().map("title", new Callable<Object>() {
                public Object call() throws Exception {
                    return project.getExtensions().getByType(ReportingExtension.class).getApiDocTitle();
                }
            });
        }
    });
}
 
Example #3
Source File: JavaBasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureJavaDoc(final Project project, final JavaPluginConvention convention) {
    project.getTasks().withType(Javadoc.class, new Action<Javadoc>() {
        public void execute(Javadoc javadoc) {
            javadoc.getConventionMapping().map("destinationDir", new Callable<Object>() {
                public Object call() throws Exception {
                    return new File(convention.getDocsDir(), "javadoc");
                }
            });
            javadoc.getConventionMapping().map("title", new Callable<Object>() {
                public Object call() throws Exception {
                    return project.getExtensions().getByType(ReportingExtension.class).getApiDocTitle();
                }
            });
        }
    });
}
 
Example #4
Source File: JavaBasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureJavaDoc(final Project project, final JavaPluginConvention convention) {
    project.getTasks().withType(Javadoc.class, new Action<Javadoc>() {
        public void execute(Javadoc javadoc) {
            javadoc.getConventionMapping().map("destinationDir", new Callable<Object>() {
                public Object call() throws Exception {
                    return new File(convention.getDocsDir(), "javadoc");
                }
            });
            javadoc.getConventionMapping().map("title", new Callable<Object>() {
                public Object call() throws Exception {
                    return project.getExtensions().getByType(ReportingExtension.class).getApiDocTitle();
                }
            });
        }
    });
}
 
Example #5
Source File: JavaBasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureJavaDoc(final Project project, final JavaPluginConvention convention) {
    project.getTasks().withType(Javadoc.class, new Action<Javadoc>() {
        public void execute(Javadoc javadoc) {
            javadoc.getConventionMapping().map("destinationDir", new Callable<Object>() {
                public Object call() throws Exception {
                    return new File(convention.getDocsDir(), "javadoc");
                }
            });
            javadoc.getConventionMapping().map("title", new Callable<Object>() {
                public Object call() throws Exception {
                    return project.getExtensions().getByType(ReportingExtension.class).getApiDocTitle();
                }
            });
        }
    });
}
 
Example #6
Source File: DocletPlugin.java    From crnk-framework with Apache License 2.0 6 votes vote down vote up
@Override
public void apply(final Project project) {
	Configuration config = project.getConfigurations().create("crnkJavaDocToXml");

	project.getDependencies().add("crnkJavaDocToXml", "com.github.markusbernhardt:xml-doclet:1.0.5");

	Javadoc task = project.getTasks().create(TASK_NAME, Javadoc.class);
	task.setTitle(null);
	task.setDestinationDir(new File(project.getBuildDir(), "crnk-xml-docs"));

	MinimalJavadocOptions options = task.getOptions();
	options.setDoclet("com.github.markusbernhardt.xmldoclet.XmlDoclet");
	options.setMemberLevel(JavadocMemberLevel.PRIVATE);
	options.setDocletpath(new ArrayList<>(config.getFiles()));

	SourceSetContainer sourceSets = (SourceSetContainer) project.getProperties().get("sourceSets");
	SourceSet mainSourceSet = sourceSets.getByName("main");
	task.source(mainSourceSet.getAllJava());
	task.setClasspath(mainSourceSet.getCompileClasspath());
}
 
Example #7
Source File: JavaBasePlugin.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
private void configureJavaDoc(final Project project, final JavaPluginConvention convention) {
    project.getTasks().withType(Javadoc.class, new Action<Javadoc>() {
        public void execute(Javadoc javadoc) {
            javadoc.getConventionMapping().map("destinationDir", new Callable<Object>() {
                public Object call() throws Exception {
                    return new File(convention.getDocsDir(), "javadoc");
                }
            });
            javadoc.getConventionMapping().map("title", new Callable<Object>() {
                public Object call() throws Exception {
                    return project.getExtensions().getByType(ReportingExtension.class).getApiDocTitle();
                }
            });
        }
    });
}
 
Example #8
Source File: ResolveJavadocLinks.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Override
public void execute(Task task) {
    javadoc = (Javadoc) task;
    logger = javadoc.getLogger();

    addLink(getJavaSeLink());

    findConfigurations(javadoc.getClasspath())
            .flatMap(files -> files.getResolvedConfiguration().getResolvedArtifacts().stream())
            .map(resolvedArtifact -> resolvedArtifact.getId().getComponentIdentifier())
            .filter(ModuleComponentIdentifier.class::isInstance)
            .map(ModuleComponentIdentifier.class::cast)
            .map(moduleComponentIdentifier -> {
                String group = moduleComponentIdentifier.getGroup();
                String artifact = moduleComponentIdentifier.getModule();
                String version = moduleComponentIdentifier.getVersion();

                String wellKnownLink = findWellKnownLink(group, artifact, version);
                if (wellKnownLink != null) {
                    javadoc.getLogger().info("Using well known link '{}' for '{}:{}:{}'", wellKnownLink, group, artifact, version);
                    return wellKnownLink;
                }
                else {
                    String javadocIoLink = String.format("https://static.javadoc.io/%s/%s/%s/", group, artifact, version);
                    if (checkLink(javadocIoLink)) {
                        javadoc.getLogger().info("Using javadoc.io link for '{}:{}:{}'", group, artifact, version);
                        return javadocIoLink;
                    }
                    else {
                        return null;
                    }
                }
            })
            .filter(Objects::nonNull)
            .forEach(this::addLink);
}
 
Example #9
Source File: JavaPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void configureJavaDoc(final JavaPluginConvention pluginConvention) {
    Project project = pluginConvention.getProject();

    SourceSet mainSourceSet = pluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
    Javadoc javadoc = project.getTasks().create(JAVADOC_TASK_NAME, Javadoc.class);
    javadoc.setDescription("Generates Javadoc API documentation for the main source code.");
    javadoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);
    javadoc.setClasspath(mainSourceSet.getOutput().plus(mainSourceSet.getCompileClasspath()));
    javadoc.setSource(mainSourceSet.getAllJava());
    addDependsOnTaskInOtherProjects(javadoc, true, JAVADOC_TASK_NAME, COMPILE_CONFIGURATION_NAME);
}
 
Example #10
Source File: JavaPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void configureJavaDoc(final JavaPluginConvention pluginConvention) {
    Project project = pluginConvention.getProject();

    SourceSet mainSourceSet = pluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
    Javadoc javadoc = project.getTasks().create(JAVADOC_TASK_NAME, Javadoc.class);
    javadoc.setDescription("Generates Javadoc API documentation for the main source code.");
    javadoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);
    javadoc.setClasspath(mainSourceSet.getOutput().plus(mainSourceSet.getCompileClasspath()));
    javadoc.setSource(mainSourceSet.getAllJava());
    addDependsOnTaskInOtherProjects(javadoc, true, JAVADOC_TASK_NAME, COMPILE_CONFIGURATION_NAME);
}
 
Example #11
Source File: JavadocUtf8PluginTest.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Test
public void apply() {
    project.getPlugins().apply(JavaPlugin.class);
    project.getPlugins().apply(JavadocUtf8Plugin.class);

    Javadoc javadoc = (Javadoc) project.getTasks().getByName(JavaPlugin.JAVADOC_TASK_NAME);
    StandardJavadocDocletOptions options = (StandardJavadocDocletOptions) javadoc.getOptions();

    assertThat(options.getDocEncoding()).isEqualToIgnoringCase("UTF-8");
    assertThat(options.getEncoding()).isEqualToIgnoringCase("UTF-8");
    assertThat(options.getCharSet()).isEqualToIgnoringCase("UTF-8");
}
 
Example #12
Source File: ResolveJavadocLinks.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Override
public void execute(Task task) {
    javadoc = (Javadoc) task;
    logger = javadoc.getLogger();

    addLink(getJavaSeLink());

    findConfigurations(javadoc.getClasspath())
            .flatMap(files -> files.getResolvedConfiguration().getResolvedArtifacts().stream())
            .map(resolvedArtifact -> resolvedArtifact.getId().getComponentIdentifier())
            .filter(ModuleComponentIdentifier.class::isInstance)
            .map(ModuleComponentIdentifier.class::cast)
            .map(moduleComponentIdentifier -> {
                String group = moduleComponentIdentifier.getGroup();
                String artifact = moduleComponentIdentifier.getModule();
                String version = moduleComponentIdentifier.getVersion();

                String wellKnownLink = findWellKnownLink(group, artifact, version);
                if (wellKnownLink != null) {
                    javadoc.getLogger().info("Using well known link '{}' for '{}:{}:{}'", wellKnownLink, group, artifact, version);
                    return wellKnownLink;
                }
                else {
                    String javadocIoLink = String.format("https://static.javadoc.io/%s/%s/%s/", group, artifact, version);
                    if (checkLink(javadocIoLink)) {
                        javadoc.getLogger().info("Using javadoc.io link for '{}:{}:{}'", group, artifact, version);
                        return javadocIoLink;
                    }
                    else {
                        return null;
                    }
                }
            })
            .filter(Objects::nonNull)
            .forEach(this::addLink);
}
 
Example #13
Source File: JavadocLinksPlugin.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Override
public void apply(Project project) {
    this.project = project;

    OkHttpPlugin okHttpPlugin = project.getPlugins().apply(OkHttpPlugin.class);

    project.getTasks().withType(Javadoc.class)
            .configureEach(javadoc -> {
                OkHttpClient okHttpClient = okHttpPlugin.getOkHttpClient();
                javadoc.doFirst("resolveJavadocLinks", new ResolveJavadocLinks(okHttpClient));
            });
}
 
Example #14
Source File: JavadocUtf8Plugin.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Override
public void apply(Project project) {
    project.getTasks().withType(Javadoc.class).configureEach(javadoc -> {

        StandardJavadocDocletOptions options = (StandardJavadocDocletOptions) javadoc.getOptions();

        options.charSet("UTF-8");
        options.docEncoding("UTF-8");
        options.setEncoding("UTF-8");
    });
}
 
Example #15
Source File: JavadocUtf8PluginTest.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Test
public void apply() {
    project.getPlugins().apply(JavaPlugin.class);
    project.getPlugins().apply(JavadocUtf8Plugin.class);

    Javadoc javadoc = (Javadoc) project.getTasks().getByName(JavaPlugin.JAVADOC_TASK_NAME);
    StandardJavadocDocletOptions options = (StandardJavadocDocletOptions) javadoc.getOptions();

    assertThat(options.getDocEncoding()).isEqualToIgnoringCase("UTF-8");
    assertThat(options.getEncoding()).isEqualToIgnoringCase("UTF-8");
    assertThat(options.getCharSet()).isEqualToIgnoringCase("UTF-8");
}
 
Example #16
Source File: JavadocLinksPlugin.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Override
public void apply(Project project) {
    this.project = project;

    OkHttpPlugin okHttpPlugin = project.getPlugins().apply(OkHttpPlugin.class);

    project.getTasks().withType(Javadoc.class)
            .configureEach(javadoc -> {
                OkHttpClient okHttpClient = okHttpPlugin.getOkHttpClient();
                javadoc.doFirst("resolveJavadocLinks", new ResolveJavadocLinks(okHttpClient));
            });
}
 
Example #17
Source File: JavadocUtf8Plugin.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Override
public void apply(Project project) {
    project.getTasks().withType(Javadoc.class).configureEach(javadoc -> {

        StandardJavadocDocletOptions options = (StandardJavadocDocletOptions) javadoc.getOptions();

        options.charSet("UTF-8");
        options.docEncoding("UTF-8");
        options.setEncoding("UTF-8");
    });
}
 
Example #18
Source File: JavaPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void configureJavaDoc(final JavaPluginConvention pluginConvention) {
    Project project = pluginConvention.getProject();

    SourceSet mainSourceSet = pluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
    Javadoc javadoc = project.getTasks().create(JAVADOC_TASK_NAME, Javadoc.class);
    javadoc.setDescription("Generates Javadoc API documentation for the main source code.");
    javadoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);
    javadoc.setClasspath(mainSourceSet.getOutput().plus(mainSourceSet.getCompileClasspath()));
    javadoc.setSource(mainSourceSet.getAllJava());
    addDependsOnTaskInOtherProjects(javadoc, true, JAVADOC_TASK_NAME, COMPILE_CONFIGURATION_NAME);
}
 
Example #19
Source File: JavaPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void configureJavaDoc(final JavaPluginConvention pluginConvention) {
    Project project = pluginConvention.getProject();

    SourceSet mainSourceSet = pluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
    Javadoc javadoc = project.getTasks().create(JAVADOC_TASK_NAME, Javadoc.class);
    javadoc.setDescription("Generates Javadoc API documentation for the main source code.");
    javadoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);
    javadoc.setClasspath(mainSourceSet.getOutput().plus(mainSourceSet.getCompileClasspath()));
    javadoc.setSource(mainSourceSet.getAllJava());
    addDependsOnTaskInOtherProjects(javadoc, true, JAVADOC_TASK_NAME, COMPILE_CONFIGURATION_NAME);
}
 
Example #20
Source File: JavadocTask.java    From gradle-modules-plugin with MIT License 5 votes vote down vote up
private void addJavadocOptions(Javadoc javadoc, JavadocModuleOptions moduleOptions) {
    var options = (CoreJavadocOptions) javadoc.getOptions();
    FileCollection classpath = mergeClassesHelper().getMergeAdjustedClasspath(javadoc.getClasspath());

    var patchModuleContainer = helper().modularityExtension().optionContainer().getPatchModuleContainer();
    StreamHelper.concat(
            patchModuleContainer.buildModulePathOption(classpath).stream(),
            patchModuleContainer.mutator(classpath).taskOptionStream(),
            moduleOptions.buildFullOptionStreamLogged()
    ).forEach(option -> option.mutateOptions(options));
}
 
Example #21
Source File: JavadocTask.java    From gradle-modules-plugin with MIT License 5 votes vote down vote up
private void configureJavaDoc(Javadoc javadoc) {
    var moduleOptions = javadoc.getExtensions().create("moduleOptions", JavadocModuleOptions.class, project);

    // don't convert to lambda: https://github.com/java9-modularity/gradle-modules-plugin/issues/54
    javadoc.doFirst(new Action<Task>() {
        @Override
        public void execute(Task task) {
            addJavadocOptions(javadoc, moduleOptions);
            javadoc.setClasspath(project.files());
        }
    });
}
 
Example #22
Source File: JavadocTask.java    From gradle-modules-plugin with MIT License 4 votes vote down vote up
public void configureJavaDoc() {
    helper().findTask(JavaPlugin.JAVADOC_TASK_NAME, Javadoc.class)
            .ifPresent(this::configureJavaDoc);
}
 
Example #23
Source File: AggregateJavadocPlugin.java    From gradle-plugins with MIT License 4 votes vote down vote up
@Override
public void apply(Project project) {

    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 ->
                    aggregateJavadoc.configure(aj -> {
                        TaskProvider<Javadoc> javadoc = p.getTasks().named(JavaPlugin.JAVADOC_TASK_NAME, Javadoc.class);

                        aj.source(javadoc.map(Javadoc::getSource));

                        if (aj.getClasspath() instanceof ConfigurableFileCollection) {
                            ((ConfigurableFileCollection) aj.getClasspath()).from(javadoc.map(Javadoc::getClasspath));
                        }
                        else {
                            ConfigurableFileCollection classpath = project.files();
                            classpath.from(aj.getClasspath());
                            classpath.from(javadoc.map(Javadoc::getClasspath));
                            aj.setClasspath(classpath);
                        }

                        StandardJavadocDocletOptions options = (StandardJavadocDocletOptions) javadoc.get().getOptions();
                        StandardJavadocDocletOptions aggregateOptions = (StandardJavadocDocletOptions) aj.getOptions();

                        options.getLinks().forEach(link -> {
                            if (!aggregateOptions.getLinks().contains(link)) {
                                aggregateOptions.getLinks().add(link);
                            }
                        });
                        options.getLinksOffline().forEach(link -> {
                            if (!aggregateOptions.getLinksOffline().contains(link)) {
                                aggregateOptions.getLinksOffline().add(link);
                            }
                        });
                        options.getJFlags().forEach(jFlag -> {
                            if (!aggregateOptions.getJFlags().contains(jFlag)) {
                                aggregateOptions.getJFlags().add(jFlag);
                            }
                        });
                    })
            )
    );
}
 
Example #24
Source File: AggregateJavadocPlugin.java    From gradle-plugins with MIT License 4 votes vote down vote up
@Override
public void apply(Project project) {

    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 ->
                    aggregateJavadoc.configure(aj -> {
                        TaskProvider<Javadoc> javadoc = p.getTasks().named(JavaPlugin.JAVADOC_TASK_NAME, Javadoc.class);

                        aj.source(javadoc.map(Javadoc::getSource));

                        if (aj.getClasspath() instanceof ConfigurableFileCollection) {
                            ((ConfigurableFileCollection) aj.getClasspath()).from(javadoc.map(Javadoc::getClasspath));
                        }
                        else {
                            ConfigurableFileCollection classpath = project.files();
                            classpath.from(aj.getClasspath());
                            classpath.from(javadoc.map(Javadoc::getClasspath));
                            aj.setClasspath(classpath);
                        }

                        StandardJavadocDocletOptions options = (StandardJavadocDocletOptions) javadoc.get().getOptions();
                        StandardJavadocDocletOptions aggregateOptions = (StandardJavadocDocletOptions) aj.getOptions();

                        options.getLinks().forEach(link -> {
                            if (!aggregateOptions.getLinks().contains(link)) {
                                aggregateOptions.getLinks().add(link);
                            }
                        });
                        options.getLinksOffline().forEach(link -> {
                            if (!aggregateOptions.getLinksOffline().contains(link)) {
                                aggregateOptions.getLinksOffline().add(link);
                            }
                        });
                        options.getJFlags().forEach(jFlag -> {
                            if (!aggregateOptions.getJFlags().contains(jFlag)) {
                                aggregateOptions.getJFlags().add(jFlag);
                            }
                        });
                    })
            )
    );
}