Java Code Examples for org.gradle.api.tasks.TaskContainer#create()
The following examples show how to use
org.gradle.api.tasks.TaskContainer#create() .
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: LanguageBasePlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
@Mutate void createLifecycleTaskForBinary(TaskContainer tasks, BinaryContainer binaries) { Task assembleTask = tasks.getByName(LifecycleBasePlugin.ASSEMBLE_TASK_NAME); for (BinarySpecInternal binary : binaries.withType(BinarySpecInternal.class)) { if (!binary.isLegacyBinary()) { Task binaryLifecycleTask = tasks.create(binary.getNamingScheme().getLifecycleTaskName()); binaryLifecycleTask.setGroup(LifecycleBasePlugin.BUILD_GROUP); binaryLifecycleTask.setDescription(String.format("Assembles %s.", binary)); binary.setBuildTask(binaryLifecycleTask); if (binary.isBuildable()) { assembleTask.dependsOn(binary); } } } }
Example 2
Source File: LayeredWheelCachePlugin.java From pygradle with Apache License 2.0 | 6 votes |
@Override public void apply(Project project) { WheelExtension wheelExtension = ExtensionUtils.maybeCreateWheelExtension(project); EditablePythonAbiContainer supportedWheelFormats = ExtensionUtils.getEditablePythonAbiContainer(project); LayeredWheelCache wheelCache = new LayeredWheelCache(wheelExtension.getLayeredCacheMap(), supportedWheelFormats); TaskContainer tasks = project.getTasks(); tasks.withType(ProvidesVenv.class, task -> task.setEditablePythonAbiContainer(supportedWheelFormats)); tasks.withType(SupportsWheelCache.class, task -> task.setWheelCache(wheelCache)); tasks.create(LayeredWheelCacheTask.TASK_LAYERED_WHEEL_CACHE, LayeredWheelCacheTask.class, task -> { tasks.getByName(TASK_VENV_CREATE.getValue()).dependsOn(task); tasks.getByName(TASK_FLAKE.getValue()).dependsOn(task); }); }
Example 3
Source File: MavenPublishPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public void apply(final Project project) { project.getPlugins().apply(PublishingPlugin.class); final TaskContainer tasks = project.getTasks(); final Task publishLocalLifecycleTask = tasks.create(PUBLISH_LOCAL_LIFECYCLE_TASK_NAME); publishLocalLifecycleTask.setDescription("Publishes all Maven publications produced by this project to the local Maven cache."); publishLocalLifecycleTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); // Can't move this to rules yet, because it has to happen before user deferred configurable actions project.getExtensions().configure(PublishingExtension.class, new Action<PublishingExtension>() { public void execute(PublishingExtension extension) { // Register factory for MavenPublication extension.getPublications().registerFactory(MavenPublication.class, new MavenPublicationFactory(dependencyMetaDataProvider, instantiator, fileResolver)); } }); }
Example 4
Source File: MavenPublishPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public void apply(final Project project) { project.getPlugins().apply(PublishingPlugin.class); final TaskContainer tasks = project.getTasks(); final Task publishLocalLifecycleTask = tasks.create(PUBLISH_LOCAL_LIFECYCLE_TASK_NAME); publishLocalLifecycleTask.setDescription("Publishes all Maven publications produced by this project to the local Maven cache."); publishLocalLifecycleTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); // Can't move this to rules yet, because it has to happen before user deferred configurable actions project.getExtensions().configure(PublishingExtension.class, new Action<PublishingExtension>() { public void execute(PublishingExtension extension) { // Register factory for MavenPublication extension.getPublications().registerFactory(MavenPublication.class, new MavenPublicationFactory(dependencyMetaDataProvider, instantiator, fileResolver)); } }); }
Example 5
Source File: MavenPublishPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public void apply(final Project project) { project.getPlugins().apply(PublishingPlugin.class); final TaskContainer tasks = project.getTasks(); final Task publishLifecycleTask = tasks.getByName(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME); final Task publishLocalLifecycleTask = tasks.create(PUBLISH_LOCAL_LIFECYCLE_TASK_NAME); publishLocalLifecycleTask.setDescription("Publishes all Maven publications produced by this project to the local Maven cache."); publishLocalLifecycleTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); // Can't move this to rules yet, because it has to happen before user deferred configurable actions project.getExtensions().configure(PublishingExtension.class, new Action<PublishingExtension>() { public void execute(PublishingExtension extension) { // Register factory for MavenPublication extension.getPublications().registerFactory(MavenPublication.class, new MavenPublicationFactory(dependencyMetaDataProvider, instantiator, fileResolver)); } }); modelRules.rule(new MavenPublishTaskModelRule(project, publishLifecycleTask, publishLocalLifecycleTask)); }
Example 6
Source File: CreateVisualStudioTasks.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
@SuppressWarnings("UnusedDeclaration") public void createTasksForVisualStudio(TaskContainer tasks, VisualStudioExtension visualStudioExtension) { for (VisualStudioProject vsProject : visualStudioExtension.getProjects()) { vsProject.builtBy(createProjectsFileTask(tasks, vsProject)); vsProject.builtBy(createFiltersFileTask(tasks, vsProject)); } for (VisualStudioSolution vsSolution : visualStudioExtension.getSolutions()) { Task solutionTask = tasks.create(vsSolution.getName() + "VisualStudio"); solutionTask.setDescription(String.format("Generates the '%s' Visual Studio solution file.", vsSolution.getName())); vsSolution.setLifecycleTask(solutionTask); vsSolution.builtBy(createSolutionTask(tasks, vsSolution)); // Lifecycle task for component ProjectNativeComponent component = vsSolution.getComponent(); Task lifecycleTask = tasks.maybeCreate(component.getName() + "VisualStudio"); lifecycleTask.dependsOn(vsSolution); lifecycleTask.setGroup("IDE"); lifecycleTask.setDescription(String.format("Generates the Visual Studio solution for %s.", component)); } addCleanTask(tasks); }
Example 7
Source File: CredentialsPlugin.java From gradle-credentials-plugin with Apache License 2.0 | 6 votes |
private void addTasks(Pair result, TaskContainer tasks) { CredentialsEncryptor credentialsEncryptor = result.credentialsEncryptor; CredentialsPersistenceManager credentialsPersistenceManager = result.credentialsPersistenceManager; // add a task instance that stores new credentials through the credentials persistence manager AddCredentialsTask addCredentials = tasks.create(ADD_CREDENTIALS_TASK_NAME, AddCredentialsTask.class); addCredentials.setDescription("Adds the credentials specified through the project properties 'credentialsKey' and 'credentialsValue'."); addCredentials.setGroup("Credentials"); addCredentials.setCredentialsEncryptor(credentialsEncryptor); addCredentials.setCredentialsPersistenceManager(credentialsPersistenceManager); addCredentials.getOutputs().upToDateWhen(AlwaysFalseSpec.INSTANCE); LOGGER.debug(String.format("Registered task '%s'", addCredentials.getName())); // add a task instance that removes some credentials through the credentials persistence manager RemoveCredentialsTask removeCredentials = tasks.create(REMOVE_CREDENTIALS_TASK_NAME, RemoveCredentialsTask.class); removeCredentials.setDescription("Removes the credentials specified through the project property 'credentialsKey'."); removeCredentials.setGroup("Credentials"); removeCredentials.setCredentialsPersistenceManager(credentialsPersistenceManager); removeCredentials.getOutputs().upToDateWhen(AlwaysFalseSpec.INSTANCE); LOGGER.debug(String.format("Registered task '%s'", removeCredentials.getName())); }
Example 8
Source File: JvmComponentPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private Task createJarTask(TaskContainer tasks, JarBinarySpecInternal binary) { Jar jar = tasks.create(binary.getNamingScheme().getTaskName("create"), Jar.class); jar.setDescription(String.format("Creates the binary file for %s.", binary.getNamingScheme().getDescription())); jar.from(binary.getClassesDir()); jar.from(binary.getResourcesDir()); jar.setDestinationDir(binary.getJarFile().getParentFile()); jar.setArchiveName(binary.getJarFile().getName()); return jar; }
Example 9
Source File: JigGradlePlugin.java From jig with Apache License 2.0 | 5 votes |
@Override public void apply(Project project) { ExtensionContainer extensions = project.getExtensions(); extensions.create("jig", JigConfig.class); TaskContainer tasks = project.getTasks(); JigReportsTask jigReports = tasks.create("jigReports", JigReportsTask.class); jigReports.setGroup("JIG"); jigReports.setDescription("Generates JIG documentation for the main source code."); VerifyJigEnvironmentTask verifyTask = tasks.create("verifyJigEnvironment", VerifyJigEnvironmentTask.class); verifyTask.setGroup("JIG"); verifyTask.setDescription("Verify JIG environment."); }
Example 10
Source File: IvyPublicationTasksModelRule.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void createTasks(TaskContainer tasks, PublishingExtension publishingExtension) { PublicationContainer publications = publishingExtension.getPublications(); RepositoryHandler repositories = publishingExtension.getRepositories(); for (final IvyPublicationInternal publication : publications.withType(IvyPublicationInternal.class)) { final String publicationName = publication.getName(); final String descriptorTaskName = String.format("generateDescriptorFileFor%sPublication", capitalize(publicationName)); GenerateIvyDescriptor descriptorTask = tasks.create(descriptorTaskName, GenerateIvyDescriptor.class); descriptorTask.setDescription(String.format("Generates the Ivy Module Descriptor XML file for publication '%s'.", publication.getName())); descriptorTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); descriptorTask.setDescriptor(publication.getDescriptor()); ConventionMapping descriptorTaskConventionMapping = new DslObject(descriptorTask).getConventionMapping(); descriptorTaskConventionMapping.map("destination", new Callable<Object>() { public Object call() throws Exception { return new File(project.getBuildDir(), "publications/" + publication.getName() + "/ivy.xml"); } }); publication.setDescriptorFile(descriptorTask.getOutputs().getFiles()); for (IvyArtifactRepository repository : repositories.withType(IvyArtifactRepository.class)) { final String repositoryName = repository.getName(); final String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName)); PublishToIvyRepository publishTask = tasks.create(publishTaskName, PublishToIvyRepository.class); publishTask.setPublication(publication); publishTask.setRepository(repository); publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); publishTask.setDescription(String.format("Publishes Ivy publication '%s' to Ivy repository '%s'.", publicationName, repositoryName)); tasks.getByName(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME).dependsOn(publishTask); } } }
Example 11
Source File: MavenPublishTaskModelRule.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void createLocalInstallTask(TaskContainer tasks, MavenPublicationInternal publication, String publicationName) { String installTaskName = String.format("publish%sPublicationToMavenLocal", capitalize(publicationName)); PublishToMavenLocal publishLocalTask = tasks.create(installTaskName, PublishToMavenLocal.class); publishLocalTask.setPublication(publication); publishLocalTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); publishLocalTask.setDescription(String.format("Publishes Maven publication '%s' to the local Maven repository.", publicationName)); publishLocalLifecycleTask.dependsOn(installTaskName); }
Example 12
Source File: MavenPublishTaskModelRule.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void createPublishTasksForEachMavenRepo(TaskContainer tasks, PublishingExtension extension, MavenPublicationInternal publication, String publicationName) { for (MavenArtifactRepository repository : extension.getRepositories().withType(MavenArtifactRepository.class)) { String repositoryName = repository.getName(); String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName)); PublishToMavenRepository publishTask = tasks.create(publishTaskName, PublishToMavenRepository.class); publishTask.setPublication(publication); publishTask.setRepository(repository); publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); publishTask.setDescription(String.format("Publishes Maven publication '%s' to Maven repository '%s'.", publicationName, repositoryName)); publishLifecycleTask.dependsOn(publishTask); } }
Example 13
Source File: PythonCliDistributionPlugin.java From pygradle with Apache License 2.0 | 5 votes |
@Override public void applyTo(Project project) { project.getPlugins().apply(PythonContainerPlugin.class); ExtensionUtils.maybeCreateCliExtension(project); TaskContainer tasks = project.getTasks(); GenerateCompletionsTask completionsTask = tasks.create(TASK_GENERATE_COMPLETIONS, GenerateCompletionsTask.class); completionsTask.dependsOn(tasks.getByName(StandardTextValues.TASK_INSTALL_PROJECT.getValue())); tasks.getByName(ApplicationContainer.TASK_ASSEMBLE_CONTAINERS) .dependsOn(project.getTasks().getByName(TASK_GENERATE_COMPLETIONS)); }
Example 14
Source File: JvmComponentPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private Task createJarTask(TaskContainer tasks, JarBinarySpecInternal binary) { Jar jar = tasks.create(binary.getNamingScheme().getTaskName("create"), Jar.class); jar.setDescription(String.format("Creates the binary file for %s.", binary.getNamingScheme().getDescription())); jar.from(binary.getClassesDir()); jar.from(binary.getResourcesDir()); jar.setDestinationDir(binary.getJarFile().getParentFile()); jar.setArchiveName(binary.getJarFile().getName()); return jar; }
Example 15
Source File: CreateVisualStudioTasks.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
private Task createFiltersFileTask(TaskContainer tasks, VisualStudioProject vsProject) { GenerateFiltersFileTask task = tasks.create(vsProject.getName() + "VisualStudioFilters", GenerateFiltersFileTask.class); task.setVisualStudioProject(vsProject); return task; }
Example 16
Source File: VisualStudioPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
private static Task createFiltersFileTask(TaskContainer tasks, VisualStudioProject vsProject) { GenerateFiltersFileTask task = tasks.create(vsProject.getName() + "VisualStudioFilters", GenerateFiltersFileTask.class); task.setVisualStudioProject(vsProject); return task; }
Example 17
Source File: VisualStudioPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
private static Task createSolutionTask(TaskContainer tasks, VisualStudioSolution solution) { GenerateSolutionFileTask solutionFileTask = tasks.create(solution.getName() + "VisualStudioSolution", GenerateSolutionFileTask.class); solutionFileTask.setVisualStudioSolution(solution); return solutionFileTask; }
Example 18
Source File: CreateVisualStudioTasks.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
private Task createProjectsFileTask(TaskContainer tasks, VisualStudioProject vsProject) { GenerateProjectFileTask task = tasks.create(vsProject.getName() + "VisualStudioProject", GenerateProjectFileTask.class); task.setVisualStudioProject(vsProject); task.initGradleCommand(); return task; }
Example 19
Source File: VisualStudioPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
private static Task createFiltersFileTask(TaskContainer tasks, VisualStudioProject vsProject) { GenerateFiltersFileTask task = tasks.create(vsProject.getName() + "VisualStudioFilters", GenerateFiltersFileTask.class); task.setVisualStudioProject(vsProject); return task; }
Example 20
Source File: SmallRyeGraphQLPlugin.java From smallrye-graphql with Apache License 2.0 | 4 votes |
private void registerTasks(Project project) { TaskContainer tasks = project.getTasks(); tasks.create(GENERATE_SCHEMA_TASK_NAME, GenerateSchemaTask.class); }