Java 类org.gradle.api.plugins.JavaBasePlugin 实例源码

项目:Reer    文件:OsgiPlugin.java   
public void apply(final Project project) {
    project.getPluginManager().apply(JavaBasePlugin.class);

    final OsgiPluginConvention osgiConvention = new OsgiPluginConvention((ProjectInternal) project);
    project.getConvention().getPlugins().put("osgi", osgiConvention);

    project.getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {
        @Override
        public void execute(JavaPlugin javaPlugin) {
            OsgiManifest osgiManifest = osgiConvention.osgiManifest();
            osgiManifest.setClassesDir(project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName("main").getOutput().getClassesDir());
            osgiManifest.setClasspath(project.getConfigurations().getByName("runtime"));
            Jar jarTask = (Jar) project.getTasks().getByName("jar");
            jarTask.setManifest(osgiManifest);
        }
    });
}
项目:gradle-project-config    文件:CheckstyleConfigPlugin.java   
/**
 * Create Checkstyle tasks
 *
 * @param tasks Task container
 * @param checkstyleConfig Checkstyle configuration
 * @param sources Source sets
 * @param files
 * @param context
 */
@Finalize
public void configureCheckstyleTasks(ModelMap<Checkstyle> tasks, CheckstyleConfig checkstyleConfig,
        ProjectSourceSet sources, FileOperations files, ProjectContext context) {
    for (JavaSourceSet source : sources.withType(JavaSourceSet.class)) {
        String taskName = getCheckstyleTaskName(source);

        if (!checkstyleConfig.getIgnoreSourceSets().contains(source.getParentName())) {
            tasks.named(taskName, t -> {
                File checkstyleConfigFile = getCheckstyleConfigFile(source.getParentName(), files);

                t.setGroup(JavaBasePlugin.VERIFICATION_GROUP);
                t.setConfigFile(checkstyleConfigFile);

                if (checkstyleConfigFile.getParentFile() != null) {
                    t.setConfigDir(context.provider(() -> checkstyleConfigFile.getParentFile()));
                }

                t.dependsOn(getUpdateConfigTaskName(source));
            });
        }
    }
}
项目:wildfly-swarm    文件:PackagePlugin.java   
@Override
public void apply(Project project) {
    project.getExtensions().create(SWARM_EXTENSION, SwarmExtension.class, project);
    project.afterEvaluate(__ -> {
        final TaskContainer tasks = project.getTasks();
        final PackageTask packageTask = tasks.create(WILDFLY_SWARM_PACKAGE_TASK_NAME, PackageTask.class);

        final Jar archiveTask = getArchiveTask(project);

        if (archiveTask == null) {
            throw new GradleException("No suitable Archive-Task found to include in Swarm Uber-JAR.");
        }

        packageTask.jarTask(archiveTask).dependsOn(archiveTask);

        tasks.getByName(JavaBasePlugin.BUILD_TASK_NAME).dependsOn(packageTask);
    });
}
项目:gradle-defaults    文件:ExtIntellijPlugin.java   
@Override
public void apply(Project project) {
    project.getPlugins().apply("idea");

    // everything below this is only at the (top-level) "Project" level, not the "Module" level
    if (project == project.getRootProject()) {
        LOG.info("Configuring the 'idea' plugin");

        codeStyleExtension(project);
        val ideaProject = ideaProject(project);
        ideaProject.setVcs("Git");

        ideaProject.getIpr().withXml(xmlProvider -> customizeProjectXml(project, xmlProvider));

        project.getPlugins().withType(JavaBasePlugin.class, plugin -> configLanguageVersion(project));
    }
}
项目:Reer    文件:ScalaBasePlugin.java   
public void apply(Project project) {
    project.getPluginManager().apply(JavaBasePlugin.class);

    configureConfigurations(project);
    ScalaRuntime scalaRuntime = configureScalaRuntimeExtension(project);
    configureCompileDefaults(project, scalaRuntime);
    configureSourceSetDefaults(project, sourceDirectorySetFactory);
    configureScaladoc(project, scalaRuntime);
}
项目:Reer    文件:ScalaBasePlugin.java   
private static void configureSourceSetDefaults(final Project project, final SourceDirectorySetFactory sourceDirectorySetFactory) {
    final JavaBasePlugin javaPlugin = project.getPlugins().getPlugin(JavaBasePlugin.class);
    project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() {
        @Override
        public void execute(final SourceSet sourceSet) {
            String displayName = (String) InvokerHelper.invokeMethod(sourceSet, "getDisplayName", null);
            Convention sourceSetConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention");
            DefaultScalaSourceSet scalaSourceSet = new DefaultScalaSourceSet(displayName, sourceDirectorySetFactory);
            sourceSetConvention.getPlugins().put("scala", scalaSourceSet);
            final SourceDirectorySet scalaDirectorySet = scalaSourceSet.getScala();
            scalaDirectorySet.srcDir(new Callable<File>() {
                @Override
                public File call() throws Exception {
                    return project.file("src/" + sourceSet.getName() + "/scala");
                }
            });
            sourceSet.getAllJava().source(scalaDirectorySet);
            sourceSet.getAllSource().source(scalaDirectorySet);
            sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() {
                @Override
                public boolean isSatisfiedBy(FileTreeElement element) {
                    return scalaDirectorySet.contains(element.getFile());
                }
            });

            configureScalaCompile(project, javaPlugin, sourceSet);
        }

    });
}
项目:Reer    文件:ScalaBasePlugin.java   
private static void configureScalaCompile(final Project project, JavaBasePlugin javaPlugin, final SourceSet sourceSet) {
    String taskName = sourceSet.getCompileTaskName("scala");
    final ScalaCompile scalaCompile = project.getTasks().create(taskName, ScalaCompile.class);
    scalaCompile.dependsOn(sourceSet.getCompileJavaTaskName());
    javaPlugin.configureForSourceSet(sourceSet, scalaCompile);
    Convention scalaConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention");
    ScalaSourceSet scalaSourceSet = scalaConvention.findPlugin(ScalaSourceSet.class);
    scalaCompile.setDescription("Compiles the " + scalaSourceSet.getScala() + ".");
    scalaCompile.setSource(scalaSourceSet.getScala());
    project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(taskName);

    // cannot use convention mapping because the resulting object won't be serializable
    // cannot compute at task execution time because we need association with source set
    project.getGradle().addBuildListener(new BuildAdapter() {
        @Override
        public void projectsEvaluated(Gradle gradle) {
            IncrementalCompileOptions incrementalOptions = scalaCompile.getScalaCompileOptions().getIncrementalOptions();
            if (incrementalOptions.getAnalysisFile() == null) {
                String analysisFilePath = project.getBuildDir().getPath() + "/tmp/scala/compilerAnalysis/" + scalaCompile.getName() + ".analysis";
                incrementalOptions.setAnalysisFile(new File(analysisFilePath));
            }

            if (incrementalOptions.getPublishedCode() == null) {
                Jar jarTask = (Jar) project.getTasks().findByName(sourceSet.getJarTaskName());
                incrementalOptions.setPublishedCode(jarTask == null ? null : jarTask.getArchivePath());
            }
        }
    });
}
项目:Reer    文件:JavaGradlePluginPlugin.java   
private void configureTaskPropertiesValidation(Project project) {
    ValidateTaskProperties validator = project.getTasks().create(VALIDATE_TASK_PROPERTIES_TASK_NAME, ValidateTaskProperties.class);

    File reportsDir = new File(project.getBuildDir(), "reports");
    File validatorReportsDir = new File(reportsDir, "task-properties");
    validator.setOutputFile(new File(validatorReportsDir, "report.txt"));

    SourceSet mainSourceSet = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
    validator.setClasspath(mainSourceSet.getCompileClasspath());
    validator.setClassesDir(mainSourceSet.getOutput().getClassesDir());
    validator.dependsOn(mainSourceSet.getOutput());

    project.getTasks().getByName(JavaBasePlugin.CHECK_TASK_NAME).dependsOn(validator);
}
项目:jpa2ddl    文件:GeneratePlugin.java   
@Override
public void apply(Project project) {
    GeneratePluginExtension generatePluginExtension = project.getExtensions().create(EXTENSION_NAME,
            GeneratePluginExtension.class, project);

    GenerateTask generateTask = project.getTasks().create(TASK_NAME, GenerateTask.class);
    generateTask.setGroup(BasePlugin.BUILD_GROUP);
    generateTask.setDescription("Generates DDL scripts based on JPA model.");
    generateTask.setExtension(generatePluginExtension);
    generateTask.dependsOn(JavaBasePlugin.BUILD_TASK_NAME);


    project.afterEvaluate(evaluatedProject -> {
        fillDefaults(evaluatedProject, generatePluginExtension);
        SourceSetContainer sourceSets = (SourceSetContainer) project.getProperties().get("sourceSets");
        Set<File> paths;
        if (sourceSets != null) {
            UnionFileCollection mainClasspath = (UnionFileCollection) sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath();
            paths = mainClasspath.getSources()
                    .stream()
                    .filter(fileCollection -> fileCollection instanceof DefaultSourceSetOutput)
                    .map(DefaultSourceSetOutput.class::cast)
                    .flatMap(fileCollection -> fileCollection.getClassesDirs().getFiles().stream())
                    .collect(Collectors.toSet());
        } else {
            paths = new HashSet<>();
        }
        generateTask.setOutputClassesDirs(paths);
    });
}
项目:gradle-site-plugin    文件:SitePlugin.java   
private SiteGenerate createSiteTask(Project project, SitePluginExtension sitePluginExtension) {
    SiteGenerate generateSiteTask = project.getTasks().create(GENERATE_SITE_TASK_NAME, SiteGenerate.class);
    generateSiteTask.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);
    generateSiteTask.setDescription("Generates a web page containing information about the project.");
    generateSiteTask.getOutputDir().set(sitePluginExtension.getOutputDir());
    generateSiteTask.getCustomData().setWebsiteUrl(sitePluginExtension.getWebsiteUrl());
    generateSiteTask.getCustomData().setVcsUrl(sitePluginExtension.getVcsUrl());
    return generateSiteTask;
}
项目:gradle-project-config    文件:JavaConfigPlugin.java   
/**
 * Create integration test task
 *
 * @param tasks Task model
 */
