Java 类org.gradle.api.tasks.TaskCollection 实例源码

项目:minikube-build-tools-for-java    文件:MinikubePluginTest.java   
@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");
      });
}
项目:atlas    文件:TransformManager.java   
public static List<TransformTask> findTransformTaskByTransformType(AppVariantContext appVariantContext, Class<?>
    transformClass) {
    List<TransformTask> transformTasksList = Lists.newArrayList();
    VariantConfiguration config = appVariantContext.getVariantConfiguration();
    TaskCollection<TransformTask> transformTasks = appVariantContext.getProject().getTasks().withType(
        TransformTask.class);
    SortedMap<String, TransformTask> transformTaskSortedMap = transformTasks.getAsMap();
    String variantName = config.getFullName();
    for (String taskName : transformTaskSortedMap.keySet()) {
        TransformTask transformTask = transformTaskSortedMap.get(taskName);
        if (variantName == transformTask.getVariantName()) {
            if (transformTask.getTransform().getClass() == transformClass) {
                transformTasksList.add(transformTask);
            }
        }
    }
    return transformTasksList;
}
项目:wildfly-swarm    文件:PackagePlugin.java   
/**
 * Returns the most suitable Archive-Task for wrapping in the swarm jar - in the following order:
 *
 * 1. Custom-JAR-Task defined in SwarmExtension 'archiveTask'
 * 2. WAR-Task
 * 3. JAR-Task
 */
