org.gradle.api.tasks.TaskCollection Java Examples
The following examples show how to use
org.gradle.api.tasks.TaskCollection.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: atlas Author: alibaba File: TransformManager.java License: Apache License 2.0 | 6 votes |
public static List<TransformTask> findTransformTaskByTransformType(VariantContext 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; }
Example #2
Source Project: minikube-build-tools-for-java Author: GoogleContainerTools File: MinikubePluginTest.java License: Apache License 2.0 | 6 votes |
@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"); }); }
Example #3
Source Project: thorntail Author: thorntail File: ThorntailUtils.java License: Apache License 2.0 | 6 votes |
/** * Returns the most suitable Archive-Task for wrapping in the swarm jar - in the following order: * <p> * 1. Custom-JAR-Task defined in ThorntailExtension 'archiveTask' * 2. WAR-Task * 3. JAR-Task */ public static Jar getArchiveTask(Project project) { TaskCollection<Jar> existingArchiveTasks = project.getTasks().withType(Jar.class); Jar customArchiveTask = project.getExtensions().getByType(ThorntailExtension.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); } throw new GradleException("Unable to detect Archive-Task: project contains neither 'war' nor 'jar', " + "nor is custom Archive-Task specified in the \"thorntail\" extension."); }
Example #4
Source Project: javaccPlugin Author: johnmartel File: CompileJjtreeTask.java License: MIT License | 6 votes |
@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(); }
Example #5
Source Project: javaccPlugin Author: johnmartel File: CompileJavaccTask.java License: MIT License | 6 votes |
@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(); }
Example #6
Source Project: javaccPlugin Author: johnmartel File: JavaToJavaccDependencyActionTest.java License: MIT License | 6 votes |
@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"))); } }
Example #7
Source Project: javaccPlugin Author: johnmartel File: JavaToJavaccDependencyActionTest.java License: MIT License | 6 votes |
@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))); } }
Example #8
Source Project: javaccPlugin Author: johnmartel File: JavaToJavaccDependencyActionTest.java License: MIT License | 6 votes |
@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))); } }
Example #9
Source Project: atlas Author: alibaba File: MtlTransformInjector.java License: Apache License 2.0 | 5 votes |
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; }
Example #10
Source Project: minikube-build-tools-for-java Author: GoogleContainerTools File: MinikubePluginTest.java License: Apache License 2.0 | 5 votes |
@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"); }
Example #11
Source Project: minikube-build-tools-for-java Author: GoogleContainerTools File: MinikubePluginTest.java License: Apache License 2.0 | 5 votes |
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[] {}); }
Example #12
Source Project: javaccPlugin Author: johnmartel File: CompileJjdocTask.java License: MIT License | 5 votes |
@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(); }
Example #13
Source Project: javaccPlugin Author: johnmartel File: JavaccCompilerInputOutputConfiguration.java License: MIT License | 5 votes |
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); } }
Example #14
Source Project: javaccPlugin Author: johnmartel File: JavaToJavaccDependencyActionTest.java License: MIT License | 5 votes |
@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))); } }
Example #15
Source Project: javaccPlugin Author: johnmartel File: JavaToJavaccDependencyActionTest.java License: MIT License | 5 votes |
@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))); } }
Example #16
Source Project: javaccPlugin Author: johnmartel File: JavaToJavaccDependencyActionTest.java License: MIT License | 5 votes |
@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))); } }
Example #17
Source Project: pushfish-android Author: PushFish File: DefaultTaskCollection.java License: BSD 2-Clause "Simplified" License | 4 votes |
@Override public <S extends T> TaskCollection<S> withType(Class<S> type) { return filtered(createFilter(type)); }
Example #18
Source Project: pushfish-android Author: PushFish File: DefaultTaskCollection.java License: BSD 2-Clause "Simplified" License | 4 votes |
@Override public TaskCollection<T> matching(Spec<? super T> spec) { return filtered(createFilter(spec)); }
Example #19
Source Project: pushfish-android Author: PushFish File: DefaultTaskCollection.java License: BSD 2-Clause "Simplified" License | 4 votes |
@Override public TaskCollection<T> matching(Closure spec) { return matching(Specs.<T>convertClosureToSpec(spec)); }
Example #20
Source Project: pushfish-android Author: PushFish File: DefaultTaskCollection.java License: BSD 2-Clause "Simplified" License | 4 votes |
@Override public <S extends T> TaskCollection<S> withType(Class<S> type) { return filtered(createFilter(type)); }
Example #21
Source Project: pushfish-android Author: PushFish File: DefaultTaskCollection.java License: BSD 2-Clause "Simplified" License | 4 votes |
@Override public TaskCollection<T> matching(Spec<? super T> spec) { return filtered(createFilter(spec)); }
Example #22
Source Project: pushfish-android Author: PushFish File: DefaultTaskCollection.java License: BSD 2-Clause "Simplified" License | 4 votes |
@Override public TaskCollection<T> matching(Closure spec) { return matching(Specs.<T>convertClosureToSpec(spec)); }
Example #23
Source Project: atlas Author: alibaba File: InjectTransformManager.java License: Apache License 2.0 | 4 votes |
/** * Gets the list of all transformtasks * * @return */ private SortedMap<String, TransformTask> getTransformTasks() { TaskCollection<TransformTask> transformTasks = project.getTasks() .withType(TransformTask.class); return transformTasks.getAsMap(); }
Example #24
Source Project: native-samples Author: gradle File: GeneratorPlugin.java License: Apache License 2.0 | 4 votes |
public void apply(Project project) { TaskCollection<SampleGeneratorTask> generatorTasks = project.getTasks().withType(SampleGeneratorTask.class); TaskCollection<GitRepoTask> repoTasks = project.getTasks().withType(GitRepoTask.class); // Add project extension SamplesExtension extension = project.getExtensions().create("samples", SamplesExtension.class, project); // Add a task to generate the list of samples TaskProvider<SamplesManifestTask> manifestTask = project.getTasks().register("samplesManifest", SamplesManifestTask.class, task -> { task.getManifest().set(project.file("samples-list.txt")); task.getSampleDirs().set(project.provider(() -> { return generatorTasks.stream().map(generator -> { return generator.getSampleDir().get().getAsFile().getAbsolutePath(); }).collect(Collectors.toList()); })); task.getRepoDirs().set(project.provider(() -> { return repoTasks.stream().map(generator -> { return generator.getSampleDir().get().getAsFile().getAbsolutePath(); }).collect(Collectors.toList()); })); }); // Add a task to clean the samples project.getTasks().register("cleanSamples", CleanSamplesTask.class, task -> { // Need the location without the task dependency as we want to clean whatever was generated last time, not whatever will be generated next time task.getManifest().set(project.provider(() -> { return manifestTask.get().getManifest().get(); })); }); // Apply conventions to the generator tasks generatorTasks.configureEach( task -> { task.getTemplatesDir().set(project.file("src/templates")); }); // Add a lifecycle task to generate the source files for the samples TaskProvider<Task> generateSource = project.getTasks().register("generateSource", task -> { task.dependsOn(generatorTasks); task.dependsOn(manifestTask); task.setGroup("source generation"); task.setDescription("generate the source files for all samples"); }); extension.getExternalRepos().all(it -> { addTasksForRepo(it, generateSource, project); }); extension.getSamples().all(it -> { addTasksForSample(it, project); }); // Add a lifecycle task to generate the repositories project.getTasks().register("generateRepos", task -> { task.dependsOn(repoTasks); task.setGroup("source generation"); task.setDescription("generate the Git repositories for all samples"); }); }
Example #25
Source Project: Pushjet-Android Author: Pushjet File: DefaultTaskCollection.java License: BSD 2-Clause "Simplified" License | 4 votes |
@Override public <S extends T> TaskCollection<S> withType(Class<S> type) { return filtered(createFilter(type)); }
Example #26
Source Project: Pushjet-Android Author: Pushjet File: DefaultTaskCollection.java License: BSD 2-Clause "Simplified" License | 4 votes |
@Override public TaskCollection<T> matching(Spec<? super T> spec) { return filtered(createFilter(spec)); }
Example #27
Source Project: Pushjet-Android Author: Pushjet File: DefaultTaskCollection.java License: BSD 2-Clause "Simplified" License | 4 votes |
@Override public TaskCollection<T> matching(Closure spec) { return matching(Specs.<T>convertClosureToSpec(spec)); }
Example #28
Source Project: Pushjet-Android Author: Pushjet File: DefaultTaskCollection.java License: BSD 2-Clause "Simplified" License | 4 votes |
@Override public <S extends T> TaskCollection<S> withType(Class<S> type) { return filtered(createFilter(type)); }
Example #29
Source Project: Pushjet-Android Author: Pushjet File: DefaultTaskCollection.java License: BSD 2-Clause "Simplified" License | 4 votes |
@Override public TaskCollection<T> matching(Spec<? super T> spec) { return filtered(createFilter(spec)); }
Example #30
Source Project: Pushjet-Android Author: Pushjet File: DefaultTaskCollection.java License: BSD 2-Clause "Simplified" License | 4 votes |
@Override public TaskCollection<T> matching(Closure spec) { return matching(Specs.<T>convertClosureToSpec(spec)); }