Java 类org.gradle.api.tasks.javadoc.Javadoc 实例源码

项目:Reer    文件:JavaBasePlugin.java   
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();
                }
            });
        }
    });
}
项目:Pushjet-Android    文件:JavaBasePlugin.java   
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();
                }
            });
        }
    });
}
项目:Pushjet-Android    文件:JavaBasePlugin.java   
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();
                }
            });
        }
    });
}
项目:gradle-stdproject-plugin    文件:StdTaskConfiguration.java   
public static void configureJavadoc(@Nonnull final Project project, @Nonnull final Javadoc javadoc) {
    final StdProjectExtension extension = project.getRootProject().getExtensions().getByType(StdProjectExtension.class);
    final StandardJavadocDocletOptions javadocOptions = (StandardJavadocDocletOptions) javadoc.getOptions();
    javadoc.doFirst(new Action<Task>() {
        @Override
        public void execute(Task t) {
            if (!t.getProject().getGradle().getStartParameter().isOffline())
                javadocOptions.setLinks(extension.javadocLinks);
            javadocOptions.setLinkSource(extension.javadocLinkSource);
            if (!extension.javadocGroups.isEmpty())
                javadocOptions.setGroups(extension.javadocGroups);
            if (JavaVersion.current().isJava8Compatible())
                if (extension.javadocQuiet)
                    javadocOptions.addStringOption("Xdoclint:none", "-quiet");
        }
    });
}
项目:checkstyle-addons    文件:CreateJarJavadocTask.java   
@Override
public void configureFor(@Nonnull final DependencyConfig pDepConfig)
{
    // set appendix for archive name
    if (!pDepConfig.isDefaultConfig()) {
        final String appendix = pDepConfig.getName();
        setAppendix(appendix);
    }
    setDescription(
        getBuildUtil().getLongName() + ": Build the javadoc JAR for dependency configuration '" + pDepConfig
            .getName() + "'");

    // Dependency on javadoc generating task
    final Javadoc javadocTask = (Javadoc) getBuildUtil().getTask(TaskNames.javadoc, pDepConfig);
    dependsOn(javadocTask);

    // Configuration of JAR file contents
    from(javadocTask.getDestinationDir());
    intoFrom("META-INF", "LICENSE");

    // Manifest
    getBuildUtil().inheritManifest(this, pDepConfig);
}
项目:Reer    文件:JavaPlugin.java   
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);
}
项目:gradle-plugins    文件:JavadocJarPlugin.java   
@Override
public void apply(final Project project) {
    super.apply(project);

    getJarTask().setDescription("Assembles a jar archive containing the javadocs.");

    project.getPluginManager().withPlugin("java", appliedPlugin -> {
        Javadoc javadocTask = (Javadoc) project.getTasks().getByName(JavaPlugin.JAVADOC_TASK_NAME);

        getJarTask().dependsOn(javadocTask);
        getJarTask().from(javadocTask.getDestinationDir());
    });
}
项目:gradle-plugins    文件:JavadocUtf8Plugin.java   
@Override
public void apply(Project project) {
    project.getTasks().withType(Javadoc.class, javadoc -> {

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

        options.charSet("UTF-8");
        options.docEncoding("UTF-8");
        options.setEncoding("UTF-8");
    });
}
项目:gradle-plugins    文件:JavadocLinksPlugin.java   
@Override
public void apply(Project project) {
    this.project = project;

    project.getTasks().withType(Javadoc.class, javadoc -> javadoc.doFirst(task -> {

        addLink(javadoc, getJavaSeLink(JavaVersion.current()));

        Configuration configuration = findConfiguraion(javadoc.getClasspath());

        boolean usedJavadocIo = false;

        for (ResolvedArtifact resolvedArtifact : configuration.getResolvedConfiguration().getResolvedArtifacts()) {
            ComponentIdentifier componentIdentifier = resolvedArtifact.getId().getComponentIdentifier();

            if (componentIdentifier instanceof ModuleComponentIdentifier) {
                ModuleComponentIdentifier moduleComponentIdentifier = (ModuleComponentIdentifier) componentIdentifier;
                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);
                    addLink(javadoc, wellKnownLink);
                    break;
                } else {
                    javadoc.getLogger().info("Using javadoc.io link for '{}:{}:{}'", group, artifact, version);
                    String javadocIoLink = String.format("https://static.javadoc.io/%s/%s/%s/", group, artifact, version);
                    addLink(javadoc, javadocIoLink);
                    usedJavadocIo = true;
                }
            }
        }

        if (usedJavadocIo && javadoc.getOptions().getJFlags().stream().noneMatch(flag -> flag.contains("http.agent"))) {
            javadoc.getOptions().jFlags("-Dhttp.agent=" + System.currentTimeMillis());
        }
    }));
}
项目:gradle-plugins    文件:JavadocLinksPlugin.java   
private void addLink(Javadoc javadoc, String link) {
    MinimalJavadocOptions options = javadoc.getOptions();
    if (options instanceof StandardJavadocDocletOptions) {
        StandardJavadocDocletOptions docletOptions = (StandardJavadocDocletOptions) options;
        Logger logger = javadoc.getLogger();
        List<String> links = docletOptions.getLinks();

        if (!links.contains(link)) {
            logger.debug("Adding '{}' to {}", link, javadoc);
            links.add(link);
        } else {
            logger.info("Not adding '{}' to {} because it's already present", link, javadoc);
        }
    }
}
项目:gradle-plugins    文件:JavadocUtf8PluginTest.java   
@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");
}
项目:gradle-project-config    文件:JavaConfigPlugin.java   
/**
 * Create a task to create a JavaDoc JAR
 *
 * @param javadocJar Task to configure
 * @param javadoc JavaDoc task
 */
