org.gradle.api.DefaultTask Java Examples
The following examples show how to use
org.gradle.api.DefaultTask.
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 File: LifecycleBasePlugin.java From javaide with GNU General Public License v3.0 | 5 votes |
private void addAssemble(ProjectInternal project) { addPlaceholderAction(project, ASSEMBLE_TASK_NAME, DefaultTask.class, new Action<TaskInternal>() { @Override public void execute(TaskInternal assembleTask) { assembleTask.setDescription("Assembles the outputs of this project."); assembleTask.setGroup(BUILD_GROUP); } }); }
Example #2
Source File: TaskFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void checkTaskArgsAndCreateDefaultValues(Map<String, Object> args) { validateArgs(args); setIfNull(args, Task.TASK_NAME, ""); setIfNull(args, Task.TASK_TYPE, DefaultTask.class); if (((Class) args.get(Task.TASK_TYPE)).isAssignableFrom(DefaultTask.class)) { args.put(Task.TASK_TYPE, DefaultTask.class); } setIfNull(args, GENERATE_SUBCLASS, "true"); }
Example #3
Source File: TaskDetailPrinter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private Class getDeclaredTaskType(Task original) { Class clazz = new DslObject(original).getDeclaredType(); if (clazz.equals(DefaultTask.class)) { return org.gradle.api.Task.class; } else { return clazz; } }
Example #4
Source File: TaskFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void checkTaskArgsAndCreateDefaultValues(Map<String, Object> args) { validateArgs(args); setIfNull(args, Task.TASK_NAME, ""); setIfNull(args, Task.TASK_TYPE, DefaultTask.class); if (((Class) args.get(Task.TASK_TYPE)).isAssignableFrom(DefaultTask.class)) { args.put(Task.TASK_TYPE, DefaultTask.class); } setIfNull(args, GENERATE_SUBCLASS, "true"); }
Example #5
Source File: JavaLanguagePlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public SourceTransformTaskConfig getTransformTask() { return new SourceTransformTaskConfig() { public String getTaskPrefix() { return "compile"; } public Class<? extends DefaultTask> getTaskType() { return PlatformJavaCompile.class; } public void configureTask(Task task, BinarySpec binarySpec, LanguageSourceSet sourceSet) { PlatformJavaCompile compile = (PlatformJavaCompile) task; JavaSourceSet javaSourceSet = (JavaSourceSet) sourceSet; JvmBinarySpec binary = (JvmBinarySpec) binarySpec; compile.setDescription(String.format("Compiles %s.", javaSourceSet)); compile.setDestinationDir(binary.getClassesDir()); compile.setToolChain(binary.getToolChain()); compile.setPlatform(binary.getTargetPlatform()); compile.setSource(javaSourceSet.getSource()); compile.setClasspath(javaSourceSet.getCompileClasspath().getFiles()); compile.setTargetCompatibility(binary.getTargetPlatform().getTargetCompatibility().toString()); compile.setSourceCompatibility(binary.getTargetPlatform().getTargetCompatibility().toString()); compile.setDependencyCacheDir(new File(compile.getProject().getBuildDir(), "jvm-dep-cache")); compile.dependsOn(javaSourceSet); binary.getTasks().getJar().dependsOn(compile); } }; }
Example #6
Source File: TaskDetailPrinter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private Class getDeclaredTaskType(Task original) { Class clazz = new DslObject(original).getDeclaredType(); if (clazz.equals(DefaultTask.class)) { return org.gradle.api.Task.class; } else { return clazz; } }
Example #7
Source File: AndroidTaskRegistry.java From javaide with GNU General Public License v3.0 | 5 votes |
public synchronized AndroidTask<Task> create( TaskFactory taskFactory, String taskName, Closure configAction) { taskFactory.create(taskName, DefaultTask.class, new ClosureBackedAction<Task>(configAction)); final AndroidTask<Task> newTask = new AndroidTask<Task>(taskName, Task.class); tasks.put(taskName, newTask); return newTask; }
Example #8
Source File: LifecycleBasePlugin.java From javaide with GNU General Public License v3.0 | 5 votes |
private void addBuild(final ProjectInternal project) { addPlaceholderAction(project, BUILD_TASK_NAME, DefaultTask.class, new Action<DefaultTask>() { @Override public void execute(DefaultTask buildTask) { buildTask.setDescription("Assembles and tests this project."); buildTask.setGroup(BUILD_GROUP); buildTask.dependsOn(ASSEMBLE_TASK_NAME); buildTask.dependsOn(CHECK_TASK_NAME); } }); }
Example #9
Source File: LifecycleBasePlugin.java From javaide with GNU General Public License v3.0 | 5 votes |
private void addCheck(ProjectInternal project) { addPlaceholderAction(project, CHECK_TASK_NAME, DefaultTask.class, new Action<TaskInternal>() { @Override public void execute(TaskInternal checkTask) { checkTask.setDescription("Runs all checks."); checkTask.setGroup(VERIFICATION_GROUP); } }); }
Example #10
Source File: TaskDetailPrinter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private Class getDeclaredTaskType(Task original) { Class clazz = new DslObject(original).getDeclaredType(); if (clazz.equals(DefaultTask.class)) { return org.gradle.api.Task.class; } else { return clazz; } }
Example #11
Source File: JavaLanguagePlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public SourceTransformTaskConfig getTransformTask() { return new SourceTransformTaskConfig() { public String getTaskPrefix() { return "compile"; } public Class<? extends DefaultTask> getTaskType() { return PlatformJavaCompile.class; } public void configureTask(Task task, BinarySpec binarySpec, LanguageSourceSet sourceSet) { PlatformJavaCompile compile = (PlatformJavaCompile) task; JavaSourceSet javaSourceSet = (JavaSourceSet) sourceSet; JvmBinarySpec binary = (JvmBinarySpec) binarySpec; compile.setDescription(String.format("Compiles %s.", javaSourceSet)); compile.setDestinationDir(binary.getClassesDir()); compile.setToolChain(binary.getToolChain()); compile.setPlatform(binary.getTargetPlatform()); compile.setSource(javaSourceSet.getSource()); compile.setClasspath(javaSourceSet.getCompileClasspath().getFiles()); compile.setTargetCompatibility(binary.getTargetPlatform().getTargetCompatibility().toString()); compile.setSourceCompatibility(binary.getTargetPlatform().getTargetCompatibility().toString()); compile.setDependencyCacheDir(new File(compile.getProject().getBuildDir(), "jvm-dep-cache")); compile.dependsOn(javaSourceSet); binary.getTasks().getJar().dependsOn(compile); } }; }
Example #12
Source File: TaskDetailPrinter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private Class getDeclaredTaskType(Task original) { Class clazz = new DslObject(original).getDeclaredType(); if (clazz.equals(DefaultTask.class)) { return org.gradle.api.Task.class; } else { return clazz; } }
Example #13
Source File: TaskFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void checkTaskArgsAndCreateDefaultValues(Map<String, Object> args) { validateArgs(args); setIfNull(args, Task.TASK_NAME, ""); setIfNull(args, Task.TASK_TYPE, DefaultTask.class); if (((Class) args.get(Task.TASK_TYPE)).isAssignableFrom(DefaultTask.class)) { args.put(Task.TASK_TYPE, DefaultTask.class); } setIfNull(args, GENERATE_SUBCLASS, "true"); }
Example #14
Source File: TaskFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void checkTaskArgsAndCreateDefaultValues(Map<String, Object> args) { validateArgs(args); setIfNull(args, Task.TASK_NAME, ""); setIfNull(args, Task.TASK_TYPE, DefaultTask.class); if (((Class) args.get(Task.TASK_TYPE)).isAssignableFrom(DefaultTask.class)) { args.put(Task.TASK_TYPE, DefaultTask.class); } setIfNull(args, GENERATE_SUBCLASS, "true"); }
Example #15
Source File: AssembleTaskConfig.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public Class<? extends DefaultTask> getTaskType() { return Assemble.class; }
Example #16
Source File: CompileTaskConfig.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public CompileTaskConfig(LanguageRegistration<? extends LanguageSourceSet> languageRegistration, Class<? extends DefaultTask> taskType) { this.language = languageRegistration; this.taskType = taskType; }
Example #17
Source File: AssembleTaskConfig.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public Class<? extends DefaultTask> getTaskType() { return Assemble.class; }
Example #18
Source File: WindowsResourcesCompileTaskConfig.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public Class<? extends DefaultTask> getTaskType() { return WindowsResourceCompile.class; }
Example #19
Source File: CompileTaskConfig.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public Class<? extends DefaultTask> getTaskType() { return taskType; }
Example #20
Source File: CompileTaskConfig.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public CompileTaskConfig(LanguageRegistration<? extends LanguageSourceSet> languageRegistration, Class<? extends DefaultTask> taskType) { this.language = languageRegistration; this.taskType = taskType; }
Example #21
Source File: CompileTaskConfig.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public Class<? extends DefaultTask> getTaskType() { return taskType; }
Example #22
Source File: WindowsResourcesCompileTaskConfig.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public Class<? extends DefaultTask> getTaskType() { return WindowsResourceCompile.class; }
Example #23
Source File: HelmPlugin.java From gradle-plugins with Apache License 2.0 | 4 votes |
public void apply(Project project) { project.getPlugins().apply(CliExecPlugin.class); HelmExtension extension = project.getExtensions().create("helm", HelmExtension.class); extension.setProject(project); // extension.setKubeConfig(KubernetesUtils.getDefaultKubeConfig(project)); HelmBootstrap helmBootstrap = project.getTasks().create("helmBootstrap", HelmBootstrap.class); DefaultTask helmPackages = project.getTasks().create("helmPackage", DefaultTask.class); HelmPublish helmPublish = project.getTasks().create("helmPublish", HelmPublish.class); Task helmUpdateRepository = project.getTasks().create("helmUpdateRepository", HelmUpdateRepository.class); DefaultTask helmPackagePrepare = project.getTasks().create("helmPackagePrepare", DefaultTask.class); helmPackagePrepare.dependsOn(helmBootstrap); helmUpdateRepository.dependsOn(helmBootstrap); helmPublish.dependsOn(helmUpdateRepository); helmPublish.dependsOn(helmPackages); CliExecExtension cliExec = project.getExtensions().getByType(CliExecExtension.class); cliExec.register("helm", extension.getCli()); Set<String> packageNames = extension.getPackageNames(); for (String packageName : packageNames) { HelmPackage helmPackage = project.getTasks().create("helmPackage" + toCamelCase(packageName), HelmPackage.class); helmPackage.setPackageName(packageName); helmPackage.dependsOn(helmPackagePrepare); helmPackages.dependsOn(helmPackage); } project.afterEvaluate(project1 -> { Cli cli = extension.getCli(); if (cli.isDockerized()) { helmBootstrap.setEnabled(false); } else if (cli.getDownload()) { helmBootstrap.src(cli.getDownloadUrl()); File downloadDir = cli.getDownloadDir(); downloadDir.mkdirs(); helmBootstrap.dest(downloadDir); } else { helmBootstrap.setEnabled(false); } }); }
Example #24
Source File: JavaBasePlugin.java From javaide with GNU General Public License v3.0 | 4 votes |
private void configureBuildDependents(Project project) { DefaultTask buildTask = project.getTasks().create(BUILD_DEPENDENTS_TASK_NAME, DefaultTask.class); buildTask.setDescription("Assembles and tests this project and all projects that depend on it."); buildTask.setGroup(BasePlugin.BUILD_GROUP); buildTask.dependsOn(BUILD_TASK_NAME); }
Example #25
Source File: JavaBasePlugin.java From javaide with GNU General Public License v3.0 | 4 votes |
private void configureBuildNeeded(Project project) { DefaultTask buildTask = project.getTasks().create(BUILD_NEEDED_TASK_NAME, DefaultTask.class); buildTask.setDescription("Assembles and tests this project and all projects it depends on."); buildTask.setGroup(BasePlugin.BUILD_GROUP); buildTask.dependsOn(BUILD_TASK_NAME); }
Example #26
Source File: MergeResAwbsConfigAction.java From atlas with Apache License 2.0 | 4 votes |
@Override public void execute(MtlParallelTask parallelTask) { super.execute(parallelTask); AtlasDependencyTree atlasDependencyTree = AtlasBuildContext.androidDependencyTrees.get( parallelTask.getVariantName()); if (null == atlasDependencyTree) { return; } List<DefaultTask> tasks = new ArrayList<DefaultTask>(); for (final AwbBundle awbBundle : atlasDependencyTree.getAwbBundles()) { if (awbBundle.isMBundle){ continue; } MergeAwbResource.MergeAwbResourceConfigAction mergeAwbResourceConfigAction = new MergeAwbResource.MergeAwbResourceConfigAction( appVariantContext, baseVariantOutput, awbBundle); final MergeAwbResource mergeTask = TaskCreater.create(appVariantContext.getProject(), mergeAwbResourceConfigAction.getName(), mergeAwbResourceConfigAction.getType()); // mergeTask.getOutputs().cacheIf(new Spec<Task>() { // @Override // public boolean isSatisfiedBy(Task element) { // return false; // } // }); mergeTask.setBlameLogFolder(appVariantContext.getAwbBlameLogFolder(awbBundle)); mergeAwbResourceConfigAction.execute(mergeTask); tasks.add(mergeTask); mergeTask.doLast(new Action<Task>() { @Override public void execute(Task task) { File publicRes = new File(awbBundle.getAndroidLibrary().getResFolder(), "values/public.xml"); if (publicRes.exists()) { try { FileUtils.copyFile(publicRes, new File(mergeTask.getOutputDir(), "values/public.xml")); } catch (IOException e) { e.printStackTrace(); } } } }); } parallelTask.parallelTask = tasks; parallelTask.uniqueTaskName = getName(); parallelTask.concurrent = true; }
Example #27
Source File: GeneratorPlugin.java From crnk-framework with Apache License 2.0 | 4 votes |
private Task setupCleanTask(Project project, GeneratorModule module) { Task task = project.getTasks().create(getCleanTaskName(module), DefaultTask.class); task.doFirst(task1 -> project.delete(module.getConfig().getGenDir())); return task; }
Example #28
Source File: QuarkusPlugin.java From quarkus with Apache License 2.0 | 4 votes |
@SuppressWarnings("Convert2Lambda") private void registerTasks(Project project, QuarkusPluginExtension quarkusExt) { TaskContainer tasks = project.getTasks(); tasks.create(LIST_EXTENSIONS_TASK_NAME, QuarkusListExtensions.class); tasks.create(ADD_EXTENSION_TASK_NAME, QuarkusAddExtension.class); tasks.create(REMOVE_EXTENSION_TASK_NAME, QuarkusRemoveExtension.class); tasks.create(GENERATE_CONFIG_TASK_NAME, QuarkusGenerateConfig.class); Task quarkusBuild = tasks.create(QUARKUS_BUILD_TASK_NAME, QuarkusBuild.class); Task quarkusDev = tasks.create(QUARKUS_DEV_TASK_NAME, QuarkusDev.class); Task quarkusRemoteDev = tasks.create(QUARKUS_REMOTE_DEV_TASK_NAME, QuarkusRemoteDev.class); tasks.create(QUARKUS_TEST_CONFIG_TASK_NAME, QuarkusTestConfig.class); Task buildNative = tasks.create(BUILD_NATIVE_TASK_NAME, DefaultTask.class); buildNative.finalizedBy(quarkusBuild); buildNative.doFirst(t -> project.getLogger() .warn("The 'buildNative' task has been deprecated in favor of 'build -Dquarkus.package.type=native'")); configureBuildNativeTask(project); final Consumer<Test> configureTestTask = t -> { // Quarkus test configuration action which should be executed before any Quarkus test // Use anonymous classes in order to leverage task avoidance. t.doFirst(new Action<Task>() { @Override public void execute(Task test) { quarkusExt.beforeTest(t); } }); // also make each task use the JUnit platform since it's the only supported test environment t.useJUnitPlatform(); // quarkusBuild is expected to run after the project has passed the tests quarkusBuild.shouldRunAfter(t); }; project.getPlugins().withType( BasePlugin.class, basePlugin -> tasks.getByName(BasePlugin.ASSEMBLE_TASK_NAME).dependsOn(quarkusBuild)); project.getPlugins().withType( JavaPlugin.class, javaPlugin -> { project.afterEvaluate(this::afterEvaluate); Task classesTask = tasks.getByName(JavaPlugin.CLASSES_TASK_NAME); Task resourcesTask = tasks.getByName(JavaPlugin.PROCESS_RESOURCES_TASK_NAME); quarkusDev.dependsOn(classesTask, resourcesTask); quarkusRemoteDev.dependsOn(classesTask, resourcesTask); quarkusBuild.dependsOn(classesTask, resourcesTask, tasks.getByName(JavaPlugin.JAR_TASK_NAME)); SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class) .getSourceSets(); SourceSet nativeTestSourceSet = sourceSets.create(NATIVE_TEST_SOURCE_SET_NAME); SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); SourceSet testSourceSet = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME); nativeTestSourceSet.setCompileClasspath( nativeTestSourceSet.getCompileClasspath() .plus(mainSourceSet.getOutput()) .plus(testSourceSet.getOutput())); nativeTestSourceSet.setRuntimeClasspath( nativeTestSourceSet.getRuntimeClasspath() .plus(mainSourceSet.getOutput()) .plus(testSourceSet.getOutput())); // create a custom configuration to be used for the dependencies of the testNative task ConfigurationContainer configurations = project.getConfigurations(); configurations.maybeCreate(NATIVE_TEST_IMPLEMENTATION_CONFIGURATION_NAME) .extendsFrom(configurations.findByName(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME)); configurations.maybeCreate(NATIVE_TEST_RUNTIME_ONLY_CONFIGURATION_NAME) .extendsFrom(configurations.findByName(JavaPlugin.TEST_RUNTIME_ONLY_CONFIGURATION_NAME)); Task testNative = tasks.create(TEST_NATIVE_TASK_NAME, QuarkusTestNative.class); testNative.dependsOn(quarkusBuild); testNative.setShouldRunAfter(Collections.singletonList(tasks.findByName(JavaPlugin.TEST_TASK_NAME))); tasks.withType(Test.class).forEach(configureTestTask); tasks.withType(Test.class).whenTaskAdded(configureTestTask::accept); }); }
Example #29
Source File: MergeAwbsJniFolder.java From atlas with Apache License 2.0 | 3 votes |
@Override public void execute(MtlParallelTask parallelTask) { super.execute(parallelTask); AtlasDependencyTree atlasDependencyTree = AtlasBuildContext.androidDependencyTrees.get(parallelTask.getVariantName()); if (null == atlasDependencyTree) { return; } List<DefaultTask> tasks = new ArrayList<DefaultTask>(); for (final AwbBundle awbBundle : atlasDependencyTree.getAwbBundles()) { MergeAwbAssets.MergeAwbJniLibFoldersConfigAction mergeAwbJniLibFoldersConfigAction = new MergeAwbAssets.MergeAwbJniLibFoldersConfigAction(appVariantContext, baseVariantOutput, awbBundle); MergeAwbAssets mergeTask = TaskCreater.create(appVariantContext.getProject(), mergeAwbJniLibFoldersConfigAction.getName(), mergeAwbJniLibFoldersConfigAction.getType()); mergeAwbJniLibFoldersConfigAction.execute(mergeTask); tasks.add(mergeTask); } parallelTask.parallelTask = tasks; parallelTask.concurrent = false; parallelTask.uniqueTaskName = getName(); }
Example #30
Source File: MergeAssetAwbsConfigAction.java From atlas with Apache License 2.0 | 3 votes |
@Override public void execute(MtlParallelTask parallelTask) { super.execute(parallelTask); AtlasDependencyTree atlasDependencyTree = AtlasBuildContext.androidDependencyTrees.get(parallelTask.getVariantName()); if (null == atlasDependencyTree) { return; } List<DefaultTask> tasks = new ArrayList<DefaultTask>(); for (final AwbBundle awbBundle : atlasDependencyTree.getAwbBundles()) { if (awbBundle.isMBundle){ continue; } MergeAwbAssets.MergeAwbAssetConfigAction mergeAwbAssetConfigAction = new MergeAwbAssets.MergeAwbAssetConfigAction(appVariantContext, baseVariantOutput, awbBundle); MergeAwbAssets mergeTask = TaskCreater.create(appVariantContext.getProject(), mergeAwbAssetConfigAction.getName(), mergeAwbAssetConfigAction.getType()); mergeAwbAssetConfigAction.execute(mergeTask); tasks.add(mergeTask); } parallelTask.parallelTask = tasks; parallelTask.concurrent = false; parallelTask.uniqueTaskName = getName(); }