@Mutate
public void createIntegrationTask(ModelMap<Test> tasks) {
    tasks.create(INTEGRATION_SOURCE_SET_NAME, t -> {
        t.setDescription("Runs the integration tests");
        t.setGroup(JavaBasePlugin.VERIFICATION_GROUP);
    });
}
项目:gradle-project-config    文件:JavaConfigPlugin.java   
/**
 * Configure the check task
 *
 * @param tasks Tasks
 */
@Mutate
public void configureCheckTask(ModelMap<Task> tasks) {
    tasks.named(JavaBasePlugin.CHECK_TASK_NAME, t -> {
        t.dependsOn(INTEGRATION_TASK_NAME);
    });
}
项目:gradle-project-config    文件:CheckstyleConfigPlugin.java   
/**
 * Create Checkstyle task
 *
 * @param tasks Task container
 * @param checkstyleConfig Checkstyle configuration
 * @param sources Project sources to run checkstyle on
 */
@Mutate
public void createCheckstyleTask(ModelMap<Task> tasks, CheckstyleConfig checkstyleConfig,
        ProjectSourceSet sources) {
    tasks.create("checkstyle", t -> {
        t.setDescription("Run Checkstyle on all source sets");
        t.setGroup(JavaBasePlugin.VERIFICATION_GROUP);

        for (JavaSourceSet source : sources.withType(JavaSourceSet.class)) {
            if (!checkstyleConfig.getIgnoreSourceSets().contains(source.getParentName())) {
                t.dependsOn(getCheckstyleTaskName(source));
            }
        }
    });
}
项目:android-gradle-plugins    文件:AndroidJavadocPlugin.java   
@Override
public void apply(Project project) {
    super.apply(project);

    allJavadocTask = project.getTasks().create("javadoc", ajdTasks -> {
        ajdTasks.setDescription("Generate Javadoc for all variants");
        ajdTasks.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);
    });

}
项目:android-gradle-plugins    文件:VariantBasedCodeQualityPlugin.java   
private void configureForVariants(DomainObjectSet<? extends BaseVariant> variants) {
    variants.all(sourceSet -> {
        Task task = project.getTasks().create(getTaskName(sourceSet, getTaskBaseName(), null), getCastedTaskType());
        task.setGroup(JavaBasePlugin.VERIFICATION_GROUP);
        configureForVariant(sourceSet, (T)task);
    });
}
项目:android-gradle-plugins    文件:SourceSetBasedCodeQualityPlugin.java   
private void configureForSourceSets(NamedDomainObjectContainer<AndroidSourceSet> sourceSets) {
    sourceSets.all(sourceSet -> {
        Task task = project.getTasks().create(getTaskName(sourceSet, getTaskBaseName(), null), getCastedTaskType());
        task.setGroup(JavaBasePlugin.VERIFICATION_GROUP);
        configureForSourceSet(sourceSet, (T)task);
    });
}
项目:intellij-ce-playground    文件:DependencyManager.java   
private void configureBuild(VariantDependencies configurationDependencies) {
    addDependsOnTaskInOtherProjects(
            project.getTasks().getByName(JavaBasePlugin.BUILD_NEEDED_TASK_NAME), true,
            JavaBasePlugin.BUILD_NEEDED_TASK_NAME, "compile");
    addDependsOnTaskInOtherProjects(
            project.getTasks().getByName(JavaBasePlugin.BUILD_DEPENDENTS_TASK_NAME), false,
            JavaBasePlugin.BUILD_DEPENDENTS_TASK_NAME, "compile");
}
项目:intellij-ce-playground    文件:BaseComponentModelPlugin.java   
/**
 * Replace BasePlugin's apply method for component model.
 */
