@@ -12,6 +12,8 @@ import org.elasticsearch.gradle.Version
12
12
import org.elasticsearch.gradle.internal.info.BuildParams
13
13
import org.elasticsearch.gradle.internal.test.AntFixture
14
14
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
15
+ import org.elasticsearch.gradle.transform.UnzipTransform
16
+ import org.gradle.api.internal.artifacts.ArtifactAttributes
15
17
16
18
apply plugin : ' elasticsearch.jdk-download'
17
19
apply plugin : ' elasticsearch.internal-testclusters'
@@ -39,34 +41,29 @@ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
39
41
logger. warn(" Disabling repository-old-versions tests because we can't get the pid file on windows" )
40
42
tasks. named(" testingConventions" ). configure { enabled = false }
41
43
} else {
42
- /* Set up tasks to unzip and run the old versions of ES before running the integration tests.
44
+ /* Register a gradle artifact transformation to unpack resolved elasticsearch distributions. We only resolve
45
+ * zip files here. Using artifact transforms allow a better caching of the downloaded distros as the
46
+ * transformed (unpacked) distro will be cached by gradle resulting in less unpacking
47
+ *
43
48
* To avoid testing against too many old versions, always pick first and last version per major
44
49
*/
50
+ project. getDependencies(). registerTransform(UnzipTransform . class, transformSpec -> {
51
+ transformSpec. getFrom(). attribute(ArtifactAttributes . ARTIFACT_FORMAT , ArtifactTypeDefinition . ZIP_TYPE );
52
+ transformSpec. getTo(). attribute(ArtifactAttributes . ARTIFACT_FORMAT , ArtifactTypeDefinition . DIRECTORY_TYPE );
53
+ });
54
+
45
55
for (String versionString : [' 5.0.0' , ' 5.6.16' , ' 6.0.0' , ' 6.8.20' ]) {
46
56
Version version = Version . fromString(versionString)
47
57
String packageName = ' org.elasticsearch.distribution.zip'
48
58
String artifact = " ${ packageName} :elasticsearch:${ version} @zip"
49
59
String versionNoDots = version. toString(). replace(' .' , ' _' )
50
60
String configName = " es${ versionNoDots} "
51
61
52
- configurations. create(configName)
53
-
62
+ def config = configurations. create(configName)
63
+ config . getAttributes() . attribute( ArtifactAttributes . ARTIFACT_FORMAT , ArtifactTypeDefinition . DIRECTORY_TYPE );
54
64
dependencies. add(configName, artifact)
55
65
56
- // TODO Rene: we should be able to replace these unzip tasks with gradle artifact transforms
57
- TaskProvider<Sync > unzip = tasks. register(" unzipEs${ versionNoDots} " , Sync ) {
58
- Configuration oldEsDependency = configurations[configName]
59
- dependsOn oldEsDependency
60
- /* Use a closure here to delay resolution of the dependency until we need
61
- * it */
62
- from {
63
- oldEsDependency. collect { zipTree(it) }
64
- }
65
- into temporaryDir
66
- }
67
-
68
66
String repoLocation = " ${ buildDir} /cluster/shared/repo/${ versionNoDots} "
69
-
70
67
String clusterName = versionNoDots
71
68
72
69
def testClusterProvider = testClusters. register(clusterName) {
@@ -83,8 +80,7 @@ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
83
80
}
84
81
85
82
TaskProvider<AntFixture > fixture = tasks. register(" oldES${ versionNoDots} Fixture" , AntFixture ) {
86
- dependsOn project. configurations. oldesFixture, jdks. legacy
87
- dependsOn unzip
83
+ dependsOn project. configurations. oldesFixture, jdks. legacy, config
88
84
executable = " ${ BuildParams.runtimeJavaHome} /bin/java"
89
85
env ' CLASSPATH' , " ${ -> project.configurations.oldesFixture.asPath} "
90
86
// old versions of Elasticsearch need JAVA_HOME
@@ -95,7 +91,7 @@ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
95
91
}
96
92
args ' oldes.OldElasticsearch' ,
97
93
baseDir,
98
- unzip . get (). temporaryDir ,
94
+ " ${ -> config.getSingleFile ().toPath() } " ,
99
95
false ,
100
96
" path.repo: ${ repoLocation} "
101
97
if (version. onOrAfter(' 6.8.0' ) && Architecture . current() == Architecture . AARCH64 ) {
0 commit comments