Search in sources :

Example 11 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 12 with CopySpec

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

the class DefaultCopySpec method with.

@Override
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 13 with CopySpec

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

the class War method webInf.

/**
 * Adds some content to the {@code WEB-INF} directory for this WAR archive.
 *
 * <p>The given action is executed to configure a {@link CopySpec}.
 *
 * @param configureAction The action to execute
 * @return The newly created {@code CopySpec}.
 * @since 3.5
 */
public CopySpec webInf(Action<? super CopySpec> configureAction) {
    CopySpec webInf = getWebInf();
    configureAction.execute(webInf);
    return webInf;
}
Also used : DefaultCopySpec(org.gradle.api.internal.file.copy.DefaultCopySpec) CopySpec(org.gradle.api.file.CopySpec)

Example 14 with CopySpec

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

the class JavaGradlePluginPlugin method configureDescriptorGeneration.

private void configureDescriptorGeneration(final Project project, final GradlePluginDevelopmentExtension extension) {
    final GeneratePluginDescriptors generatePluginDescriptors = project.getTasks().create(GENERATE_PLUGIN_DESCRIPTORS_TASK_NAME, GeneratePluginDescriptors.class);
    generatePluginDescriptors.setGroup(PLUGIN_DEVELOPMENT_GROUP);
    generatePluginDescriptors.setDescription(GENERATE_PLUGIN_DESCRIPTORS_TASK_DESCRIPTION);
    generatePluginDescriptors.conventionMapping("declarations", new Callable<List<PluginDeclaration>>() {

        @Override
        public List<PluginDeclaration> call() {
            return Lists.newArrayList(extension.getPlugins());
        }
    });
    generatePluginDescriptors.conventionMapping("outputDirectory", new Callable<File>() {

        @Override
        public File call() {
            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() {
            return generatePluginDescriptors.getOutputDirectory();
        }
    });
    processResources.dependsOn(generatePluginDescriptors);
}
Also used : CopySpec(org.gradle.api.file.CopySpec) Copy(org.gradle.api.tasks.Copy) GeneratePluginDescriptors(org.gradle.plugin.devel.tasks.GeneratePluginDescriptors) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File)

Example 15 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)

Aggregations

CopySpec (org.gradle.api.file.CopySpec)15 File (java.io.File)4 ArrayList (java.util.ArrayList)3 GradleException (org.gradle.api.GradleException)2 InvalidUserDataException (org.gradle.api.InvalidUserDataException)2 Task (org.gradle.api.Task)2 CopyProcessingSpec (org.gradle.api.file.CopyProcessingSpec)2 DefaultCopySpec (org.gradle.api.internal.file.copy.DefaultCopySpec)2 Spec (org.gradle.api.specs.Spec)2 List (java.util.List)1 Map (java.util.Map)1 Callable (java.util.concurrent.Callable)1 Action (org.gradle.api.Action)1 InvalidUserCodeException (org.gradle.api.InvalidUserCodeException)1 UncheckedIOException (org.gradle.api.UncheckedIOException)1 DefaultDistributionContainer (org.gradle.api.distribution.internal.DefaultDistributionContainer)1 RegularFile (org.gradle.api.file.RegularFile)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