@Override
public void apply(Project project) {
    ExecutionConfigurationUtil.setThreadPoolSize(project);
    try {
        ProcessRecorderFactory.initialize(
                new LoggerWrapper(project.getLogger()),
                project.getRootProject()
                        .file("profiler" + System.currentTimeMillis() + ".json"));
    } catch (IOException e) {
        throw new RuntimeException("Unable to initialize ProcessRecorderFactory");
    }
    project.getGradle().addListener(new RecordingBuildListener(ThreadRecorder.get()));

    project.getPlugins().apply(AndroidComponentModelPlugin.class);
    project.getPlugins().apply(JavaBasePlugin.class);
    project.getPlugins().apply(JacocoPlugin.class);

    // TODO: Create configurations for build types and flavors, or migrate to new dependency
    // management if it's ready.
    ConfigurationContainer configurations = project.getConfigurations();
    createConfiguration(configurations, "compile", "Classpath for default sources.");
    createConfiguration(configurations, "default-metadata", "Metadata for published APKs");
    createConfiguration(configurations, "default-mapping", "Metadata for published APKs");

    project.getPlugins().apply(NdkComponentModelPlugin.class);

    // Remove this when our models no longer depends on Project.
    modelRegistry.create(ModelCreators
            .bridgedInstance(ModelReference.of("projectModel", Project.class), project)
            .descriptor("Model of project.").build());

    toolingRegistry.register(new ComponentModelBuilder(modelRegistry));

    // Inserting the ToolingModelBuilderRegistry into the model so that it can be use to create
    // TaskManager in child classes.
    modelRegistry.create(ModelCreators.bridgedInstance(
            ModelReference.of("toolingRegistry", ToolingModelBuilderRegistry.class),
            toolingRegistry).descriptor("Tooling model builder model registry.").build());
}
项目:putnami-gradle-plugin    文件:PwtPlugin.java   
private void createCheckTask(final Project project) {
    project.getTasks().create(GwtCheckTask.NAME, GwtCheckTask.class);
    final PutnamiExtension extension = project.getExtensions().getByType(PutnamiExtension.class);
    final Task checkTask = project.getTasks().getByName(JavaBasePlugin.CHECK_TASK_NAME);
    checkTask.dependsOn(GwtCheckTask.NAME);
    project.getTasks().withType(GwtCheckTask.class, new Action<GwtCheckTask>() {
        @Override
        public void execute(final GwtCheckTask task) {
            task.configure(project, extension);
        }
    });
}
项目:checkstyle-addons    文件:TaskCreator.java   
/**
 * Set up cross-check feature. We provide an 'xcheck' task which depends on a number of Test tasks that run the
 * unit tests compiled against every Checkstyle version against all the other Checkstyle libraries. In this way, we
 * find out which versions are compatible.
 */
