Search in sources :

Example 1 with AbstractArchiveTask

use of org.gradle.api.tasks.bundling.AbstractArchiveTask in project gradle by gradle.

the class PublishArtifactToFileBuildOutcomeTransformer method getTypeIdentifier.

private String getTypeIdentifier(PublishArtifact artifact) {
    if (artifact instanceof ArchivePublishArtifact) {
        ArchivePublishArtifact publishArtifact = (ArchivePublishArtifact) artifact;
        AbstractArchiveTask task = publishArtifact.getArchiveTask();
        if (task instanceof War) {
            return WAR_ARTIFACT.getTypeIdentifier();
        } else if (task instanceof Ear) {
            return EAR_ARTIFACT.getTypeIdentifier();
        } else if (task instanceof Jar) {
            return JAR_ARTIFACT.getTypeIdentifier();
        } else if (task instanceof Zip) {
            return ZIP_ARTIFACT.getTypeIdentifier();
        } else if (task instanceof Tar) {
            return TAR_ARTIFACT.getTypeIdentifier();
        } else {
            // we don't know about this kind of archive task
            return ARCHIVE_ARTIFACT.getTypeIdentifier();
        }
    } else {
        // The client may try to infer from the file extension.
        return UNKNOWN_ARTIFACT.getTypeIdentifier();
    }
}
Also used : Zip(org.gradle.api.tasks.bundling.Zip) ArchivePublishArtifact(org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact) Tar(org.gradle.api.tasks.bundling.Tar) AbstractArchiveTask(org.gradle.api.tasks.bundling.AbstractArchiveTask) Ear(org.gradle.plugins.ear.Ear) War(org.gradle.api.tasks.bundling.War) Jar(org.gradle.jvm.tasks.Jar)

Example 2 with AbstractArchiveTask

use of org.gradle.api.tasks.bundling.AbstractArchiveTask in project spring-boot by spring-projects.

the class AbstractBootArchiveTests method configure.

private T configure(T task) throws IOException {
    AbstractArchiveTask archiveTask = task;
    archiveTask.getArchiveBaseName().set("test");
    File destination = new File(this.temp, "destination");
    destination.mkdirs();
    archiveTask.getDestinationDirectory().set(destination);
    return task;
}
Also used : AbstractArchiveTask(org.gradle.api.tasks.bundling.AbstractArchiveTask) JarFile(java.util.jar.JarFile) ZipFile(org.apache.commons.compress.archivers.zip.ZipFile) File(java.io.File)

Example 3 with AbstractArchiveTask

use of org.gradle.api.tasks.bundling.AbstractArchiveTask in project gradle by gradle.

the class LazyPublishArtifact method getDelegate.

private PublishArtifactInternal getDelegate() {
    if (delegate == null) {
        Object value = provider.get();
        if (value instanceof FileSystemLocation) {
            FileSystemLocation location = (FileSystemLocation) value;
            delegate = fromFile(location.getAsFile());
        } else if (value instanceof File) {
            delegate = fromFile((File) value);
        } else if (value instanceof AbstractArchiveTask) {
            delegate = new ArchivePublishArtifact((AbstractArchiveTask) value);
        } else if (value instanceof Task) {
            delegate = fromFile(((Task) value).getOutputs().getFiles().getSingleFile());
        } else if (fileResolver != null) {
            delegate = fromFile(fileResolver.resolve(value));
        } else {
            throw new InvalidUserDataException(String.format("Cannot convert provided value (%s) to a file.", value));
        }
    }
    return delegate;
}
Also used : AbstractArchiveTask(org.gradle.api.tasks.bundling.AbstractArchiveTask) Task(org.gradle.api.Task) ArchivePublishArtifact(org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact) FileSystemLocation(org.gradle.api.file.FileSystemLocation) AbstractArchiveTask(org.gradle.api.tasks.bundling.AbstractArchiveTask) InvalidUserDataException(org.gradle.api.InvalidUserDataException) File(java.io.File)

Aggregations

AbstractArchiveTask (org.gradle.api.tasks.bundling.AbstractArchiveTask)3 File (java.io.File)2 ArchivePublishArtifact (org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact)2 JarFile (java.util.jar.JarFile)1 ZipFile (org.apache.commons.compress.archivers.zip.ZipFile)1 InvalidUserDataException (org.gradle.api.InvalidUserDataException)1 Task (org.gradle.api.Task)1 FileSystemLocation (org.gradle.api.file.FileSystemLocation)1 Tar (org.gradle.api.tasks.bundling.Tar)1 War (org.gradle.api.tasks.bundling.War)1 Zip (org.gradle.api.tasks.bundling.Zip)1 Jar (org.gradle.jvm.tasks.Jar)1 Ear (org.gradle.plugins.ear.Ear)1