@Mutate
public void configureJavadocJarTask(@Path("tasks.javadocJar") Jar javadocJar,
        @Path("tasks.javadoc") Javadoc javadoc) {
    javadocJar.setDescription("Assembles a jar archive containing the JavaDoc documentation.");
    javadocJar.setGroup("build");
    javadocJar.setClassifier("javadoc");
    javadocJar.from(javadoc);
    javadocJar.dependsOn(javadoc);
}
项目:android-gradle-plugins    文件:AndroidJavadocJarPlugin.java   
@Override
protected void withAndroid(TestedExtension extension) {
    super.withAndroid(extension);

    getAndroidVariants().all(variant -> {

        AndroidJavadocPlugin androidJavadocPlugin = getProject().getPlugins().findPlugin(AndroidJavadocPlugin.class);
        Javadoc javadocTask = androidJavadocPlugin.getJavadocTask(getProject(), variant);

        Jar javadocJarTask = getProject().getTasks().create("javadoc" + capitalize((CharSequence) variant.getName()) + "Jar", Jar.class, jar -> {
            jar.dependsOn(javadocTask);

            jar.setDescription("Generate the javadoc jar for the " + variant.getName() + " variant");
            jar.setGroup("jar");

            jar.setAppendix(variant.getName());
            jar.setClassifier("javadoc");
            jar.from(javadocTask.getDestinationDir());
        });

        allJavadocJarTask.dependsOn(javadocJarTask);

        if (publishVariant(variant)) {
            getProject().getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, javadocJarTask);
        }
    });
}
项目:android-gradle-plugins    文件:AndroidJavadocPlugin.java   
@Override
protected void withAndroid(TestedExtension extension) {
    super.withAndroid(extension);
    getAndroidVariants().all(variant -> {
        Javadoc javadocTask = getJavadocTask(getProject(), variant);

        allJavadocTask.dependsOn(javadocTask);
    });
}
项目:ModGradle    文件:AbstractPlugin.java   
/**
 * Add Minecraft dependencies to compile time
 */
