.matching(task -> task.getName().equals(JavaBasePlugin.CHECK_TASK_NAME)) .all(task -> task.dependsOn(rootCheckTask));
@Override public void execute(AppliedPlugin appliedPlugin) { project.getTasks().matching(new Spec<Task>() { @Override public boolean isSatisfiedBy(Task task) { String compilationTaskName = sourceSet.getCompileTaskName("kotlin"); return compilationTaskName.equals(task.getName()); } }) .all(new Action<Task>() { @Override public void execute(Task task) { if (task instanceof SourceTask) { ((SourceTask) task).source(javaTask.getOutputs()); } else { task.dependsOn(javaTask); } } }); } });
/** * Applies the debugging plugin to a project * @param project A Gradle project instance */ @Override public void apply(Project project) { this.project = project; debuggableTasks = project.getTasks().matching(JavaForkOptions.class::isInstance); debuggableTasks.all(this::setupExtendedDebug); project.getExtensions().getExtraProperties().set(Debug.class.getSimpleName(), Debug.class); project.getExtensions().add(DEBUG_CONFIGURATION_CONTAINER, createDebuggingContainer()); }
private void setDefaults() { setDescription("Creates the CQ Package zip file"); getProject().getTasks(). matching(it -> it instanceof VerifyBundlesTask || it instanceof AddBundlesToFilterXmlTask). all(it -> this.dependsOn(it)); fileExclusions = new ArrayList<>(Arrays.asList("**/.git", "**/.git/**", "**/.gitattributes", "**/.gitignore", "**/.gitmodules", "**/.vlt", "jcr_root/.vlt-sync-config.properties", "jcr_root/var/**", "SLING-INF/**")); setContentSrc(getProject().file("src/main/content")); }
static boolean configureTask(Task snapshotTask, List<String> taskNames) { boolean isSnapshot = taskNames.contains(SNAPSHOT_TASK); if (isSnapshot) { snapshotTask.getProject().getTasks().matching(withName("javadoc", "groovydoc")).all(doc -> { LOG.info("{} - disabled to speed up the 'snapshot' build", snapshotTask.getPath()); doc.setEnabled(false); }); } return isSnapshot; }
static boolean configureTask(Task snapshotTask, List<String> taskNames) { boolean isSnapshot = taskNames.contains(SNAPSHOT_TASK); if (isSnapshot) { snapshotTask.getProject().getTasks().matching(withName("javadoc", "groovydoc")).all(doc -> { LOG.info("{} - disabled to speed up the 'snapshot' build", snapshotTask.getPath()); doc.setEnabled(false); }); } return isSnapshot; }
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)); } }); }); }
@Override public void apply(final Project project) { project.getPlugins().apply(GitHubContributorsPlugin.class); final Task fetcher = project.getTasks().getByName(GitHubContributorsPlugin.FETCH_CONTRIBUTORS); project.allprojects(subproject -> subproject.getPlugins().withType(JavaBintrayPlugin.class, plugin -> { //Because maven-publish plugin uses new configuration model, we cannot get the task directly //So we use 'matching' technique. subproject.getTasks().matching(withName(POM_TASK)).all(t -> t.mustRunAfter(fetcher)); //Pom task needs data from fetcher hence 'mustRunAfter' above. //We don't use 'dependsOn' because we want the fetcher to be included only when we are publishing to Bintray Task upload = subproject.getTasks().getByName(ShipkitBintrayPlugin.BINTRAY_UPLOAD_TASK); upload.dependsOn(fetcher); })); } }
@Override public void apply(final Project project) { project.getPlugins().apply(GitHubContributorsPlugin.class); final Task fetcher = project.getTasks().getByName(GitHubContributorsPlugin.FETCH_CONTRIBUTORS); project.allprojects(subproject -> subproject.getPlugins().withType(JavaBintrayPlugin.class, plugin -> { //Because maven-publish plugin uses new configuration model, we cannot get the task directly //So we use 'matching' technique. subproject.getTasks().matching(withName(POM_TASK)).all(t -> t.mustRunAfter(fetcher)); //Pom task needs data from fetcher hence 'mustRunAfter' above. //We don't use 'dependsOn' because we want the fetcher to be included only when we are publishing to Bintray Task upload = subproject.getTasks().getByName(ShipkitBintrayPlugin.BINTRAY_UPLOAD_TASK); upload.dependsOn(fetcher); })); } }
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)); } }); }); }
@Test public void testAppEngineTaskGroupAssignment() { Project p = new TestProject(testProjectDir.getRoot()).applyAppYamlProjectBuilder(); p.getTasks() .matching(task -> task.getName().startsWith("appengine")) .all( task -> assertEquals( AppEngineAppYamlPlugin.APP_ENGINE_APP_YAML_TASK_GROUP, task.getGroup())); } }
@Test public void testAppEngineTaskGroupAssignment() throws IOException { Project p = new TestProject(testProjectDir.getRoot()) .addAppEngineWebXml() .applyStandardProjectBuilder(); p.getTasks() .matching(task -> task.getName().startsWith("appengine")) .all( task -> assertEquals( AppEngineStandardPlugin.APP_ENGINE_STANDARD_TASK_GROUP, task.getGroup())); } }
TaskCollection<Task> matching = p.getTasks().matching(t -> t instanceof SupportPortalDownload); unpackPlatform.dependsOn(matching); });
tasks.matching(it -> it instanceof SupportsWheelCache && !(it instanceof ProvidesVenv)
tasks.matching(it -> it instanceof SupportsWheelCache && !(it instanceof ProvidesVenv)