org.gradle.external.javadoc.StandardJavadocDocletOptions Java Examples

The following examples show how to use org.gradle.external.javadoc.StandardJavadocDocletOptions. 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: 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 #2
Source File: ResolveJavadocLinks.java    From gradle-plugins with MIT License 5 votes vote down vote up
private void addLink(String link) {
    MinimalJavadocOptions options = javadoc.getOptions();
    if (options instanceof StandardJavadocDocletOptions) {
        StandardJavadocDocletOptions docletOptions = (StandardJavadocDocletOptions) options;
        List<String> links = docletOptions.getLinks();

        if (links == null || !links.contains(link)) {
            logger.debug("Adding '{}' to {}", link, javadoc);
            docletOptions.links(link);
        }
        else {
            logger.info("Not adding '{}' to {} because it's already present", link, javadoc);
        }
    }
}
 
Example #3
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 #4
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 #5
Source File: ResolveJavadocLinks.java    From gradle-plugins with MIT License 5 votes vote down vote up
private void addLink(String link) {
    MinimalJavadocOptions options = javadoc.getOptions();
    if (options instanceof StandardJavadocDocletOptions) {
        StandardJavadocDocletOptions docletOptions = (StandardJavadocDocletOptions) options;
        List<String> links = docletOptions.getLinks();

        if (links == null || !links.contains(link)) {
            logger.debug("Adding '{}' to {}", link, javadoc);
            docletOptions.links(link);
        }
        else {
            logger.info("Not adding '{}' to {} because it's already present", link, javadoc);
        }
    }
}
 
Example #6
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 #7
Source File: Javadoc.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@TaskAction
protected void generate() {
    final File destinationDir = getDestinationDir();

    if (options.getDestinationDirectory() == null) {
        options.destinationDirectory(destinationDir);
    }

    options.classpath(new ArrayList<File>(getClasspath().getFiles()));

    if (!GUtil.isTrue(options.getWindowTitle()) && GUtil.isTrue(getTitle())) {
        options.windowTitle(getTitle());
    }
    if (options instanceof StandardJavadocDocletOptions) {
        StandardJavadocDocletOptions docletOptions = (StandardJavadocDocletOptions) options;
        if (!GUtil.isTrue(docletOptions.getDocTitle()) && GUtil.isTrue(getTitle())) {
            docletOptions.setDocTitle(getTitle());
        }
    }

    if (maxMemory != null) {
        final List<String> jFlags = options.getJFlags();
        final Iterator<String> jFlagsIt = jFlags.iterator();
        boolean containsXmx = false;
        while (!containsXmx && jFlagsIt.hasNext()) {
            final String jFlag = jFlagsIt.next();
            if (jFlag.startsWith("-Xmx")) {
                containsXmx = true;
            }
        }
        if (!containsXmx) {
            options.jFlags("-Xmx" + maxMemory);
        }
    }

    List<String> sourceNames = new ArrayList<String>();
    for (File sourceFile : getSource()) {
        sourceNames.add(sourceFile.getAbsolutePath());
    }
    options.setSourceNames(sourceNames);

    executeExternalJavadoc();
}
 