private Jar getArchiveTask(Project project) {

    TaskCollection<Jar> existingArchiveTasks = project.getTasks().withType(Jar.class);
    Jar customArchiveTask = project.getExtensions().getByType(SwarmExtension.class).getArchiveTask();

    if (customArchiveTask != null) {
        return existingArchiveTasks.getByName(customArchiveTask.getName());

    } else if (existingArchiveTasks.findByName(WarPlugin.WAR_TASK_NAME) != null) {
        return existingArchiveTasks.getByName(WarPlugin.WAR_TASK_NAME);

    } else if (existingArchiveTasks.findByName(JavaPlugin.JAR_TASK_NAME) != null) {
        return existingArchiveTasks.getByName(JavaPlugin.JAR_TASK_NAME);
    }

    return null;
}
项目:enunciate-gradle    文件:EnunciateTask.java   
private List<String> buildCompilerArgs(JavaPluginConvention javaPluginConvention) {
    TaskCollection<JavaCompile> javaCompilers = getProject().getTasks().withType(JavaCompile.class);
    CompileOptions firstCompilerOptions = javaCompilers.isEmpty() ? null : javaCompilers.iterator().next().getOptions();

    List<String> args = new ArrayList<>(Arrays.asList("-source", javaPluginConvention.getSourceCompatibility().toString(),
                                                      "-target", javaPluginConvention.getTargetCompatibility().toString(),
                                                      "-encoding", getDefaultOrCompilerEncoding(firstCompilerOptions)));

    if (firstCompilerOptions != null) {
        FileCollection bootClasspath = firstCompilerOptions.getBootstrapClasspath();
        if (bootClasspath != null) {
            args.add("-bootclasspath");
            args.add(bootClasspath.getAsPath());
        }
    }

    return args;
}
项目:javaccPlugin    文件:CompileJjtreeTask.java   
@TaskAction
public void run() {
    TaskCollection<JavaCompile> javaCompileTasks = this.getProject().getTasks().withType(JavaCompile.class);
    CompilerInputOutputConfiguration inputOutputDirectories
        = new JavaccCompilerInputOutputConfiguration(getInputDirectory(), getOutputDirectory(), getSource(), javaCompileTasks);
    JjtreeProgramInvoker jjtreeInvoker = new JjtreeProgramInvoker(getProject(), getClasspath(), inputOutputDirectories.getTempOutputDirectory());
    ProgramArguments arguments = new ProgramArguments();
    arguments.addAll(getArguments());
    SourceFileCompiler compiler = new JavaccSourceFileCompiler(jjtreeInvoker, arguments, inputOutputDirectories, getLogger());

    compiler.createTempOutputDirectory();
    compiler.compileSourceFilesToTempOutputDirectory();
    compiler.copyCompiledFilesFromTempOutputDirectoryToOutputDirectory();
    compiler.copyNonJavaccFilesToOutputDirectory();
    compiler.cleanTempOutputDirectory();
}
项目:javaccPlugin    文件:CompileJavaccTask.java   
@TaskAction
public void run() {
    TaskCollection<JavaCompile> javaCompileTasks = this.getProject().getTasks().withType(JavaCompile.class);
    CompilerInputOutputConfiguration inputOutputDirectories
        = new JavaccCompilerInputOutputConfiguration(getInputDirectory(), getOutputDirectory(), getSource(), javaCompileTasks);
    JavaccProgramInvoker javaccInvoker = new JavaccProgramInvoker(getProject(), getClasspath(), inputOutputDirectories.getTempOutputDirectory());
    ProgramArguments arguments = new ProgramArguments();
    arguments.addAll(getArguments());
    SourceFileCompiler compiler = new JavaccSourceFileCompiler(javaccInvoker, arguments, inputOutputDirectories, getLogger());

    compiler.createTempOutputDirectory();
    compiler.compileSourceFilesToTempOutputDirectory();
    compiler.copyCompiledFilesFromTempOutputDirectoryToOutputDirectory();
    compiler.copyNonJavaccFilesToOutputDirectory();
    compiler.cleanTempOutputDirectory();
}
项目:javaccPlugin    文件:JavaToJavaccDependencyActionTest.java   
@Test
public void generatedJavaFilesFromCompileJavaccAreAddedToMainJavaSourceSet() {
    applyJavaccPluginToProject();
    applyJavaPluginToProject();
    JavaToJavaccDependencyAction action = new JavaToJavaccDependencyAction();
    final File outputDirectory = new File(getClass().getResource("/javacc/testgenerated").getFile());
    CompileJavaccTask compileJavaccTask = (CompileJavaccTask) project.getTasks().findByName(CompileJavaccTask.TASK_NAME_VALUE);
    compileJavaccTask.setOutputDirectory(outputDirectory);

    action.execute(project);

    TaskCollection<JavaCompile> javaCompilationTasks = project.getTasks().withType(JavaCompile.class);
    for (JavaCompile task : javaCompilationTasks) {
        assertTrue(task.getSource().contains(new File(outputDirectory, "someSourceFile.txt")));
    }
}
项目:javaccPlugin    文件:JavaToJavaccDependencyActionTest.java   
@Test
public void compileJavaccDependOnCompileJJTreeWhenInputDirectoryNotEmpty() {
    applyJavaPluginToProject();
    applyJavaccPluginToProject();
    JavaToJavaccDependencyAction action = new JavaToJavaccDependencyAction();

    final File inputDirectory = new File(getClass().getResource("/jjtree/input").getFile());
    CompileJjtreeTask compileJjtreeTask = (CompileJjtreeTask) project.getTasks().findByName(CompileJjtreeTask.TASK_NAME_VALUE);
    compileJjtreeTask.setInputDirectory(inputDirectory);

    action.execute(project);

    TaskCollection<CompileJavaccTask> compileJavaccTasks = project.getTasks().withType(CompileJavaccTask.class);
    for (CompileJavaccTask task : compileJavaccTasks) {
        Set<Object> dependencies = task.getDependsOn();
        assertTrue(dependencies.contains(project.getTasks().findByName(CompileJjtreeTask.TASK_NAME_VALUE)));
    }
}
项目:javaccPlugin    文件:JavaToJavaccDependencyActionTest.java   
@Test
public void compileJavaccDoesNotDependOnCompileJJTreeWhenInputDirectoryEmpty() {
    applyJavaPluginToProject();
    applyJavaccPluginToProject();
    JavaToJavaccDependencyAction action = new JavaToJavaccDependencyAction();

    final File inputDirectory = new File(getClass().getResource("/empty").getFile());
    CompileJjtreeTask compileJjtreeTask = (CompileJjtreeTask) project.getTasks().findByName(CompileJjtreeTask.TASK_NAME_VALUE);
    compileJjtreeTask.setInputDirectory(inputDirectory);

    action.execute(project);

    TaskCollection<CompileJavaccTask> compileJavaccTasks = project.getTasks().withType(CompileJavaccTask.class);
    for (CompileJavaccTask task : compileJavaccTasks) {
        Set<Object> dependencies = task.getDependsOn();
        assertFalse(dependencies.contains(project.getTasks().findByName(CompileJjtreeTask.TASK_NAME_VALUE)));
    }
}
项目:Reer    文件:JacocoReport.java   
/**
 * Adds execution data generated by the given tasks to the list of those used during coverage analysis. Only tasks with a {@link JacocoTaskExtension} will be included; all others will be ignored.
 *
 * @param tasks one or more tasks to add
 */
