parent
a3a373b67f
commit
09f7cff612
|
@ -99,11 +99,14 @@ class InternalDistributionArchiveSetupPluginFuncTest extends AbstractGradleFuncT
|
||||||
import org.gradle.api.artifacts.type.ArtifactTypeDefinition;
|
import org.gradle.api.artifacts.type.ArtifactTypeDefinition;
|
||||||
import org.gradle.api.internal.artifacts.ArtifactAttributes;
|
import org.gradle.api.internal.artifacts.ArtifactAttributes;
|
||||||
|
|
||||||
|
def snapshotFile = file("snapshot-\${version}.txt")
|
||||||
|
snapshotFile << 'some snapshot content'
|
||||||
distribution_archives {
|
distribution_archives {
|
||||||
producerTar {
|
producerTar {
|
||||||
content {
|
content {
|
||||||
project.copySpec {
|
project.copySpec {
|
||||||
from 'someFile.txt'
|
from 'someFile.txt'
|
||||||
|
from snapshotFile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,12 +144,20 @@ class InternalDistributionArchiveSetupPluginFuncTest extends AbstractGradleFuncT
|
||||||
file("consumer/build/archives/elasticsearch.tar.gz").exists()
|
file("consumer/build/archives/elasticsearch.tar.gz").exists()
|
||||||
|
|
||||||
when:
|
when:
|
||||||
result = gradleRunner("copyDir").build()
|
result = gradleRunner("copyDir", "-Pversion=1.0").build()
|
||||||
then: "plain copy task executed and target folder contains plain content"
|
then: "plain copy task executed and target folder contains plain content"
|
||||||
result.task(':buildProducer').outcome == TaskOutcome.SUCCESS
|
result.task(':buildProducer').outcome == TaskOutcome.SUCCESS
|
||||||
result.task(':consumer:copyDir').outcome == TaskOutcome.SUCCESS
|
result.task(':consumer:copyDir').outcome == TaskOutcome.SUCCESS
|
||||||
file("producer-tar/build/install/someFile.txt").exists()
|
file("producer-tar/build/install/someFile.txt").exists()
|
||||||
|
file("producer-tar/build/install/snapshot-1.0.txt").exists()
|
||||||
file("consumer/build/dir/someFile.txt").exists()
|
file("consumer/build/dir/someFile.txt").exists()
|
||||||
|
|
||||||
|
when:
|
||||||
|
gradleRunner("copyDir", "-Pversion=2.0").build()
|
||||||
|
then: "old content is cleared out"
|
||||||
|
file("producer-tar/build/install/someFile.txt").exists()
|
||||||
|
!file("producer-tar/build/install/snapshot-1.0.txt").exists()
|
||||||
|
file("producer-tar/build/install/snapshot-2.0.txt").exists()
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean assertTarPermissionDefaults(File tarArchive) {
|
private static boolean assertTarPermissionDefaults(File tarArchive) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.elasticsearch.gradle.internal;
|
||||||
|
|
||||||
import org.gradle.api.Named;
|
import org.gradle.api.Named;
|
||||||
import org.gradle.api.file.CopySpec;
|
import org.gradle.api.file.CopySpec;
|
||||||
import org.gradle.api.tasks.Copy;
|
import org.gradle.api.tasks.Sync;
|
||||||
import org.gradle.api.tasks.TaskProvider;
|
import org.gradle.api.tasks.TaskProvider;
|
||||||
import org.gradle.api.tasks.bundling.AbstractArchiveTask;
|
import org.gradle.api.tasks.bundling.AbstractArchiveTask;
|
||||||
|
|
||||||
|
@ -30,10 +30,10 @@ import java.util.function.Supplier;
|
||||||
public class DistributionArchive implements Named {
|
public class DistributionArchive implements Named {
|
||||||
|
|
||||||
private TaskProvider<? extends AbstractArchiveTask> archiveTask;
|
private TaskProvider<? extends AbstractArchiveTask> archiveTask;
|
||||||
private TaskProvider<Copy> expandedDistTask;
|
private TaskProvider<Sync> expandedDistTask;
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
public DistributionArchive(TaskProvider<? extends AbstractArchiveTask> archiveTask, TaskProvider<Copy> expandedDistTask, String name) {
|
public DistributionArchive(TaskProvider<? extends AbstractArchiveTask> archiveTask, TaskProvider<Sync> expandedDistTask, String name) {
|
||||||
this.archiveTask = archiveTask;
|
this.archiveTask = archiveTask;
|
||||||
this.expandedDistTask = expandedDistTask;
|
this.expandedDistTask = expandedDistTask;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -57,7 +57,7 @@ public class DistributionArchive implements Named {
|
||||||
return archiveTask;
|
return archiveTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TaskProvider<Copy> getExpandedDistTask() {
|
public TaskProvider<Sync> getExpandedDistTask() {
|
||||||
return expandedDistTask;
|
return expandedDistTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.gradle.api.Project;
|
||||||
import org.gradle.api.artifacts.type.ArtifactTypeDefinition;
|
import org.gradle.api.artifacts.type.ArtifactTypeDefinition;
|
||||||
import org.gradle.api.plugins.BasePlugin;
|
import org.gradle.api.plugins.BasePlugin;
|
||||||
import org.gradle.api.tasks.AbstractCopyTask;
|
import org.gradle.api.tasks.AbstractCopyTask;
|
||||||
import org.gradle.api.tasks.Copy;
|
import org.gradle.api.tasks.Sync;
|
||||||
import org.gradle.api.tasks.TaskContainer;
|
import org.gradle.api.tasks.TaskContainer;
|
||||||
import org.gradle.api.tasks.bundling.AbstractArchiveTask;
|
import org.gradle.api.tasks.bundling.AbstractArchiveTask;
|
||||||
import org.gradle.api.tasks.bundling.Compression;
|
import org.gradle.api.tasks.bundling.Compression;
|
||||||
|
@ -72,7 +72,7 @@ public class InternalDistributionArchiveSetupPlugin implements Plugin<Project> {
|
||||||
var subProjectDir = archiveToSubprojectName(name);
|
var subProjectDir = archiveToSubprojectName(name);
|
||||||
var copyDistributionTaskName = "build" + capitalize(name.substring(0, name.length() - 3));
|
var copyDistributionTaskName = "build" + capitalize(name.substring(0, name.length() - 3));
|
||||||
TaskContainer tasks = project.getTasks();
|
TaskContainer tasks = project.getTasks();
|
||||||
var explodedDist = tasks.register(copyDistributionTaskName, Copy.class, copy -> copy.into(subProjectDir + "/build/install/"));
|
var explodedDist = tasks.register(copyDistributionTaskName, Sync.class, sync -> sync.into(subProjectDir + "/build/install/"));
|
||||||
var archiveTaskName = "build" + capitalize(name);
|
var archiveTaskName = "build" + capitalize(name);
|
||||||
return name.endsWith("Tar")
|
return name.endsWith("Tar")
|
||||||
? new DistributionArchive(tasks.register(archiveTaskName, SymbolicLinkPreservingTar.class), explodedDist, name)
|
? new DistributionArchive(tasks.register(archiveTaskName, SymbolicLinkPreservingTar.class), explodedDist, name)
|
||||||
|
|
Loading…
Reference in New Issue