Java Examples for org.gradle.api.file.CopySpec

The following java examples will help you to understand the usage of org.gradle.api.file.CopySpec. These source code samples are taken from different open source projects.

Example 1
Project: gradle-master  File: DefaultCopySpec.java View source code
public CopySpec with(CopySpec... copySpecs) {
    for (CopySpec copySpec : copySpecs) {
        CopySpecInternal copySpecInternal;
        if (copySpec instanceof CopySpecSource) {
            CopySpecSource copySpecSource = (CopySpecSource) copySpec;
            copySpecInternal = copySpecSource.getRootSpec();
        } else {
            copySpecInternal = (CopySpecInternal) copySpec;
        }
        addChildSpec(copySpecInternal);
    }
    return this;
}
Example 2
Project: spaghetti-master  File: CompiledJsCopier.java View source code
public String copyCompiledJs(final File workDir, final File testApplication, String testApplicationName) {
    try {
        // Extract Require JS
        Properties requireJsProps = new Properties();
        InputStream requireJsPropsStream = CompiledJsCopier.class.getResourceAsStream("/META-INF/maven/org.webjars/requirejs/pom.properties");
        try {
            requireJsProps.load(requireJsPropsStream);
        } finally {
            requireJsPropsStream.close();
        }
        logger.debug("Copying test application from {} to {}", testApplication, workDir);
        operations.sync(new Action<CopySpec>() {

            @Override
            public void execute(CopySpec copySpec) {
                copySpec.from(testApplication);
                copySpec.into(workDir);
            }
        });
        String requireJsVersion = requireJsProps.getProperty("version");
        File requireJsFile = new File(workDir, "require.js");
        FileUtils.deleteQuietly(requireJsFile);
        InputStream requireJsStream = CompiledJsCopier.class.getResourceAsStream("/META-INF/resources/webjars/requirejs/" + requireJsVersion + "/require.js");
        try {
            Files.asByteSink(requireJsFile).writeFrom(requireJsStream);
        } finally {
            requireJsStream.close();
        }
        return testApplicationName;
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}
Example 3
Project: liferay-portal-master  File: LiferayOSGiDefaultsPlugin.java View source code
@SuppressWarnings("unused")
public void doCall(CopySpec copySpec) {
    String originalLibSrcDirName = patchTask.getOriginalLibSrcDirName();
    if (originalLibSrcDirName.equals(".")) {
        return;
    }
    Map<Object, Object> leadingPathReplacementsMap = new HashMap<>();
    leadingPathReplacementsMap.put(originalLibSrcDirName, "");
    copySpec.eachFile(new ReplaceLeadingPathAction(leadingPathReplacementsMap));
    copySpec.include(originalLibSrcDirName + "/");
    copySpec.setIncludeEmptyDirs(false);
}
Example 4
Project: ForgeGradle-master  File: CopyInto.java View source code
@Override
public Object call(Object... args) {
    CopySpec spec = (CopySpec) getDelegate();
    // do filters
    for (String s : filters) {
        if (s.startsWith("!"))
            spec.exclude(s.substring(1));
        else
            spec.include(s);
    }
    if (!expands.isEmpty())
        spec.expand(expands);
    if (!Strings.isNullOrEmpty(dir))
        spec.into(dir);
    return null;
}
Example 5
Project: spring-boot-master  File: ApplicationPluginAction.java View source code
@Override
public void execute(Project project) {
    ApplicationPluginConvention applicationConvention = project.getConvention().getPlugin(ApplicationPluginConvention.class);
    DistributionContainer distributions = project.getExtensions().getByType(DistributionContainer.class);
    Distribution distribution = distributions.create("boot");
    CreateBootStartScripts bootStartScripts = project.getTasks().create("bootStartScripts", CreateBootStartScripts.class);
    bootStartScripts.setDescription("Generates OS-specific start scripts to run the" + " project as a Spring Boot application.");
    ((TemplateBasedScriptGenerator) bootStartScripts.getUnixStartScriptGenerator()).setTemplate(project.getResources().getText().fromString(loadResource("/unixStartScript.txt")));
    ((TemplateBasedScriptGenerator) bootStartScripts.getWindowsStartScriptGenerator()).setTemplate(project.getResources().getText().fromString(loadResource("/windowsStartScript.txt")));
    project.getConfigurations().all( configuration -> {
        if ("bootArchives".equals(configuration.getName())) {
            distribution.getContents().with(project.copySpec().into("lib").from((Callable<FileCollection>) () -> configuration.getArtifacts().getFiles()));
            bootStartScripts.setClasspath(configuration.getArtifacts().getFiles());
        }
    });
    bootStartScripts.getConventionMapping().map("outputDir", () -> new File(project.getBuildDir(), "bootScripts"));
    bootStartScripts.getConventionMapping().map("applicationName", () -> applicationConvention.getApplicationName());
    CopySpec binCopySpec = project.copySpec().into("bin").from(bootStartScripts);
    binCopySpec.setFileMode(0x755);
    distribution.getContents().with(binCopySpec);
}
Example 6
Project: gwt-gradle-plugin-master  File: GwtWarPlugin.java View source code
@Override
public void execute(Project t) {
    String modulePathPrefix = extension.getModulePathPrefix();
    if (modulePathPrefix == null || modulePathPrefix.isEmpty()) {
        warTask.from(compileTask.getOutputs());
        return;
    }
    warTask.into(modulePathPrefix == null ? "" : modulePathPrefix, (new ActionClosure<CopySpec>(this, new Action<CopySpec>() {

        @Override
        public void execute(CopySpec spec) {
            spec.from(compileTask.getOutputs());
            spec.exclude("WEB-INF");
        }
    })));
    warTask.into("", (new ActionClosure<CopySpec>(this, new Action<CopySpec>() {

        @Override
        public void execute(CopySpec spec) {
            spec.from(compileTask.getOutputs());
            spec.include("WEB-INF");
        }
    })));
}
Example 7
Project: gradle-haxe-plugin-master  File: HaxeBasePlugin.java View source code
public static <T extends Har> T createSourceTask(final Project project, final HaxeBinaryBase<?> binary, Class<T> harType) {
    final BinaryNamingScheme namingScheme = ((BinaryInternal) binary).getNamingScheme();
    String sourceTaskName = namingScheme.getTaskName("bundle", "source");
    T sourceTask = project.getTasks().create(sourceTaskName, harType);
    sourceTask.setDescription("Bundles the sources of " + binary);
    sourceTask.getConventionMapping().map("baseName", new Callable<String>() {

        @Override
        public String call() throws Exception {
            return project.getName();
        }
    });
    sourceTask.getConventionMapping().map("destinationDir", new Callable<File>() {

        @Override
        public File call() throws Exception {
            return project.file(project.getBuildDir() + "/haxe-source/" + namingScheme.getOutputDirectoryBase());
        }
    });
    sourceTask.getConventionMapping().map("embeddedResources", new Callable<Map<String, File>>() {

        @Override
        public Map<String, File> call() throws Exception {
            return gatherEmbeddedResources(binary.getSource());
        }
    });
    CopySpec sources = sourceTask.getRootSpec().addChild().into("sources");
    sources.setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE);
    sources.from(getSources(HaxeSourceSet.class, binary));
    CopySpec resources = sourceTask.getRootSpec().addChild().into(RESOURCE_SET_NAME);
    resources.setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE);
    resources.from(getSources(ResourceSet.class, binary));
    CopySpec embedded = sourceTask.getRootSpec().addChild().into("embedded");
    embedded.setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE);
    embedded.from(Collections2.transform(binary.getSource().withType(HaxeResourceSet.class), new Function<HaxeResourceSet, Collection<File>>() {

        @Override
        public Collection<File> apply(HaxeResourceSet resourceSet) {
            return resourceSet.getEmbeddedResources().values();
        }
    }));
    sourceTask.dependsOn(binary.getSource());
    project.getTasks().getByName(namingScheme.getLifecycleTaskName()).dependsOn(sourceTask);
    binary.setSourceHarTask(sourceTask);
    binary.builtBy(sourceTask);
    // TODO This should state more clearly what it does
    ArchivePublishArtifact artifact = (ArchivePublishArtifact) project.getArtifacts().add(binary.getConfiguration().getName(), sourceTask);
    artifact.setName(project.getName() + "-" + binary.getName());
    artifact.setType("har");
    logger.debug("Created source source task {} for {} in {}", sourceTask, binary, project.getPath());
    return sourceTask;
}
Example 8
Project: SetupBuilder-master  File: MsiBuilder.java View source code
/**
     * Create the lauch4j starter if there was set some and add it to the sources.
     * 
     * @throws Exception if any error occur
     */
private void buildLauch4j() throws Exception {
    if (task.getLaunch4js().size() > 0) {
        Launch4jCreator creator = new Launch4jCreator();
        for (DesktopStarter launch : task.getLaunch4js()) {
            File file = creator.create(launch, task, setup);
            signTool(file);
            CopySpec copySpec = task.getProject().copySpec((Closure<CopySpec>) null);
            task.with(copySpec);
            copySpec.from(file);
            String workDir = launch.getWorkDir();
            if (workDir != null && !workDir.isEmpty()) {
                copySpec.into(workDir);
            }
        }
        creator.close();
    }
}