public void executionData(TaskCollection tasks) {
    tasks.all(new Action<Task>() {
        @Override
        public void execute(Task task) {
            executionData(task);
        }
    });
}
项目:Reer    文件:JacocoMerge.java   
/**
 * Adds execution data generated by the given tasks to the list of those merged. Only tasks with a {@link JacocoTaskExtension} will be included; all others will be ignored.
 *
 * @param tasks one or more tasks to merge
 */
public void executionData(TaskCollection tasks) {
    tasks.all(new Action<Task>() {
        @Override
        public void execute(Task task) {
            executionData(task);
        }
    });
}
项目:Reer    文件:JacocoPluginExtension.java   
/**
 * Applies Jacoco to all of the given tasks.
 *
 * @param tasks the tasks to apply Jacoco to
 */
public <T extends Task & JavaForkOptions> void applyTo(TaskCollection tasks) {
    tasks.withType(JavaForkOptions.class, new Action<JavaForkOptions>() {
        @Override
        public void execute(JavaForkOptions task) {
            applyTo(Cast.<T>uncheckedCast(task));
        }
    });
}
项目:Reer    文件:RealizableTaskCollection.java   
public RealizableTaskCollection(Class<T> type, TaskCollection<T> delegate, MutableModelNode modelNode) {
    assert !(delegate instanceof RealizableTaskCollection) : "Attempt to wrap already realizable task collection in realizable wrapper: " + delegate;

    this.delegate = delegate;
    this.type = type;
    this.modelNode = modelNode;
}
项目:minikube-build-tools-for-java    文件:MinikubePluginTest.java   
@Test
public void testDefaultMinikubeTasks() {
  Project project = ProjectBuilder.builder().withProjectDir(tmp.getRoot()).build();
  project.getPluginManager().apply(MinikubePlugin.class);
  ((ProjectInternal) project).evaluate();

  TaskContainer t = project.getTasks();
  TaskCollection<MinikubeTask> tc = t.withType(MinikubeTask.class);

  Assert.assertEquals(3, tc.size());

  AssertMinikubeTaskConfig(tc, "minikubeStart", "start");
  AssertMinikubeTaskConfig(tc, "minikubeStop", "stop");
  AssertMinikubeTaskConfig(tc, "minikubeDelete", "delete");
}
项目:minikube-build-tools-for-java    文件:MinikubePluginTest.java   
private void AssertMinikubeTaskConfig(
    TaskCollection<MinikubeTask> tc, String taskName, String taskCommand) {
  MinikubeTask minikubeTask = tc.getByName(taskName);
  Assert.assertEquals(minikubeTask.getMinikube(), "minikube");
  Assert.assertEquals(minikubeTask.getCommand(), taskCommand);
  Assert.assertArrayEquals(minikubeTask.getFlags(), new String[] {});
}
项目:atlas    文件:MtlTransformInjector.java   
private TransformTask findTransformTask(Class transformClazz) {

        TaskCollection<TransformTask> androidTasks = project.getTasks().withType(TransformTask.class);

        for (TransformTask transformTask : androidTasks) {
            if (transformTask.getTransform().getClass().equals(transformClazz)) {

                if (appVariantContext.getVariantData().getName().equals(transformTask.getVariantName())) {
                    return transformTask;
                }
            }
        }

        return null;
    }
