private void configureTestTasks(final Project project, final ImmutableSet<String> moduleNameIset) { project.getTasks().withType(Test.class).forEach(test -> configureTestTask(test, moduleNameIset)); }
private void configureJavaExecTasks(final Project project, final String mainModuleName) { project.getTasks().withType(JavaExec.class).forEach(javaExec -> configureJavaExecTask(javaExec, mainModuleName)); }
private void configureJavadocTasks(final Project project, final ImmutableSet<String> moduleNameIset) { project.getTasks().withType(Javadoc.class).forEach(javadoc -> configureJavadocTask(javadoc, moduleNameIset)); }
private void configureCreateStartScriptsTasks(final Project project, final String mainModuleName) { project.getTasks().withType(CreateStartScripts.class).forEach(css -> configureCreateStartScriptsTask(css, mainModuleName)); }
private void configureJavaCompileTasks(final Project project, final ImmutableBiMap<String, String> moduleNameIbiTaskName) { final ImmutableSet<File> outputDirFileIset = getSourceSets(project).stream().flatMap(ss -> stream(ss.getOutput())).collect(toImmutableSet()); project.getTasks().withType(JavaCompile.class).forEach(javaCompile -> configureJavaCompileTask(javaCompile, outputDirFileIset, moduleNameIbiTaskName.get(javaCompile.getName()))); }
private void createDownloadCloudSdkTask() { project .getTasks() .create( DOWNLOAD_CLOUD_SDK_TASK_NAME, DownloadCloudSdkTask.class, downloadCloudSdkTask -> { downloadCloudSdkTask.setGroup(taskGroup); downloadCloudSdkTask.setDescription("Download the Cloud SDK"); downloadCloudSdkTask.requiresAppEngineJava(requiresAppEngineJava); project.afterEvaluate( p -> { if (managedCloudSdk != null) { downloadCloudSdkTask.setManagedCloudSdk(managedCloudSdk); p.getTasks() .matching(task -> task.getName().startsWith("appengine")) .forEach(task -> task.dependsOn(downloadCloudSdkTask)); } }); }); }
private void verify(Project p) { p.getTasks().withType(SpotBugsTask.class).forEach(task -> { SpotBugsReports reports = task.getReports(); if (reports.getText() != null && reports.getText().getDestination() == null) { String message = String.format( "Task '%s' has no destination for TEXT report. Set reports.text.destination to this task.", task.getName()); throw new IllegalStateException(message); } if (reports.getXml() != null && reports.getXml().getDestination() == null) { String message = String.format( "Task '%s' has no destination for XML report. Set reports.xml.destination to this task.", task.getName()); throw new IllegalStateException(message); } if (reports.getHtml() != null && reports.getHtml().getDestination() == null) { String message = String.format( "Task '%s' has no destination for HTML report. Set reports.html.destination. to this task", task.getName()); throw new IllegalStateException(message); } if (reports.getEmacs() != null && reports.getEmacs().getDestination() == null) { String message = String.format( "Task '%s' has no destination for EMACS report. Set reports.emacs.destination. to this task", task.getName()); throw new IllegalStateException(message); } }); }
private void verify(Project p) { p.getTasks().withType(SpotBugsTask.class).forEach(task -> { SpotBugsReports reports = task.getReports(); if (reports.getText() != null && reports.getText().getDestination() == null) { String message = String.format( "Task '%s' has no destination for TEXT report. Set reports.text.destination to this task.", task.getName()); throw new IllegalStateException(message); } if (reports.getXml() != null && reports.getXml().getDestination() == null) { String message = String.format( "Task '%s' has no destination for XML report. Set reports.xml.destination to this task.", task.getName()); throw new IllegalStateException(message); } if (reports.getHtml() != null && reports.getHtml().getDestination() == null) { String message = String.format( "Task '%s' has no destination for HTML report. Set reports.html.destination. to this task", task.getName()); throw new IllegalStateException(message); } if (reports.getEmacs() != null && reports.getEmacs().getDestination() == null) { String message = String.format( "Task '%s' has no destination for EMACS report. Set reports.emacs.destination. to this task", task.getName()); throw new IllegalStateException(message); } }); }
private void createCheckCloudSdkTask() { project .getTasks() .create( CHECK_CLOUD_SDK_TASK_NAME, CheckCloudSdkTask.class, checkCloudSdkTask -> { checkCloudSdkTask.setGroup(taskGroup); checkCloudSdkTask.setDescription("Validates the Cloud SDK"); project.afterEvaluate( p -> { if (managedCloudSdk == null && toolsExtension.getCloudSdkVersion() != null) { checkCloudSdkTask.setVersion(toolsExtension.getCloudSdkVersion()); checkCloudSdkTask.setCloudSdk(cloudSdkOperations.getCloudSdk()); checkCloudSdkTask.requiresAppEngineJava(requiresAppEngineJava); p.getTasks() .matching(task -> task.getName().startsWith("appengine")) .forEach(task -> task.dependsOn(checkCloudSdkTask)); } }); }); }
/** * Applies the {@link JavaPlugin}. * * @param project * the {@link Project} that the {@link Plugin} is applied to */ private void applyJavaPlugin(Project project) { project.getPluginManager().apply(JavaPlugin.class); JavaPluginConvention javaPluginConv = project.getConvention().findPlugin(JavaPluginConvention.class); javaPluginConv.setSourceCompatibility(JavaVersion.VERSION_1_8); javaPluginConv.setTargetCompatibility(JavaVersion.VERSION_1_8); project.getTasks().withType(JavaCompile.class).forEach(task -> task.getOptions().setEncoding("UTF-8")); }
.withType(GenerateApi.class) .matching(generateTask -> isAncestorOf(generateTask.getProject(), project)) .forEach(generateTask -> generateTask.dependsOn(scanTask)); }); });
private void configureCompileTestJavaTask(final JavaCompile compileTestJava, final String moduleName) { setModuleNamesInputProperty(compileTestJava, moduleName); compileTestJava.doFirst(task -> { final Project project = compileTestJava.getProject(); final List<String> args = compileTestJava.getOptions().getCompilerArgs(); addModulePathArgument(args, compileTestJava.getClasspath()); project.getTasks().withType(Test.class).forEach(test -> KnownTestFrameworkModuleInfo.from(test).configureCompileTestJavaTask(args, moduleName)); addPatchModuleArgument(args, moduleName, getSourceSets(project).getByName(TEST_SOURCE_SET_NAME).getJava().getSourceDirectories()); compileTestJava.setClasspath(project.files()); }); }
@Test public void testMinikubeExtensionSetProperties() { Project project = ProjectBuilder.builder().withProjectDir(tmp.getRoot()).build(); project.getPluginManager().apply(MinikubePlugin.class); MinikubeExtension ex = (MinikubeExtension) project.getExtensions().getByName("minikube"); ex.setMinikube("/custom/minikube/path"); TaskContainer t = project.getTasks(); TaskCollection<MinikubeTask> tc = t.withType(MinikubeTask.class); Assert.assertEquals(3, tc.size()); tc.forEach( minikubeTask -> { Assert.assertEquals(minikubeTask.getMinikube(), "/custom/minikube/path"); }); }