protected void configureCompile() {
    JavaPluginConvention javaModule = (JavaPluginConvention) project.getConvention().getPlugins().get("java");

    SourceSet main = javaModule.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
    SourceSet test = javaModule.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME);

    main.setCompileClasspath(main.getCompileClasspath().plus(project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES)));
    test.setCompileClasspath(test.getCompileClasspath().plus(project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES)));
    main.setRuntimeClasspath(main.getCompileClasspath().plus(project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES)));
    test.setCompileClasspath(test.getCompileClasspath().plus(project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES)));

    Javadoc javadoc = (Javadoc) project.getTasks().getByName(JavaPlugin.JAVADOC_TASK_NAME);
    javadoc.setClasspath(main.getOutput().plus(main.getCompileClasspath()));
}
项目:gradle-plugins    文件:JavadocJarPlugin.java   
@Override
public void apply(final Project project) {
    super.apply(project);

    getJarTask().setDescription("Assembles a jar archive containing the javadocs.");

    project.getPluginManager().withPlugin("java", appliedPlugin -> {
        Javadoc javadocTask = (Javadoc) project.getTasks().getByName(JavaPlugin.JAVADOC_TASK_NAME);

        getJarTask().dependsOn(javadocTask);
        getJarTask().from(javadocTask.getDestinationDir());
    });
}
项目:gradle-plugins    文件:JavadocUtf8Plugin.java   
@Override
public void apply(Project project) {
    project.getTasks().withType(Javadoc.class, javadoc -> {

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

        options.charSet("UTF-8");
        options.docEncoding("UTF-8");
        options.setEncoding("UTF-8");
    });
}
项目:gradle-plugins    文件:JavadocLinksPlugin.java   
@Override
public void apply(Project project) {
    this.project = project;

    project.getTasks().withType(Javadoc.class, javadoc -> javadoc.doFirst(task -> {

        addLink(javadoc, getJavaSeLink(JavaVersion.current()));

        Configuration configuration = findConfiguraion(javadoc.getClasspath());

        boolean usedJavadocIo = false;

        for (ResolvedArtifact resolvedArtifact : configuration.getResolvedConfiguration().getResolvedArtifacts()) {
            ComponentIdentifier componentIdentifier = resolvedArtifact.getId().getComponentIdentifier();

            if (componentIdentifier instanceof ModuleComponentIdentifier) {
                ModuleComponentIdentifier moduleComponentIdentifier = (ModuleComponentIdentifier) componentIdentifier;
                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);
                    addLink(javadoc, wellKnownLink);
                    break;
                } else {
                    javadoc.getLogger().info("Using javadoc.io link for '{}:{}:{}'", group, artifact, version);
                    String javadocIoLink = String.format("https://static.javadoc.io/%s/%s/%s/", group, artifact, version);
                    addLink(javadoc, javadocIoLink);
                    usedJavadocIo = true;
                }
            }
        }

        if (usedJavadocIo && javadoc.getOptions().getJFlags().stream().noneMatch(flag -> flag.contains("http.agent"))) {
            javadoc.getOptions().jFlags("-Dhttp.agent=" + System.currentTimeMillis());
        }
    }));
}
项目:gradle-plugins    文件:JavadocLinksPlugin.java   
private void addLink(Javadoc javadoc, String link) {
    MinimalJavadocOptions options = javadoc.getOptions();
    if (options instanceof StandardJavadocDocletOptions) {
        StandardJavadocDocletOptions docletOptions = (StandardJavadocDocletOptions) options;
        Logger logger = javadoc.getLogger();
        List<String> links = docletOptions.getLinks();

        if (!links.contains(link)) {
            logger.debug("Adding '{}' to {}", link, javadoc);
            links.add(link);
        } else {
            logger.info("Not adding '{}' to {} because it's already present", link, javadoc);
        }
    }
}
项目:gradle-plugins    文件:JavadocUtf8PluginTest.java   
@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");
}
项目:Pushjet-Android    文件:JavaPlugin.java   
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);
}
项目:Pushjet-Android    文件:JavaPlugin.java   
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);
}
项目:checkstyle-addons    文件:JavadocTask.java   
public static void configureJavadocTask(final Javadoc pTask, final DependencyConfig pDepConfig)
{
    final Project project = pTask.getProject();
    final BuildUtil buildUtil = new BuildUtil(project);

    pTask.setTitle(buildUtil.getLongName() + " v" + project.getVersion());
    final StandardJavadocDocletOptions options = (StandardJavadocDocletOptions) pTask.getOptions();
    options.setEncoding(StandardCharsets.UTF_8.toString());
    options.setDocEncoding(StandardCharsets.UTF_8.toString());
    options.setCharSet(StandardCharsets.UTF_8.toString());
    options.setAuthor(false);
    options.setUse(true);
    options.setNoDeprecated(true);
    options.setWindowTitle(buildUtil.getLongName());
    options.setSplitIndex(false);
    options.setHeader(buildUtil.getLongName());
    options.setLinks(pDepConfig.getJavadocLinks());

    pTask.setSource(buildUtil.getSourceSet(SourceSet.MAIN_SOURCE_SET_NAME).getAllJava()
        .plus(buildUtil.getSourceSet(BuildUtil.SONARQUBE_SOURCE_SET_NAME).getAllJava()));
    pTask.setClasspath(new ClasspathBuilder(project)
        .buildClassPath(pDepConfig, null, false, buildUtil.getSourceSet(SourceSet.MAIN_SOURCE_SET_NAME),
            buildUtil.getSourceSet(BuildUtil.SONARQUBE_SOURCE_SET_NAME)));

    // javadoc does not inherit the proxy settings (https://issues.gradle.org/browse/GRADLE-1228)
    if (System.getProperty("http.proxyHost") != null) {
        options.jFlags("-DproxyHost=" + System.getProperty("http.proxyHost"),
            "-DproxyPort=" + System.getProperty("http.proxyPort"),
            "-DproxyUser=" + System.getProperty("http.proxyUser"),
            "-DproxyPassword=" + System.getProperty("http.proxyPassword"));
    }
}
项目:sources-gradle-plugin    文件:SourcesPlugin.java   
protected void createSourcesJars(final Project project) {

        final JavaPluginConvention javaPluginConvention = project.getConvention().getPlugin(JavaPluginConvention.class);

        Task sourcesJar = project.getTasks().create("sourcesJar", Jar.class, jar -> {
            jar.setDescription("Creates a jar with the sources");
            jar.setClassifier("sources");
            jar.from(javaPluginConvention.getSourceSets().getByName("main").getAllSource());
        });

        Task javadocJar = project.getTasks().create("javadocJar", Jar.class, jar -> {
            jar.setDescription("Creates a javadoc jar");
            jar.setClassifier("javadoc");
            Javadoc javadoc = (Javadoc) project.getTasks().getByName(JavaPlugin.JAVADOC_TASK_NAME);
            jar.from(javadoc.getDestinationDir());
            jar.dependsOn(javadoc);
        });

        Task testsJar = project.getTasks().create("testsJar", Jar.class, jar -> {
            jar.setDescription("Creates a jar containing all the source and classes for the tests");
            jar.setClassifier("tests");
            SourceSet test = javaPluginConvention.getSourceSets().getByName("test");
            jar.from(test.getAllJava());
            jar.from(test.getOutput());
        });

        project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, sourcesJar);
        project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, javadocJar);
        project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, testsJar);
    }