项目:core-java    文件:ModelVerifierShould.java   
@Before
public void setUp() {
    project = mock(Project.class);
    when(project.getSubprojects()).thenReturn(Collections.<Project>emptySet());
    when(project.getRootProject()).thenReturn(project);
    final TaskContainer tasks = mock(TaskContainer.class);
    final TaskCollection emptyTaskCollection = mock(TaskCollection.class);
    when(emptyTaskCollection.iterator()).thenReturn(Iterators.emptyIterator());
    when(emptyTaskCollection.toArray()).thenReturn(EMPTY_ARRAY);
    when(tasks.withType(any(Class.class))).thenReturn(emptyTaskCollection);
    when(project.getTasks()).thenReturn(tasks);
}
项目:javaccPlugin    文件:CompileJjdocTask.java   
@TaskAction
public void run() {
    TaskCollection<JavaCompile> javaCompileTasks = this.getProject().getTasks().withType(JavaCompile.class);
    CompilerInputOutputConfiguration inputOutputDirectories
        = new JavaccCompilerInputOutputConfiguration(getInputDirectory(), getOutputDirectory(), getSource(), javaCompileTasks);
    JjdocProgramInvoker jjdocInvoker = new JjdocProgramInvoker(getProject(), getClasspath(), inputOutputDirectories.getTempOutputDirectory());
    ProgramArguments arguments = new ProgramArguments();
    arguments.addAll(getArguments());
    SourceFileCompiler compiler = new JavaccSourceFileCompiler(jjdocInvoker, arguments, inputOutputDirectories, getLogger());

    compiler.createTempOutputDirectory();
    compiler.compileSourceFilesToTempOutputDirectory();
    compiler.copyCompiledFilesFromTempOutputDirectoryToOutputDirectory();
    compiler.cleanTempOutputDirectory();
}
项目:javaccPlugin    文件:JavaccCompilerInputOutputConfiguration.java   
public JavaccCompilerInputOutputConfiguration(File inputDirectory, File outputDirectory, FileTree source, TaskCollection<JavaCompile> javaCompileTasks) {
    this.inputDirectory = inputDirectory;
    this.outputDirectory = outputDirectory;
    this.source = source;
    this.javaCompileTasks = new HashSet<JavaCompile>();

    if (!CollectionUtils.isEmpty(javaCompileTasks)) {
        this.javaCompileTasks.addAll(javaCompileTasks);
    }
}
项目:javaccPlugin    文件:JavaToJavaccDependencyActionTest.java   
@Test
public void compileJavaDependsOnCompileJavaccAfterExecutionWhenJavaPluginApplied() {
    applyJavaccPluginToProject();
    applyJavaPluginToProject();
    JavaToJavaccDependencyAction action = new JavaToJavaccDependencyAction();

    action.execute(project);

    TaskCollection<JavaCompile> javaCompilationTasks = project.getTasks().withType(JavaCompile.class);
    for (JavaCompile task : javaCompilationTasks) {
        Set<Object> dependencies = task.getDependsOn();
        assertTrue(dependencies.contains(project.getTasks().findByName(CompileJavaccTask.TASK_NAME_VALUE)));
    }
}
项目:javaccPlugin    文件:JavaToJavaccDependencyActionTest.java   
@Test
public void compileJavaDoesNotDependOnCompileJavaccWhenJavaccPluginNotApplied() {
    applyJavaPluginToProject();
    JavaToJavaccDependencyAction action = new JavaToJavaccDependencyAction();

    action.execute(project);

    TaskCollection<JavaCompile> javaCompilationTasks = project.getTasks().withType(JavaCompile.class);
    for (JavaCompile task : javaCompilationTasks) {
        Set<Object> dependencies = task.getDependsOn();
        assertFalse(dependencies.contains(project.getTasks().findByName(CompileJavaccTask.TASK_NAME_VALUE)));
    }
}
项目:javaccPlugin    文件:JavaToJavaccDependencyActionTest.java   
@Test
public void compileJavaDoesNotDependOnCompileJJTreeWhenJavaccPluginNotApplied() {
    applyJavaPluginToProject();
    JavaToJavaccDependencyAction action = new JavaToJavaccDependencyAction();

    action.execute(project);

    TaskCollection<JavaCompile> javaCompilationTasks = project.getTasks().withType(JavaCompile.class);
    for (JavaCompile task : javaCompilationTasks) {
        Set<Object> dependencies = task.getDependsOn();
        assertFalse(dependencies.contains(project.getTasks().findByName(CompileJjtreeTask.TASK_NAME_VALUE)));
    }
}
项目:gradle-errorprone-plugin    文件:ErrorPronePlugin.java   
@Override
public void apply(final Project project) {
  project.apply(Collections.singletonMap("plugin", ErrorProneBasePlugin.class));

  final ErrorProneToolChain toolChain = ErrorProneToolChain.create(project);
  final Action<JavaCompile> action = task -> task.setToolChain(toolChain);

  final TaskCollection<JavaCompile> javaCompileTasks =
      project.getTasks().withType(JavaCompile.class);
  javaCompileTasks.all(action);
  javaCompileTasks.whenTaskAdded(action);
}
项目:Reer    文件:DefaultTaskContainer.java   
@Override
public <S extends Task> TaskCollection<S> withType(Class<S> type) {
    return new RealizableTaskCollection<S>(type, super.withType(type), modelNode);
}
项目:Reer    文件:RealizableTaskCollection.java   
private <S extends T> RealizableTaskCollection<S> realizable(Class<S> type, TaskCollection<S> collection) {
    return new RealizableTaskCollection<S>(type, collection, modelNode);
}
项目:Reer    文件:RealizableTaskCollection.java   
@Override
public TaskCollection<T> matching(Spec<? super T> spec) {
    return realizable(type, delegate.matching(spec));
}
项目:Reer    文件:RealizableTaskCollection.java   
@Override
public TaskCollection<T> matching(Closure closure) {
    return realizable(type, delegate.matching(closure));
}
项目:Reer    文件:RealizableTaskCollection.java   
@Override
public <S extends T> TaskCollection<S> withType(Class<S> type) {
    return realizable(type, delegate.withType(type));
}
项目:Reer    文件:DefaultTaskCollection.java   
@Override
public <S extends T> TaskCollection<S> withType(Class<S> type) {
    return filtered(createFilter(type));
}
项目:Reer    文件:DefaultTaskCollection.java   
@Override
public TaskCollection<T> matching(Spec<? super T> spec) {
    return filtered(createFilter(spec));
}
项目:Reer    文件:DefaultTaskCollection.java   
@Override
public TaskCollection<T> matching(Closure spec) {
    return matching(Specs.<T>convertClosureToSpec(spec));
}
项目:atlas    文件:InjectTransformManager.java   
/**
 * Gets the list of all transformtasks
 *
 * @return
 */