public void setupCrossCheckTasks()
{
    final TaskContainer tasks = project.getTasks();

    final Task xtest = tasks.create(XTEST_TASK_NAME);
    xtest.setGroup(XTEST_GROUP_NAME);
    xtest.setDescription(
        buildUtil.getLongName() + ": Run the unit tests against all supported Checkstyle runtimes");
    tasks.getByName(JavaBasePlugin.BUILD_TASK_NAME).dependsOn(xtest);

    for (final DependencyConfig depConfig : buildUtil.getDepConfigs().getAll().values()) {
        final JavaVersion javaLevel = depConfig.getJavaLevel();
        final String csBaseVersion = depConfig.getCheckstyleBaseVersion();
        for (final String csRuntimeVersion : depConfig.getCompatibleCheckstyleVersions()) {
            if (csBaseVersion.equals(csRuntimeVersion)) {
                continue;
            }

            final TestTask testTask = tasks.create(TaskNames.xtest.getName(depConfig, csRuntimeVersion),
                TestTask.class);
            testTask.configureFor(depConfig, csRuntimeVersion);
            testTask.setGroup(XTEST_GROUP_NAME);
            testTask.setDescription(
                buildUtil.getLongName() + ": Run the unit tests compiled for Checkstyle " + csBaseVersion
                    + " against a Checkstyle " + csRuntimeVersion + " runtime (Java level: " + javaLevel + ")");
            testTask.getReports().getHtml().setEnabled(false);
            xtest.dependsOn(testTask);
        }
    }
}
项目:Reer    文件:AbstractCodeQualityPlugin.java   
protected Class<? extends Plugin> getBasePlugin() {
    return JavaBasePlugin.class;
}
项目:Reer    文件:EclipsePlugin.java   
private void configureEclipseClasspath(final Project project, final EclipseModel model) {
    model.setClasspath(instantiator.newInstance(EclipseClasspath.class, project));
    ((IConventionAware) model.getClasspath()).getConventionMapping().map("defaultOutputDir", new Callable<File>() {
        @Override
        public File call() {
            return new File(project.getProjectDir(), "bin");
        }

    });

    final EclipsePlugin eclipsePlugin = this;
    project.getPlugins().withType(JavaBasePlugin.class, new Action<JavaBasePlugin>() {
        @Override
        public void execute(JavaBasePlugin javaBasePlugin) {
            maybeAddTask(project, eclipsePlugin, ECLIPSE_CP_TASK_NAME, GenerateEclipseClasspath.class, new Action<GenerateEclipseClasspath>() {
                @Override
                public void execute(final GenerateEclipseClasspath task) {
                    //task properties:
                    task.setDescription("Generates the Eclipse classpath file.");
                    task.setInputFile(project.file(".classpath"));
                    task.setOutputFile(project.file(".classpath"));

                    //model properties:
                    task.setClasspath(model.getClasspath());
                    task.getClasspath().setFile(new XmlFileContentMerger(task.getXmlTransformer()));
                    task.getClasspath().setSourceSets(project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets());

                    AfterEvaluateHelper.afterEvaluateOrExecute(project, new Action<Project>() {
                        @Override
                        public void execute(Project p) {
                            // keep the ordering we had in earlier gradle versions
                            Set<String> containers = Sets.newLinkedHashSet();
                            containers.add("org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/" + model.getJdt().getJavaRuntimeName() + "/");
                            containers.addAll(task.getClasspath().getContainers());
                            task.getClasspath().setContainers(containers);
                        }

                    });

                    project.getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {
                        @Override
                        public void execute(JavaPlugin javaPlugin) {
                            configureJavaClasspath(project, task);
                        }

                    });

                    configureScalaDependencies(project, task);
                }

            });
        }

    });
}
项目:Reer    文件:EclipsePlugin.java   
private void configureEclipseJdt(final Project project, final EclipseModel model) {
    final EclipsePlugin eclipsePlugin = this;
    project.getPlugins().withType(JavaBasePlugin.class, new Action<JavaBasePlugin>() {
        @Override
        public void execute(JavaBasePlugin javaBasePlugin) {
            maybeAddTask(project, eclipsePlugin, ECLIPSE_JDT_TASK_NAME, GenerateEclipseJdt.class, new Action<GenerateEclipseJdt>() {
                @Override
                public void execute(GenerateEclipseJdt task) {
                    //task properties:
                    task.setDescription("Generates the Eclipse JDT settings file.");
                    task.setOutputFile(project.file(".settings/org.eclipse.jdt.core.prefs"));
                    task.setInputFile(project.file(".settings/org.eclipse.jdt.core.prefs"));
                    //model properties:
                    EclipseJdt jdt = task.getJdt();
                    model.setJdt(jdt);
                    ConventionMapping conventionMapping = ((IConventionAware) jdt).getConventionMapping();
                    conventionMapping.map("sourceCompatibility", new Callable<JavaVersion>() {
                        @Override
                        public JavaVersion call() {
                            return project.getConvention().getPlugin(JavaPluginConvention.class).getSourceCompatibility();
                        }

                    });
                    conventionMapping.map("targetCompatibility", new Callable<JavaVersion>() {
                        @Override
                        public JavaVersion call() {
                            return project.getConvention().getPlugin(JavaPluginConvention.class).getTargetCompatibility();
                        }

                    });
                    conventionMapping.map("javaRuntimeName", new Callable<String>() {
                        @Override
                        public String call() {
                            return "JavaSE-" + project.getConvention().getPlugin(JavaPluginConvention.class).getTargetCompatibility();
                        }

                    });
                }

            });
        }

    });
}
项目:Reer    文件:IdeaPlugin.java   
@Override
public boolean apply(Project project) {
    return project.getPlugins().hasPlugin(IdeaPlugin.class) && project.getPlugins().hasPlugin(JavaBasePlugin.class);
}
项目:gradle-clojure    文件:ClojureBasePlugin.java   
@Override
public void apply(Project project) {
  project.getPluginManager().apply(JavaBasePlugin.class);

  configureSourceSetDefaults(project);
}
项目: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());
    }
