Search in sources :

Example 6 with CopySpec

use of org.gradle.api.file.CopySpec in project gradle by gradle.

the class Jar method metaInf.

/**
     * Adds content to this JAR archive's META-INF directory.
     *
     * <p>The given action is executed to configure a {@code CopySpec}.</p>
     *
     * @param configureAction The action.
     * @return The created {@code CopySpec}
     * @since 3.5
     */
public CopySpec metaInf(Action<? super CopySpec> configureAction) {
    CopySpec metaInf = getMetaInf();
    configureAction.execute(metaInf);
    return metaInf;
}
Also used : CopySpec(org.gradle.api.file.CopySpec)

Example 7 with CopySpec

use of org.gradle.api.file.CopySpec in project gradle by gradle.

the class AntGroovydoc method execute.

public void execute(final FileCollection source, File destDir, boolean use, boolean noTimestamp, boolean noVersionStamp, String windowTitle, String docTitle, String header, String footer, String overview, boolean includePrivate, final Set<Groovydoc.Link> links, final Iterable<File> groovyClasspath, Iterable<File> classpath, Project project) {
    final File tmpDir = new File(project.getBuildDir(), "tmp/groovydoc");
    FileOperations fileOperations = (ProjectInternal) project;
    fileOperations.delete(tmpDir);
    fileOperations.copy(new Action<CopySpec>() {

        public void execute(CopySpec copySpec) {
            copySpec.from(source).into(tmpDir);
        }
    });
    List<File> combinedClasspath = ImmutableList.<File>builder().addAll(classpath).addAll(groovyClasspath).build();
    VersionNumber version = VersionNumber.parse(getGroovyVersion(combinedClasspath));
    final Map<String, Object> args = Maps.newLinkedHashMap();
    args.put("sourcepath", tmpDir.toString());
    args.put("destdir", destDir);
    args.put("use", use);
    if (isAtLeast(version, "2.4.6")) {
        args.put("noTimestamp", noTimestamp);
        args.put("noVersionStamp", noVersionStamp);
    }
    args.put("private", includePrivate);
    putIfNotNull(args, "windowtitle", windowTitle);
    putIfNotNull(args, "doctitle", docTitle);
    putIfNotNull(args, "header", header);
    putIfNotNull(args, "footer", footer);
    if (overview != null) {
        args.put("overview", overview);
    }
    invokeGroovydoc(links, combinedClasspath, args);
}
Also used : CopySpec(org.gradle.api.file.CopySpec) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) FileOperations(org.gradle.api.internal.file.FileOperations) File(java.io.File) VersionNumber(org.gradle.util.VersionNumber)

Example 8 with CopySpec

use of org.gradle.api.file.CopySpec in project gradle by gradle.

the class DefaultCopySpec method with.

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;
}
Also used : CopySpec(org.gradle.api.file.CopySpec)

Example 9 with CopySpec

use of org.gradle.api.file.CopySpec in project gradle by gradle.

the class DefaultCopySpec method filesNotMatching.

public CopySpec filesNotMatching(Iterable<String> patterns, Action<? super FileCopyDetails> action) {
    if (!patterns.iterator().hasNext()) {
        throw new InvalidUserDataException("must provide at least one pattern to not match");
    }
    List<Spec> matchers = new ArrayList<Spec>();
    for (String pattern : patterns) {
        matchers.add(PatternMatcherFactory.getPatternMatcher(true, isCaseSensitive(), pattern));
    }
    Spec unionMatcher = Specs.union(matchers.toArray(new Spec[matchers.size()]));
    return eachFile(new MatchingCopyAction(Specs.<RelativePath>negate(unionMatcher), action));
}
Also used : RelativePath(org.gradle.api.file.RelativePath) InvalidUserDataException(org.gradle.api.InvalidUserDataException) ArrayList(java.util.ArrayList) CopySpec(org.gradle.api.file.CopySpec) CopyProcessingSpec(org.gradle.api.file.CopyProcessingSpec) Spec(org.gradle.api.specs.Spec)

Example 10 with CopySpec

use of org.gradle.api.file.CopySpec in project gradle by gradle.

the class FileCopier method createCopySpec.

private DestinationRootCopySpec createCopySpec(Action<? super CopySpec> action) {
    DefaultCopySpec copySpec = new DefaultCopySpec(this.fileResolver, instantiator);
    DestinationRootCopySpec destinationRootCopySpec = new DestinationRootCopySpec(fileResolver, copySpec);
    CopySpec wrapped = instantiator.newInstance(CopySpecWrapper.class, destinationRootCopySpec);
    action.execute(wrapped);
    return destinationRootCopySpec;
}
Also used : CopySpec(org.gradle.api.file.CopySpec)

Aggregations

CopySpec (org.gradle.api.file.CopySpec)13 File (java.io.File)3 ArrayList (java.util.ArrayList)3 InvalidUserDataException (org.gradle.api.InvalidUserDataException)2 Task (org.gradle.api.Task)2 CopyProcessingSpec (org.gradle.api.file.CopyProcessingSpec)2 Spec (org.gradle.api.specs.Spec)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 List (java.util.List)1 Map (java.util.Map)1 Callable (java.util.concurrent.Callable)1 GradleException (org.gradle.api.GradleException)1 InvalidUserCodeException (org.gradle.api.InvalidUserCodeException)1 DefaultDistributionContainer (org.gradle.api.distribution.internal.DefaultDistributionContainer)1 RelativePath (org.gradle.api.file.RelativePath)1 ArchivePublishArtifact (org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact)1 FileOperations (org.gradle.api.internal.file.FileOperations)1 CopySpecInternal (org.gradle.api.internal.file.copy.CopySpecInternal)1