项目:android-gradle-plugins    文件:AndroidJavadocPlugin.java   
public Javadoc getJavadocTask(Project project, BaseVariant variant) {

        if (!javadocTasks.containsKey(variant.getName())) {

            Javadoc task = project.getTasks().create("javadoc" + capitalize((CharSequence) variant.getName()), Javadoc.class, javadoc -> {
                javadoc.setDescription("Generate Javadoc for the " + variant.getName() + " variant");
                javadoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);

                javadoc.dependsOn(variant.getJavaCompiler());

                if (variant.getJavaCompiler() instanceof JavaCompile) {
                    JavaCompile javacTask = (JavaCompile) variant.getJavaCompiler();

                    javadoc.setSource(javacTask.getSource());

                    javadoc.setClasspath(project.files(javacTask.getDestinationDir()).plus(javacTask.getClasspath()));
                    javadoc.getOptions().setSource(javacTask.getSourceCompatibility());
                } else {
                    getProject().getLogger().warn("Failed to configure {}. Unsupported Compiler: {}", javadoc.getName(), variant.getJavaCompiler().getClass().getName());
                }

                //javadoc.exclude '**/BuildConfig.java'
                javadoc.exclude("**/R.java");

                javadoc.getOptions().encoding("UTF-8");
                javadoc.getOptions().setBootClasspath(getAndroidExtension().getBootClasspath());

                if (javadoc.getOptions() instanceof StandardJavadocDocletOptions) {
                    StandardJavadocDocletOptions realOptions = (StandardJavadocDocletOptions) javadoc.getOptions();

                    realOptions.docEncoding("UTF-8");
                    realOptions.charSet("UTF-8");

                    Serializable javaVersion = GUtil.elvis(Jvm.current().getJavaVersion().getMajorVersion(), '8');
                    realOptions.links("http://docs.oracle.com/javase/" + javaVersion + "/docs/api/");
                    realOptions.linksOffline("http://developer.android.com/reference/", getAndroidExtension().getSdkDirectory() + "/docs/reference");
                }

                javadoc.setFailOnError(false);

                File docsDir;
                if (project.hasProperty("docsDir")) {
                    docsDir = (File) project.property("docsDir");
                } else {
                    docsDir = new File(project.getBuildDir(), "docs");
                }
                File javadocDir = new File(docsDir, "javadoc");
                javadoc.setDestinationDir(new File(javadocDir, variant.getDirName()));
            });

            javadocTasks.put(variant.getName(), task);
        }

        return javadocTasks.get(variant.getName());
    }
项目:gradle-project-config    文件:JavaConfigPlugin.java   
/**
 * Configure the javadoc task
 *
 * @param javadoc Javadoc task to configure
 */
@Mutate
public void configureJavadocTask(@Path("tasks.javadoc") Javadoc javadoc) {
    javadoc.setFailOnError(false);
}