项目:android-gradle-plugins    文件:AbstractAndroidCodeQualityPlugin.java   
protected Class<? extends Plugin> getBasePlugin() {
    return JavaBasePlugin.class;
}
项目:intellij-ce-playground    文件:TaskManager.java   
/**
 * Create tasks before the evaluation (on plugin apply). This is useful for tasks that
 * could be referenced by custom build logic.
 */
public void createTasksBeforeEvaluate(@NonNull TaskFactory tasks) {
    tasks.create(UNINSTALL_ALL, new Action<Task>() {
        @Override
        public void execute(Task uninstallAllTask) {
            uninstallAllTask.setDescription("Uninstall all applications.");
            uninstallAllTask.setGroup(INSTALL_GROUP);
        }
    });

    tasks.create(DEVICE_CHECK, new Action<Task>() {
        @Override
        public void execute(Task deviceCheckTask) {
            deviceCheckTask.setDescription(
                    "Runs all device checks using Device Providers and Test Servers.");
            deviceCheckTask.setGroup(JavaBasePlugin.VERIFICATION_GROUP);
        }
    });

    tasks.create(CONNECTED_CHECK, new Action<Task>() {
        @Override
        public void execute(Task connectedCheckTask) {
            connectedCheckTask.setDescription(
                    "Runs all device checks on currently connected devices.");
            connectedCheckTask.setGroup(JavaBasePlugin.VERIFICATION_GROUP);
        }
    });

    tasks.create(MAIN_PREBUILD);

    tasks.create(SOURCE_SETS, SourceSetsTask.class, new Action<SourceSetsTask>() {
        @Override
        public void execute(SourceSetsTask sourceSetsTask) {
            sourceSetsTask.setConfig(extension);
            sourceSetsTask.setDescription(
                    "Prints out all the source sets defined in this project.");
            sourceSetsTask.setGroup(ANDROID_GROUP);
        }
    });

    tasks.create(ASSEMBLE_ANDROID_TEST, new Action<Task>() {
        @Override
        public void execute(Task assembleAndroidTestTask) {
            assembleAndroidTestTask.setGroup(BasePlugin.BUILD_GROUP);
            assembleAndroidTestTask.setDescription("Assembles all the Test applications.");
        }
    });

    tasks.create(LINT, Lint.class, new Action<Lint>() {
        @Override
        public void execute(Lint lintTask) {
            lintTask.setDescription("Runs lint on all variants.");
            lintTask.setGroup(JavaBasePlugin.VERIFICATION_GROUP);
            lintTask.setLintOptions(getExtension().getLintOptions());
            lintTask.setSdkHome(sdkHandler.getSdkFolder());
            lintTask.setToolingRegistry(toolingRegistry);
        }
    });
    tasks.named(JavaBasePlugin.CHECK_TASK_NAME, new Action<Task>() {
        @Override
        public void execute(Task it) {
            it.dependsOn(LINT);
        }
    });
    createLintCompileTask(tasks);
}
项目:intellij-ce-playground    文件:TaskManager.java   
private void createUnitTestTask(@NonNull TaskFactory tasks,
        @NonNull final TestVariantData variantData) {
    final BaseVariantData testedVariantData =
            (BaseVariantData) variantData.getTestedVariantData();

    final Test runTestsTask = project.getTasks().create(
            variantData.getScope().getTaskName(UNIT_TEST.getPrefix()),
            Test.class);
    runTestsTask.setGroup(JavaBasePlugin.VERIFICATION_GROUP);
    runTestsTask.setDescription(
            "Run unit tests for the " +
                    testedVariantData.getVariantConfiguration().getFullName() + " build.");

    fixTestTaskSources(runTestsTask);

    runTestsTask.dependsOn(variantData.assembleVariantTask);

    final AbstractCompile testCompileTask = variantData.javacTask;
    runTestsTask.setTestClassesDir(testCompileTask.getDestinationDir());

    ConventionMappingHelper.map(runTestsTask, "classpath",
            new Callable<ConfigurableFileCollection>() {
                @Override
                public ConfigurableFileCollection call() throws Exception {
                    Iterable<File> filteredBootClasspath = Iterables.filter(
                            androidBuilder.getBootClasspath(),
                            new Predicate<File>() {
                                @Override
                                public boolean apply(@Nullable File file) {
                                    return file != null &&
                                            !SdkConstants.FN_FRAMEWORK_LIBRARY
                                                    .equals(file.getName());
                                }
                            });

                    return project.files(
                            testCompileTask.getClasspath(),
                            testCompileTask.getOutputs().getFiles(),
                            variantData.processJavaResourcesTask.getOutputs(),
                            testedVariantData.processJavaResourcesTask.getOutputs(),
                            filteredBootClasspath,
                            // Mockable JAR is last, to make sure you can shadow the classes
                            // withdependencies.
                            createMockableJar.getOutputFile());
                }
            });

    // Put the variant name in the report path, so that different testing tasks don't
    // overwrite each other's reports.
    TestTaskReports testTaskReports = runTestsTask.getReports();

    for (ConfigurableReport report : new ConfigurableReport[] {
            testTaskReports.getJunitXml(), testTaskReports.getHtml()}) {
        report.setDestination(new File(report.getDestination(), testedVariantData.getName()));
    }

    tasks.named(JavaPlugin.TEST_TASK_NAME, new Action<Task>() {
        @Override
        public void execute(Task test) {
            test.dependsOn(runTestsTask);
        }

    });

    extension.getTestOptions().getUnitTests().applyConfiguration(runTestsTask);
}
项目:spotless    文件:SpotlessPlugin.java   
@SuppressWarnings("rawtypes")
void createTasks(Project project) {
    Task rootCheckTask = project.task(EXTENSION + CHECK);
    rootCheckTask.setGroup(TASK_GROUP);
    rootCheckTask.setDescription(CHECK_DESCRIPTION);
    Task rootApplyTask = project.task(EXTENSION + APPLY);
    rootApplyTask.setGroup(TASK_GROUP);
    rootApplyTask.setDescription(APPLY_DESCRIPTION);

    spotlessExtension.formats.forEach((key, value) -> {
        // create the task that does the work
        String taskName = EXTENSION + capitalize(key);
        SpotlessTask spotlessTask = project.getTasks().create(taskName, SpotlessTask.class);
        value.setupTask(spotlessTask);

        // create the check and apply control tasks
        Task checkTask = project.getTasks().create(taskName + CHECK);
        Task applyTask = project.getTasks().create(taskName + APPLY);
        // the root tasks depend on them
        rootCheckTask.dependsOn(checkTask);
        rootApplyTask.dependsOn(applyTask);
        // and they depend on the work task
        checkTask.dependsOn(spotlessTask);
        applyTask.dependsOn(spotlessTask);

        // when the task graph is ready, we'll configure the spotlessTask appropriately
        project.getGradle().getTaskGraph().whenReady(new Closure(null) {
            private static final long serialVersionUID = 1L;

            // called by gradle
            @SuppressFBWarnings("UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS")
            public Object doCall(TaskExecutionGraph graph) {
                if (graph.hasTask(checkTask)) {
                    spotlessTask.setCheck();
                }
                if (graph.hasTask(applyTask)) {
                    spotlessTask.setApply();
                }
                return Closure.DONE;
            }
        });
    });

    // Add our check task as a dependency on the global check task
    // getTasks() returns a "live" collection, so this works even if the
    // task doesn't exist at the time this call is made
    if (spotlessExtension.enforceCheck) {
        project.getTasks()
                .matching(task -> task.getName().equals(JavaBasePlugin.CHECK_TASK_NAME))
                .all(task -> task.dependsOn(rootCheckTask));
    }

    // clear spotless' cache when the user does a clean, but only after any spotless tasks
    Task clean = project.getTasks().getByName(BasePlugin.CLEAN_TASK_NAME);
    clean.doLast(unused -> SpotlessCache.clear());
    project.getTasks()
            .withType(SpotlessTask.class)
            .all(task -> task.mustRunAfter(clean));
}
项目:checkstyle-addons    文件:TestTask.java   
public void configureFor(@Nonnull final DependencyConfig pDepConfig, @Nonnull final String pCsVersion)
{
    final Project project = getProject();
    final JavaVersion javaLevel = pDepConfig.getJavaLevel();
    final String baseCsVersion = pDepConfig.getCheckstyleBaseVersion();

    if (baseCsVersion.equals(pCsVersion)) {
        setDescription(
            buildUtil.getLongName() + ": Run the unit tests using dependency configuration '" + pDepConfig.getName()
                + "' (Checkstyle " + baseCsVersion + ", Java level: " + javaLevel + ")");
    }
    else {
        setDescription(buildUtil.getLongName() + ": Run the unit tests compiled for Checkstyle " + baseCsVersion
            + " against a Checkstyle " + pCsVersion + " runtime (Java level: " + javaLevel + ")");
    }

    dependsOn(TaskNames.testClasses.getName(pDepConfig));

    configure(buildUtil.getExtraPropertyValue(ExtProp.TestConfigClosure));
    setTestClassesDirs(project.files(((JavaCompile) buildUtil.getTask(TaskNames.compileTestJava, pDepConfig))
        .getDestinationDir()));

    if (baseCsVersion.equals(pCsVersion)) {
        project.getTasks().getByName(JavaBasePlugin.CHECK_TASK_NAME).dependsOn(this);
    }

    final JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
    getReports().getHtml().setDestination(new File(javaConvention.getTestReportDir(), getName()));

    final JacocoTaskExtension jacoco = (JacocoTaskExtension) getExtensions().getByName(
        JacocoPluginExtension.TASK_EXTENSION_NAME);
    jacoco.setEnabled(false);

    setClasspath(new ClasspathBuilder(project)
        .buildClassPath(pDepConfig, pCsVersion, true, buildUtil.getSourceSet(SourceSet.TEST_SOURCE_SET_NAME),
            buildUtil.getSourceSet(SourceSet.MAIN_SOURCE_SET_NAME),
            buildUtil.getSourceSet(BuildUtil.SONARQUBE_SOURCE_SET_NAME)));

    final JavaLevelUtil javaLevelUtil = new JavaLevelUtil(project);
    if (javaLevelUtil.isOlderSupportedJava(javaLevel)) {
        setExecutable(javaLevelUtil.getJvmExecutable(javaLevel));
    }
}
项目:checkstyle-addons    文件:JavadocTask.java   
public JavadocTask()
{
    super();
    buildUtil = new BuildUtil(getProject());
    setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);
}