private SortedMap<String, TransformTask> getTransformTasks() {
    TaskCollection<TransformTask> transformTasks = project.getTasks()
            .withType(TransformTask.class);
    return transformTasks.getAsMap();
}
项目:Pushjet-Android    文件:DefaultTaskCollection.java   
@Override
public <S extends T> TaskCollection<S> withType(Class<S> type) {
    return filtered(createFilter(type));
}
项目:Pushjet-Android    文件:DefaultTaskCollection.java   
@Override
public TaskCollection<T> matching(Spec<? super T> spec) {
    return filtered(createFilter(spec));
}
项目:Pushjet-Android    文件:DefaultTaskCollection.java   
@Override
public TaskCollection<T> matching(Closure spec) {
    return matching(Specs.<T>convertClosureToSpec(spec));
}
项目:Pushjet-Android    文件:DefaultTaskCollection.java   
@Override
public <S extends T> TaskCollection<S> withType(Class<S> type) {
    return filtered(createFilter(type));
}
项目:Pushjet-Android    文件:DefaultTaskCollection.java   
@Override
public TaskCollection<T> matching(Spec<? super T> spec) {
    return filtered(createFilter(spec));
}
项目:Pushjet-Android    文件:DefaultTaskCollection.java   
@Override
public TaskCollection<T> matching(Closure spec) {
    return matching(Specs.<T>convertClosureToSpec(spec));
}
项目:javaccPlugin    文件:JavaToJavaccDependencyAction.java   
private void addJavaccDependencyToJavaCompileTask(TaskCollection<JavaCompile> javaCompilationTasks, CompileJavaccTask compileJavaccTask) {
    for (JavaCompile task : javaCompilationTasks) {
        task.dependsOn(compileJavaccTask);
        task.source(compileJavaccTask.getOutputDirectory());
    }
}
项目:javaccPlugin    文件:JavaccCompilerInputOutputConfigurationTest.java   
public JavaccConfigurationBuilder withJavaCompileTasks(TaskCollection<JavaCompile> javaCompileTasks) {
    this.javaCompileTasks = javaCompileTasks;

    return this;
}