/** * Sets the directory to copy files into. This is the same as calling {@link #into(Object)} on this task. * * @param destinationDir The destination directory. Must not be null. */ public void setDestinationDir(File destinationDir) { into(destinationDir); }
private Copy _addTaskCopyAppTLDDocResources(final Project project) { Copy copy = GradleUtil.addTask( project, COPY_APP_TLDDOC_RESOURCES_TASK_NAME, Copy.class); copy.into( new Callable<File>() { @Override public File call() throws Exception { TLDDocTask appTLDDocTask = (TLDDocTask)GradleUtil.getTask( project, APP_TLDDOC_TASK_NAME); return appTLDDocTask.getDestinationDir(); } }); copy.setDescription("Copies tag library documentation resources."); return copy; }
@Override public void execute(Copy copy) { copy.dependsOn(bootJarTask); copy.from(targetJar.getOutputs().getFiles()); copy.into(new File(project.getBuildDir(), "thin/root")); } });
public Copy getJacocoAgentTask() { if (jacocoAgentTask == null) { jacocoAgentTask = project.getTasks().create("unzipJacocoAgent", Copy.class); jacocoAgentTask.from(new Callable<List<FileTree>>() { @Override public List<FileTree> call() throws Exception { return Lists.newArrayList(Iterables.transform( project.getConfigurations().getByName( JacocoPlugin.AGENT_CONFIGURATION_NAME), new Function<Object, FileTree>() { @Override public FileTree apply(@Nullable Object it) { return project.zipTree(it); } })); } }); jacocoAgentTask.include(FILE_JACOCO_AGENT); jacocoAgentTask.into(new File(getGlobalScope().getIntermediatesDir(), "jacoco")); } return jacocoAgentTask; }
@Override public void execute(@NonNull Copy copyLint) { copyLint.from( new File(variantScope.getGlobalScope().getIntermediatesDir(), "lint/lint.jar")); copyLint.into(variantScope.getBaseBundleDir()); } }
private static Copy getConjureSources( Project project, org.gradle.api.internal.file.SourceDirectorySetFactory sourceDirectorySetFactory) { // Conjure code source set SourceDirectorySet conjureSourceSet = sourceDirectorySetFactory.create("conjure"); conjureSourceSet.setSrcDirs(Collections.singleton("src/main/conjure")); conjureSourceSet.setIncludes(Collections.singleton("**/*.yml")); // Copy conjure imports into build directory File buildDir = new File(project.getBuildDir(), "conjure"); // Copy conjure sources into build directory Copy copyConjureSourcesTask = project.getTasks().create("copyConjureSourcesIntoBuild", Copy.class); copyConjureSourcesTask.into(project.file(buildDir)).from(conjureSourceSet); copyConjureSourcesTask.doFirst(task -> { GFileUtils.deleteDirectory(buildDir); }); Task cleanTask = project.getTasks().findByName(TASK_CLEAN); cleanTask.dependsOn(project.getTasks().findByName("cleanCopyConjureSourcesIntoBuild")); return copyConjureSourcesTask; }
private Copy _addTaskCopyTLDDocResources(final Project project) { Copy copy = GradleUtil.addTask( project, COPY_TLDDOC_RESOURCES_TASK_NAME, Copy.class); copy.from("src/main/tlddoc"); copy.into( new Callable<File>() { @Override public File call() throws Exception { TLDDocTask tldDocTask = (TLDDocTask)GradleUtil.getTask( project, TLDDOC_TASK_NAME); return tldDocTask.getDestinationDir(); } }); copy.setDescription("Copies tag library documentation resources."); return copy; }
@Override public void execute(@NonNull Copy task) { task.from(new Callable<List<FileTree>>() { @Override public List<FileTree> call() throws Exception { List<FileTree> fileTrees = Lists.newArrayList(); for (File file : scope.getProject().getConfigurations().getByName( JacocoPlugin.AGENT_CONFIGURATION_NAME)) { fileTrees.add(scope.getProject().zipTree(file)); } return fileTrees; } }); task.include(scope.getJacocoAgent().getName()); task.into(scope.getJacocoAgentOutputDirectory()); }
private void setupSolrPackaging(Project p, PackagingExtension extension, Path packageFolder, Zip zipPackage, Task cleanTargetFolder) { // FIXME This is only POC for Solr configuration only. Set<String> environments = extension.getEnvironments().get(); Path configurationFolder = extension.getConfigurationFolder().getAsFile().get().toPath(); for (String environment : environments) { Path sourceFolder = configurationFolder.resolve(environment).resolve("solr"); Path commonFolder = configurationFolder.resolve(COMMON_CONFIG).resolve("solr"); Path targetFolder = packageFolder.resolve("solr/config/" + environment); Copy copySolrCommonConfig = p.getTasks().create("copySolrCommonEnv_" + environment, Copy.class, t -> { t.from(commonFolder); t.into(targetFolder); t.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE); t.exclude(SOLR_CONFIG_EXCLUDE); }); copySolrCommonConfig.dependsOn(cleanTargetFolder); Copy copySolrConfig = p.getTasks().create("copySolrEnv_" + environment, Copy.class, t -> { t.from(sourceFolder); t.into(targetFolder); t.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE); t.exclude(SOLR_CONFIG_EXCLUDE); }); copySolrConfig.dependsOn(copySolrCommonConfig); zipPackage.dependsOn(copySolrConfig); } }
private void configEnv(Project project) { Task jar = project.getTasks().getByName("jar"); Copy copy = project.getTasks().create("copy", Copy.class); copy.into(project.getBuildDir() + "/classes/java/main"); // copy.from("/home/xiaoquan/idea-workspace/support-plugin/.idea/misc.xml"); // copy.into("/home/xiaoquan/tmp/gradle_tmp"); Action<Task> taskAction = (t) -> { NukeEnvExtension nukeEnvExtension = (NukeEnvExtension) project.getExtensions().getByName(Nuke_Ext_Name); EnvDomain qa = nukeEnvExtension.getQa(); if (qa.getConfigDir() != null) { String configDir = qa.getConfigDir(); copy.from(configDir); } copy.exclude(qa.getExclude()); copy.execute(); }; jar.doFirst(taskAction); }
private void setupDatahubPackaging(Project p, PackagingExtension extension, Path packageFolder, Zip zipPackage, Task cleanTargetFolder) { Copy copyDataHubWar = p.getTasks().create("copyDataHubWar", Copy.class, t -> { t.from(extension.getDatahubWar(), s -> s.rename(".*", "datahub-webapp.war")); t.into(packageFolder.resolve("datahub/bin")); t.onlyIf(a -> { if (a.getInputs().getSourceFiles().isEmpty()) { t.into(targetFolder); t.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE); t.exclude(DATAHUB_CONFIG_EXCLUDE); t.into(targetFolder); t.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE); t.exclude(DATAHUB_CONFIG_EXCLUDE);
copy.into(deployableExtension.getDeployableBuildDir().toPath().resolve("resource")); });
/** * Create task to update license file * * @param tasks Task container to create task * @param projectConfig Project configuration for general project data * @param files Resolver for file names */ @Mutate public void createLicenseUpdateTask(ModelMap<Task> tasks, ProjectConfig projectConfig, FileOperations files) { tasks.create("licenseUpdate", Copy.class, t -> { t.setDescription("Update license file from template."); t.setGroup("license"); t.from(files.file("src/doc/templates/LICENSE.txt")); t.into(t.getProject().getProjectDir()); Map<String, Object> properties = new HashMap<>(); properties.put("year", LocalDate.now().getYear()); t.expand(properties); }); }
/** * Create task to update license file * * @param tasks Task container to create task * @param projectConfig Project configuration for general project data * @param files Resolver for file names */ @Mutate public void createLicenseUpdateTask(ModelMap<Task> tasks, ProjectConfig projectConfig, FileOperations files) { tasks.create("licenseUpdate", Copy.class, t -> { t.setDescription("Update license file from template."); t.setGroup("license"); t.from(files.file("src/doc/templates/LICENSE.txt")); t.into(t.getProject().getProjectDir()); Map<String, Object> properties = new HashMap<>(); properties.put("year", LocalDate.now().getYear()); t.expand(properties); }); }
copy.into(deployableExtension.getDeployableBuildDir().toPath().resolve("resource")); });
@Override void configure(Task task) { super.configure(task); Copy t = (Copy)task; t.setDescription("Prepares azure templates for publishing and deployment."); t.from(azure.getTemplateSrcDir(), (CopySpec spec) -> { spec.filter(templateRenderer); }); t.into(azure.getTemplateBuildDir()); } }
t.setDescription(format("Copy files for Docker image '%s'", image.getName())); t.setGroup("docker"); t.into(buildDir.toPath().resolve(Paths.get("docker", image.getName())).toFile()); t.from(Paths.get("src", "docker", image.getName()).toString(), c -> { c.expand(context);
private Copy createGeneratedModelOrganizationTask(Project project, Task dependencyTask) { String generatedModelsOutputBaseDirPath = generatedModelsOutputDirBasePath.get(); String generatedModelsBasePackagePath = project.getBuildDir().getPath() + "/generated/source/rocky/src/com/shopify/rocky"; return project.getTasks().create("organizeGeneratedModels", Copy.class, (Copy task) -> { task.dependsOn(dependencyTask); task.from(generatedModelsOutputBaseDirPath + "/tmp/Enums", copySpec -> { copySpec.into("/enums"); copySpec.include("*.kt"); }); task.from(generatedModelsOutputBaseDirPath + "/tmp/Queries", copySpec -> { copySpec.into("/queries"); copySpec.include("*.kt"); }); task.from(generatedModelsOutputBaseDirPath + "/tmp/Inputs", copySpec -> { copySpec.into("/inputs"); copySpec.include("*.kt"); }); task.from(generatedModelsOutputBaseDirPath + "/tmp/Mutations", copySpec -> { copySpec.into("/mutations"); copySpec.include("*.kt"); }); task.from(generatedModelsOutputBaseDirPath + "/tmp/Responses", copySpec -> { copySpec.into("/responses"); copySpec.include("*.kt"); }); task.setIncludeEmptyDirs(true); task.into(generatedModelsBasePackagePath); task.execute(); }); }
@Override void configure(Task task) { super.configure(task); Copy t = (Copy)task; t.setDescription("Prepares azure templates for test deployments."); t.from(azure.getTemplateSrcDir(), (CopySpec spec) -> { spec.filter(templateRenderer); }); t.from(azure.getTemplateTestSrcDir(), (CopySpec spec) -> { spec.filter(templateRenderer); }); t.into(azure.getTemplateTestBuildDir()); } }
private void _configureTaskBuildWSDL( final BuildWSDLTask buildWSDLTask, Copy processResourcesTask, Configuration wsdlBuilderConfiguration) { FileCollection fileCollection = buildWSDLTask.getSource(); if (fileCollection.isEmpty()) { return; } Project project = buildWSDLTask.getProject(); for (File inputFile : fileCollection) { _addTaskBuildWSDLTasks( buildWSDLTask, inputFile, wsdlBuilderConfiguration); } if (buildWSDLTask.isBuildLibs()) { TaskOutputs taskOutputs = buildWSDLTask.getOutputs(); GradleUtil.addDependency( project, JavaPlugin.COMPILE_CONFIGURATION_NAME, taskOutputs.getFiles()); } if (buildWSDLTask.isIncludeWSDLs() && (processResourcesTask != null)) { processResourcesTask.into( "wsdl", new Closure<Void>(project) { @SuppressWarnings("unused") public void doCall(CopySpec copySpec) { copySpec.from(buildWSDLTask.getSource()); } }); } }