forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/93582-downsample-persistent-task
- Loading branch information
Showing
1,014 changed files
with
18,844 additions
and
6,659 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
build-tools-internal/gradle/wrapper/gradle-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionSha256Sum=5625a0ae20fe000d9225d000b36909c7a0e0e8dda61c19b12da769add847c975 | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip | ||
distributionSha256Sum=5022b0b25fe182b0e50867e77f484501dba44feeea88f5c1f13b6b4660463640 | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
243 changes: 243 additions & 0 deletions
243
...al/src/integTest/groovy/org/elasticsearch/gradle/internal/StringTemplatePluginTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,243 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.gradle.internal; | ||
|
||
import org.elasticsearch.gradle.fixtures.AbstractGradleFuncTest; | ||
import org.gradle.testkit.runner.TaskOutcome; | ||
|
||
class StringTemplatePluginTest extends AbstractGradleFuncTest { | ||
|
||
def "test substitution"() { | ||
given: | ||
internalBuild() | ||
file('src/main/p/X-Box.java.st') << """ | ||
public class \$Type\$Box { | ||
final \$type\$ value; | ||
public \$Type\$Box(\$type\$ value) { | ||
this.value = value; | ||
} | ||
} | ||
""".stripIndent().stripTrailing() | ||
file('src/main/generated-src/someFile.txt') << """ | ||
Just some random data | ||
""" | ||
|
||
buildFile << """ | ||
apply plugin: 'elasticsearch.build' | ||
apply plugin: 'elasticsearch.string-templates' | ||
tasks.named("stringTemplates").configure { | ||
template { | ||
it.properties = ["Type" : "Int", "type" : "int"] | ||
it.inputFile = file("src/main/p/X-Box.java.st") | ||
it.outputFile = "p/IntBox.java" | ||
} | ||
template { | ||
it.properties = ["Type" : "Long", "type" : "long"] | ||
it.inputFile = file("src/main/p/X-Box.java.st") | ||
it.outputFile = "p/LongBox.java" | ||
} | ||
} | ||
""" | ||
|
||
when: | ||
def result = gradleRunner("stringTemplates", '-g', gradleUserHome).build() | ||
|
||
then: | ||
result.task(":stringTemplates").outcome == TaskOutcome.SUCCESS | ||
file("src/main/generated-src/someFile.txt").exists() == false | ||
file("src/main/generated-src/p/IntBox.java").exists() | ||
file("src/main/generated-src/p/LongBox.java").exists() | ||
|
||
//assert output | ||
normalized(file("src/main/generated-src/p/IntBox.java").text) == """ | ||
public class IntBox { | ||
final int value; | ||
public IntBox(int value) { | ||
this.value = value; | ||
} | ||
} | ||
""".stripIndent().stripTrailing() | ||
normalized(file("src/main/generated-src/p/LongBox.java").text) == """ | ||
public class LongBox { | ||
final long value; | ||
public LongBox(long value) { | ||
this.value = value; | ||
} | ||
} | ||
""".stripIndent().stripTrailing() | ||
} | ||
|
||
def "test basic conditional"() { | ||
given: | ||
internalBuild() | ||
file('src/main/Color.txt.st') << """ | ||
\$if(Red)\$1 Red\$endif\$ | ||
\$if(Blue)\$2 Blue\$endif\$ | ||
\$if(Green)\$3 Green\$endif\$ | ||
""".stripIndent().stripTrailing() | ||
|
||
buildFile << """ | ||
apply plugin: 'elasticsearch.build' | ||
apply plugin: 'elasticsearch.string-templates' | ||
tasks.named("stringTemplates").configure { | ||
template { | ||
it.properties = ["Red" : "true", "Blue" : "", "Green" : "true"] | ||
it.inputFile = file("src/main/Color.txt.st") | ||
it.outputFile = "Color.txt" | ||
} | ||
} | ||
""" | ||
|
||
when: | ||
def result = gradleRunner("stringTemplates", '-g', gradleUserHome).build() | ||
|
||
then: | ||
result.task(":stringTemplates").outcome == TaskOutcome.SUCCESS | ||
file("src/main/generated-src/Color.txt").exists() | ||
//assert output | ||
normalized(file("src/main/generated-src/Color.txt").text) == """ | ||
1 Red | ||
3 Green | ||
""".stripIndent().stripTrailing() | ||
} | ||
|
||
def "test if then else"() { | ||
given: | ||
internalBuild() | ||
file('src/main/Token.txt.st') << """ | ||
\$if(Foo)\$1 Foo | ||
\$elseif(Bar)\$2 Bar | ||
\$else\$3 Baz | ||
\$endif\$ | ||
""".stripIndent().stripTrailing() | ||
|
||
buildFile << """ | ||
apply plugin: 'elasticsearch.build' | ||
apply plugin: 'elasticsearch.string-templates' | ||
tasks.named("stringTemplates").configure { | ||
template { | ||
it.properties = [:] // no properties | ||
it.inputFile = file("src/main/Token.txt.st") | ||
it.outputFile = "Token.txt" | ||
} | ||
} | ||
""" | ||
|
||
when: | ||
def result = gradleRunner("stringTemplates", '-g', gradleUserHome).build() | ||
|
||
then: | ||
result.task(":stringTemplates").outcome == TaskOutcome.SUCCESS | ||
file("src/main/generated-src/Token.txt").exists() | ||
//assert output | ||
normalized(file("src/main/generated-src/Token.txt").text) == """ | ||
3 Baz | ||
""".stripIndent().stripTrailing() | ||
} | ||
|
||
def "output file already present and up to date"() { | ||
given: | ||
internalBuild() | ||
file('src/main/UpToDate.txt.st') << """ | ||
Hello World! | ||
""".stripIndent().stripTrailing() | ||
// the output file is already created and up to date (content wise) | ||
file('src/main/generated-src/UpToDate.txt') << """ | ||
Hello World! | ||
""".stripIndent().stripTrailing() | ||
|
||
buildFile << """ | ||
apply plugin: 'elasticsearch.build' | ||
apply plugin: 'elasticsearch.string-templates' | ||
tasks.named("stringTemplates").configure { | ||
template { | ||
it.properties = [:] // no properties | ||
it.inputFile = file("src/main/UpToDate.txt.st") | ||
it.outputFile = "UpToDate.txt" | ||
} | ||
} | ||
""" | ||
|
||
when: | ||
def result = gradleRunner("stringTemplates", '-g', gradleUserHome).build() | ||
|
||
then: | ||
result.task(":stringTemplates").outcome == TaskOutcome.SUCCESS | ||
file("src/main/generated-src/UpToDate.txt").exists() | ||
//assert output - expect the original output | ||
normalized(file("src/main/generated-src/UpToDate.txt").text) == """ | ||
Hello World! | ||
""".stripIndent().stripTrailing() | ||
} | ||
|
||
def "output file already present but not up to date"() { | ||
given: | ||
internalBuild() | ||
file('src/main/Message.txt.st') << """ | ||
Hello World! | ||
""".stripIndent().stripTrailing() | ||
// the output file is already created, but not up to date (content wise) | ||
file('src/main/generated-src/Message.txt') << """ | ||
Hello Chris xx | ||
""".stripIndent().stripTrailing() | ||
|
||
buildFile << """ | ||
apply plugin: 'elasticsearch.build' | ||
apply plugin: 'elasticsearch.string-templates' | ||
tasks.named("stringTemplates").configure { | ||
template { | ||
it.properties = [:] // no properties | ||
it.inputFile = file("src/main/Message.txt.st") | ||
it.outputFile = "Message.txt" | ||
} | ||
} | ||
""" | ||
|
||
when: | ||
def result = gradleRunner("stringTemplates", '-g', gradleUserHome).build() | ||
|
||
then: | ||
result.task(":stringTemplates").outcome == TaskOutcome.SUCCESS | ||
file("src/main/generated-src/Message.txt").exists() | ||
//assert output - expect the updated message output | ||
normalized(file("src/main/generated-src/Message.txt").text) == """ | ||
Hello World! | ||
""".stripIndent().stripTrailing() | ||
} | ||
|
||
def "cleanup delete files"() { | ||
given: | ||
internalBuild() | ||
file('src/main/generated-src/someFile.txt') << """ | ||
Just some random data | ||
""" | ||
|
||
buildFile << """ | ||
apply plugin: 'elasticsearch.build' | ||
apply plugin: 'elasticsearch.string-templates' | ||
tasks.named("stringTemplates").configure { | ||
// no templates | ||
} | ||
""" | ||
|
||
when: | ||
def result = gradleRunner("stringTemplates", '-g', gradleUserHome).build() | ||
|
||
then: | ||
result.task(":stringTemplates").outcome == TaskOutcome.SUCCESS | ||
file("src/main/generated-src/someFile.txt").exists() == false | ||
file("src/main/generated-src").exists() == true | ||
} | ||
} |
Oops, something went wrong.