当前位置: 首页>>代码示例>>Java>>正文


Java Copy类代码示例

本文整理汇总了Java中org.gradle.api.tasks.Copy的典型用法代码示例。如果您正苦于以下问题:Java Copy类的具体用法?Java Copy怎么用?Java Copy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Copy类属于org.gradle.api.tasks包,在下文中一共展示了Copy类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureDescriptorGeneration

import org.gradle.api.tasks.Copy; //导入依赖的package包/类
private void configureDescriptorGeneration(final Project project, final GradlePluginDevelopmentExtension extension) {
    final GeneratePluginDescriptors generatePluginDescriptors = project.getTasks().create(GENERATE_PLUGIN_DESCRIPTORS_TASK_NAME, GeneratePluginDescriptors.class);
    generatePluginDescriptors.conventionMapping("declarations", new Callable<List<PluginDeclaration>>() {
        @Override
        public List<PluginDeclaration> call() throws Exception {
            return Lists.newArrayList(extension.getPlugins());
        }
    });
    generatePluginDescriptors.conventionMapping("outputDirectory", new Callable<File>() {
        @Override
        public File call() throws Exception {
            return new File(project.getBuildDir(), generatePluginDescriptors.getName());
        }
    });
    Copy processResources = (Copy) project.getTasks().getByName(PROCESS_RESOURCES_TASK);
    CopySpec copyPluginDescriptors = processResources.getRootSpec().addChild();
    copyPluginDescriptors.into("META-INF/gradle-plugins");
    copyPluginDescriptors.from(new Callable<File>() {
        @Override
        public File call() throws Exception {
            return generatePluginDescriptors.getOutputDirectory();
        }
    });
    processResources.dependsOn(generatePluginDescriptors);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:26,代码来源:JavaGradlePluginPlugin.java

示例2: getJacocoAgentTask

import org.gradle.api.tasks.Copy; //导入依赖的package包/类
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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:TaskManager.java

示例3: createStlCopyTask

import org.gradle.api.tasks.Copy; //导入依赖的package包/类
public static void createStlCopyTask(NdkHandler ndkHandler, String stl,
        ModelMap<Task> tasks, final File buildDir,
        final SharedLibraryBinarySpec binary) {
    if (stl.endsWith("_shared")) {
        final StlNativeToolSpecification stlConfig = new StlNativeToolSpecification(ndkHandler,
                stl, binary.getTargetPlatform());

        String copyTaskName = NdkNamingScheme.getTaskName(binary, "copy", "StlSo");
        tasks.create(copyTaskName, Copy.class, new Action<Copy>() {
            @Override
            public void execute(Copy copy) {
                copy.from(stlConfig.getStlLib(binary.getTargetPlatform().getName()));
                copy.into(new File(buildDir, NdkNamingScheme.getOutputDirectoryName(binary)));

            }
        });
        binary.getBuildTask().dependsOn(copyTaskName);
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:StlConfiguration.java

示例4: createProcessResourcesTaskForBinary

import org.gradle.api.tasks.Copy; //导入依赖的package包/类
private void createProcessResourcesTaskForBinary(final ClassDirectoryBinarySpecInternal binary, final Project target) {
    final BinaryNamingScheme namingScheme = binary.getNamingScheme();
    binary.getSource().withType(JvmResourceSet.class).all(new Action<JvmResourceSet>() {
        public void execute(JvmResourceSet resourceSet) {
            Copy resourcesTask = target.getTasks().create(namingScheme.getTaskName("process", "resources"), ProcessResources.class);
            resourcesTask.setDescription(String.format("Processes %s.", resourceSet));
            new DslObject(resourcesTask).getConventionMapping().map("destinationDir", new Callable<File>() {
                public File call() throws Exception {
                    return binary.getResourcesDir();
                }
            });
            binary.getTasks().add(resourcesTask);
            binary.builtBy(resourcesTask);
            resourcesTask.from(resourceSet.getSource());
        }
    });
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:18,代码来源:LegacyJavaComponentPlugin.java

示例5: copyGracljTools

import org.gradle.api.tasks.Copy; //导入依赖的package包/类
@BinaryTasks
public void copyGracljTools(ModelMap<Task> tasks, JUnitTestSuiteBinarySpec binary, GracljInternal internal) {
    Test testTask = binary.getTasks().getRun();

    // Need to provide explicit list of directories to scan for test namespaces in. Not sure it should be in this rule.
    JvmAssembly assembly = ((WithJvmAssembly) binary).getAssembly();
    Stream<File> classDirs = assembly.getClassDirectories().stream();
    Stream<File> resourceDirs = assembly.getResourceDirectories().stream();
    String testDirs = Stream.concat(classDirs, resourceDirs)
        .map(File::getAbsolutePath)
        .collect(Collectors.joining(File.pathSeparator));
    testTask.systemProperty("clojure.test.dirs", testDirs);

    tasks.create(binary.getName() + "GracljTools", Copy.class, task -> {
        testTask.dependsOn(task);
        File tools = internal.resolve("org.graclj:graclj-tools:" + internal.getGracljVersion() + "@jar").getSingleFile();
        task.from(task.getProject().zipTree(tools));
        task.into(binary.getClassesDir());
    });
    testTask.setClasspath(testTask.getClasspath().plus(internal.resolve("org.graclj:graclj-tools:" + internal.getGracljVersion())));
}
 
开发者ID:ajoberstar,项目名称:graclj,代码行数:22,代码来源:ClojureTestSuiteRules.java

示例6: adjustTaskGroupAssignments

import org.gradle.api.tasks.Copy; //导入依赖的package包/类
/**
 * Assign some standard tasks and tasks created by third-party plugins to their task groups according to the
 * order of things for Checkstyle Addons.
 */
public void adjustTaskGroupAssignments()
{
    final TaskContainer tasks = project.getTasks();
    tasks.getByName(BasePlugin.ASSEMBLE_TASK_NAME).setGroup(ARTIFACTS_GROUP_NAME);
    tasks.getByName(JavaPlugin.JAR_TASK_NAME).setGroup(ARTIFACTS_GROUP_NAME);

    final SourceSet sqSourceSet = buildUtil.getSourceSet(BuildUtil.SONARQUBE_SOURCE_SET_NAME);
    tasks.getByName(JavaPlugin.COMPILE_JAVA_TASK_NAME).setGroup(BasePlugin.BUILD_GROUP);
    tasks.getByName(sqSourceSet.getCompileJavaTaskName()).setGroup(BasePlugin.BUILD_GROUP);
    tasks.getByName(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME).setGroup(BasePlugin.BUILD_GROUP);

    for (final FindBugs fbTask : tasks.withType(FindBugs.class)) {
        fbTask.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
    }
    for (final Checkstyle csTask : tasks.withType(Checkstyle.class)) {
        csTask.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
    }
    for (final Copy task : tasks.withType(Copy.class)) {
        if (task.getName().startsWith("process") && task.getName().endsWith("Resources")) {
            task.setGroup(LifecycleBasePlugin.BUILD_GROUP);
        }
    }
}
 
开发者ID:checkstyle-addons,项目名称:checkstyle-addons,代码行数:28,代码来源:TaskCreator.java

示例7: createProcessResourcesTaskForBinary

import org.gradle.api.tasks.Copy; //导入依赖的package包/类
private void createProcessResourcesTaskForBinary(final SourceSet sourceSet, SourceDirectorySet resourceSet, final Project target) {
    Copy resourcesTask = target.getTasks().create(sourceSet.getProcessResourcesTaskName(), ProcessResources.class);
    resourcesTask.setDescription("Processes " + resourceSet + ".");
    new DslObject(resourcesTask).getConventionMapping().map("destinationDir", new Callable<File>() {
        public File call() throws Exception {
            return sourceSet.getOutput().getResourcesDir();
        }
    });
    resourcesTask.from(resourceSet);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:11,代码来源:JavaBasePlugin.java

示例8: apply

import org.gradle.api.tasks.Copy; //导入依赖的package包/类
@Override
public void apply(Project project) {
    jSassBasePlugin = project.getPlugins().apply(JSassBasePlugin.class);

    project.getPlugins().apply(JavaPlugin.class);

    project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(sourceSet -> {
        String taskName = sourceSet.getTaskName("compile", "Sass");

        Set<File> srcDirs = sourceSet.getResources().getSrcDirs();

        int i = 1;
        for (File srcDir : srcDirs) {
            SassCompile sassCompile = project.getTasks().create(i == 1 ? taskName : taskName + i, SassCompile.class);
            i++;

            sassCompile.setGroup(BasePlugin.BUILD_GROUP);
            sassCompile.setDescription("Compile sass and scss files for the " + sourceSet.getName() + " source set");

            sassCompile.setSourceDir(srcDir);

            Copy processResources = (Copy) project.getTasks().getByName(sourceSet.getProcessResourcesTaskName());

            sassCompile.getConventionMapping().map("destinationDir", () -> {
                        if (jSassBasePlugin.getExtension().isInplace()) {
                            return srcDir;
                        } else {
                            return processResources.getDestinationDir();
                        }
                    });

            processResources.dependsOn(sassCompile);
        }
    });
}
 
开发者ID:freefair,项目名称:jsass-gradle-plugin,代码行数:36,代码来源:JSassJavaPlugin.java

示例9: apply

import org.gradle.api.tasks.Copy; //导入依赖的package包/类
@Override
public void apply(Project project) {
  project.getExtensions().create("web", WebExtension.class);

  project.getPlugins().apply(NodePlugin.class);
  project.getPlugins().apply(JavaLibraryPlugin.class);

  JavaPluginConvention java = project.getConvention().getPlugin(JavaPluginConvention.class);
  java.getSourceSets()
      .getByName(SourceSet.MAIN_SOURCE_SET_NAME)
      .getOutput()
      .dir(ImmutableMap.of("builtBy", "copyWeb"), "build/javaweb");

  CacheableYarnTask buildWeb = project.getTasks().create("buildWeb", CacheableYarnTask.class);
  buildWeb.dependsOn(project.getRootProject().getTasks().findByName("yarn"));
  buildWeb.setArgs(ImmutableList.of("run", "build"));
  buildWeb.getInputs().dir("app");
  buildWeb.getInputs().dir("internals");
  // We assume the yarn task correctly handles up-to-date checks for node_modules, so only
  // need to look at yarn.lock here.
  buildWeb.getInputs().file(project.getRootProject().file("yarn.lock"));
  buildWeb.getOutputs().dir("build");

  Copy copyWeb = project.getTasks().create("copyWeb", Copy.class);
  copyWeb.dependsOn(buildWeb);
  copyWeb.from("build/web");
  project.afterEvaluate(
      p -> {
        ImmutableWebExtension web = project.getExtensions().getByType(WebExtension.class);
        copyWeb.into("build/javaweb/" + web.javaPackage().replace('.', '/'));
      });
}
 
开发者ID:curioswitch,项目名称:curiostack,代码行数:33,代码来源:CurioWebPlugin.java

示例10: createReadmeUpdateTasks

import org.gradle.api.tasks.Copy; //导入依赖的package包/类
/**
 * Create task to update readme file from template
 *
 * @param tasks Task container to create new tasks
 * @param projectConfig Project configuration
 * @param projectContext Project context
 * @param extensions Extension container
 */
@Mutate
public void createReadmeUpdateTasks(ModelMap<Task> tasks, ProjectConfig projectConfig,
        ProjectContext projectContext, ExtensionContainer extensions) {
    // Create task to update the README
    Map<String, Object> context = new HashMap<>();

    extensions.getExtraProperties().getProperties().forEach((name, value) -> {
        context.put(name, value);
    });

    context.put("project", projectContext);
    context.put("projectConfig", projectConfig);

    tasks.create("readmeUpdate", Copy.class, t -> {
        t.setDescription("Update README from template.");
        t.setGroup("documentation");
        t.from("src/doc/templates");
        t.include("README.template.md");
        t.rename(n -> n.replace(".template.", "."));
        t.expand(context);

        ConventionMapping parameters = t.getConventionMapping();
        parameters.map("destinationDir", () -> projectContext.getProjectDir());
    });

    tasks.named("assemble", t -> {
        t.dependsOn("readmeUpdate");
    });
}
 
开发者ID:jochenseeber,项目名称:gradle-project-config,代码行数:38,代码来源:ProjectConfigPlugin.java

示例11: setupPackageTasks

import org.gradle.api.tasks.Copy; //导入依赖的package包/类
void setupPackageTasks(Project project, Task generateTask) {
	final File buildDir = new File(project.getBuildDir(), "npm_compile");
	final File distDir = getNpmOutputDir(project);

	project.getTasks().create(PublishTypescriptStubsTask.NAME, PublishTypescriptStubsTask.class);
	TSGeneratorConfig config = project.getExtensions().getByType(TSGeneratorConfig.class);

	Copy copySources = project.getTasks().create("processTypescript", Copy.class);
	copySources.from(config.getGenDir());
	copySources.into(buildDir);
	copySources.dependsOn(generateTask);

	// copy .npmrc file from root to working directory if available
	final File npmrcFile = new File(project.getProjectDir(), ".npmrc");
	if (npmrcFile.exists()) {
		copySources.getInputs().file(npmrcFile);
		copySources.doFirst(new Action<Task>() {
			@Override
			public void execute(Task task) {
				File targetFile = new File(buildDir, ".npmrc");
				buildDir.mkdirs();
				TypescriptUtils.copyFile(npmrcFile, targetFile);
			}
		});
	}

	CompileTypescriptStubsTask compileTypescriptTask = project.getTasks().create(CompileTypescriptStubsTask.NAME,
			CompileTypescriptStubsTask.class);
	try {
		NpmInstallTask npmInstall = (NpmInstallTask) project.getTasks().getByName("npmInstall");
		npmInstall.setWorkingDir(buildDir);
		npmInstall.dependsOn(copySources);
		npmInstall.getInputs().file(new File(buildDir, "package.json"));
		npmInstall.getOutputs().dir(new File(buildDir, "node_modules"));
		compileTypescriptTask.dependsOn(npmInstall);
	}
	catch (UnknownTaskException e) {
		LOGGER.warn("task not found, ok in testing", e);
	}

	ConfigurableFileTree fileTree = project.fileTree(buildDir);
	fileTree.include("package.json");
	fileTree.include(".npmrc");
	fileTree.include("**/*.ts");
	fileTree.exclude("**/*.d.ts");
	compileTypescriptTask.getInputs().files(fileTree);
	compileTypescriptTask.setWorkingDir(buildDir);
	compileTypescriptTask.getOutputs().dir(buildDir);

	ConfigurableFileTree assembleFileTree = project.fileTree(new File(buildDir, "src"));
	assembleFileTree.include("**/*.ts");
	assembleFileTree.include("**/*.js");
	assembleFileTree.include("**/*.js.map");

	Copy assembleSources = project.getTasks().create("assembleTypescript", Copy.class);
	assembleSources.from(assembleFileTree);
	assembleSources.from(new File(buildDir, "package.json"));
	assembleSources.into(distDir);
	assembleSources.dependsOn(compileTypescriptTask);
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:61,代码来源:TSGeneratorPlugin.java

示例12: getProcessJavaResourcesTask

import org.gradle.api.tasks.Copy; //导入依赖的package包/类
public AndroidTask<Copy> getProcessJavaResourcesTask() {
    return processJavaResourcesTask;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:VariantScope.java

示例13: setProcessJavaResourcesTask

import org.gradle.api.tasks.Copy; //导入依赖的package包/类
public void setProcessJavaResourcesTask(
        AndroidTask<Copy> processJavaResourcesTask) {
    this.processJavaResourcesTask = processJavaResourcesTask;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:VariantScope.java

示例14: execute

import org.gradle.api.tasks.Copy; //导入依赖的package包/类
@Override
public void execute(Object arg0) {
	if(arg0 instanceof FileCopyDetails)
	{
		FileCopyDetails detail = (FileCopyDetails)arg0;
		File file = detail.getFile();
		if(!file.isFile())
			return;
		String originMd5 = md5s.get(detail.getRelativePath().getPathString());
		if(originMd5==null)
			return;
		String nowMd5 = getMD5(file);
		if(nowMd5.equals(originMd5))
			detail.exclude(); //Only copy modified files.
	}
	else if(arg0 instanceof Copy)
	{
		Copy task = (Copy)arg0;
		md5s = new HashMap<String, String>();
		if(started==false)
		{
			started = true;
			try {
				File dest = task.getDestinationDir();
				if(dest.exists())
					FileUtils.deleteDirectory(task.getDestinationDir());
				task.getDestinationDir().mkdir();
			} catch (IOException e1) {
				throw new RuntimeException("Failed to clear directory:"+task.getDestinationDir().getAbsolutePath(), e1);
			}
			if(inFile.exists())
			{
				try {
					List<String> lines = Files.readLines(inFile, Charset.defaultCharset());
					for(String line : lines)
					{
						if(line.trim().isEmpty())
							continue;
						md5s.put(line.substring(0, line.lastIndexOf(':')), 
								line.substring(line.lastIndexOf(':')+1, line.length()-1));
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			else
			{
				throw new RuntimeException("Can't find md5 record:"+inFile.getAbsolutePath());
			}
		}
		else
		{
			started = false;
			md5s.clear();
		}
	}
	else 
	{
		throw new RuntimeException("Unexpected arg when copying.");
	}
}
 
开发者ID:szszss,项目名称:FGOW,代码行数:62,代码来源:ActionPick.java


注:本文中的org.gradle.api.tasks.Copy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。