Example #8
Source File: Javadoc.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@TaskAction
protected void generate() {
    final File destinationDir = getDestinationDir();

    if (options.getDestinationDirectory() == null) {
        options.destinationDirectory(destinationDir);
    }

    options.classpath(new ArrayList<File>(getClasspath().getFiles()));

    if (!GUtil.isTrue(options.getWindowTitle()) && GUtil.isTrue(getTitle())) {
        options.windowTitle(getTitle());
    }
    if (options instanceof StandardJavadocDocletOptions) {
        StandardJavadocDocletOptions docletOptions = (StandardJavadocDocletOptions) options;
        if (!GUtil.isTrue(docletOptions.getDocTitle()) && GUtil.isTrue(getTitle())) {
            docletOptions.setDocTitle(getTitle());
        }
    }

    if (maxMemory != null) {
        final List<String> jFlags = options.getJFlags();
        final Iterator<String> jFlagsIt = jFlags.iterator();
        boolean containsXmx = false;
        while (!containsXmx && jFlagsIt.hasNext()) {
            final String jFlag = jFlagsIt.next();
            if (jFlag.startsWith("-Xmx")) {
                containsXmx = true;
            }
        }
        if (!containsXmx) {
            options.jFlags("-Xmx" + maxMemory);
        }
    }

    List<String> sourceNames = new ArrayList<String>();
    for (File sourceFile : getSource()) {
        sourceNames.add(sourceFile.getAbsolutePath());
    }
    options.setSourceNames(sourceNames);

    executeExternalJavadoc();
}
 
Example #9
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 #10
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 #11
Source File: Javadoc.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@TaskAction
protected void generate() {
    final File destinationDir = getDestinationDir();

    if (options.getDestinationDirectory() == null) {
        options.destinationDirectory(destinationDir);
    }

    options.classpath(new ArrayList<File>(getClasspath().getFiles()));

    if (!GUtil.isTrue(options.getWindowTitle()) && GUtil.isTrue(getTitle())) {
        options.windowTitle(getTitle());
    }
    if (options instanceof StandardJavadocDocletOptions) {
        StandardJavadocDocletOptions docletOptions = (StandardJavadocDocletOptions) options;
        if (!GUtil.isTrue(docletOptions.getDocTitle()) && GUtil.isTrue(getTitle())) {
            docletOptions.setDocTitle(getTitle());
        }
    }

    if (maxMemory != null) {
        final List<String> jFlags = options.getJFlags();
        final Iterator<String> jFlagsIt = jFlags.iterator();
        boolean containsXmx = false;
        while (!containsXmx && jFlagsIt.hasNext()) {
            final String jFlag = jFlagsIt.next();
            if (jFlag.startsWith("-Xmx")) {
                containsXmx = true;
            }
        }
        if (!containsXmx) {
            options.jFlags("-Xmx" + maxMemory);
        }
    }

    List<String> sourceNames = new ArrayList<String>();
    for (File sourceFile : getSource()) {
        sourceNames.add(sourceFile.getAbsolutePath());
    }
    options.setSourceNames(sourceNames);

    executeExternalJavadoc();
}
 
Example #12
Source File: Javadoc.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@TaskAction
protected void generate() {
    final File destinationDir = getDestinationDir();

    if (options.getDestinationDirectory() == null) {
        options.destinationDirectory(destinationDir);
    }

    options.classpath(new ArrayList<File>(getClasspath().getFiles()));

    if (!GUtil.isTrue(options.getWindowTitle()) && GUtil.isTrue(getTitle())) {
        options.windowTitle(getTitle());
    }
    if (options instanceof StandardJavadocDocletOptions) {
        StandardJavadocDocletOptions docletOptions = (StandardJavadocDocletOptions) options;
        if (!GUtil.isTrue(docletOptions.getDocTitle()) && GUtil.isTrue(getTitle())) {
            docletOptions.setDocTitle(getTitle());
        }
    }

    if (maxMemory != null) {
        final List<String> jFlags = options.getJFlags();
        final Iterator<String> jFlagsIt = jFlags.iterator();
        boolean containsXmx = false;
        while (!containsXmx && jFlagsIt.hasNext()) {
            final String jFlag = jFlagsIt.next();
            if (jFlag.startsWith("-Xmx")) {
                containsXmx = true;
            }
        }
        if (!containsXmx) {
            options.jFlags("-Xmx" + maxMemory);
        }
    }

    List<String> sourceNames = new ArrayList<String>();
    for (File sourceFile : getSource()) {
        sourceNames.add(sourceFile.getAbsolutePath());
    }
    options.setSourceNames(sourceNames);

    executeExternalJavadoc();
}