File tree Expand file tree Collapse file tree 7 files changed +47
-10
lines changed
main/java/org/elasticsearch/gradle/info
minimumRuntime/java/org/elasticsearch/gradle/info Expand file tree Collapse file tree 7 files changed +47
-10
lines changed Original file line number Diff line number Diff line change @@ -273,8 +273,17 @@ class VersionPropertiesLoader {
273
273
}
274
274
elasticsearch + = " -" + qualifier
275
275
}
276
- if (" true" . equals(systemProperties. getProperty(" build.snapshot" , " true" ))) {
277
- elasticsearch + = " -SNAPSHOT"
276
+ final String buildSnapshotSystemProperty = systemProperties. getProperty(" build.snapshot" , " true" );
277
+ switch (buildSnapshotSystemProperty) {
278
+ case " true" :
279
+ elasticsearch + = " -SNAPSHOT"
280
+ break ;
281
+ case " false" :
282
+ // do nothing
283
+ break ;
284
+ default :
285
+ throw new IllegalArgumentException (
286
+ " build.snapshot was set to [" + buildSnapshotSystemProperty + " ] but can only be unset or [true|false]" );
278
287
}
279
288
loadedProps. put(" elasticsearch" , elasticsearch)
280
289
}
Original file line number Diff line number Diff line change @@ -59,6 +59,20 @@ public void apply(Project project) {
59
59
testSeed = testSeedProperty ;
60
60
}
61
61
62
+ final String buildSnapshotSystemProperty = System .getProperty ("build.snapshot" , "true" );
63
+ final boolean isSnapshotBuild ;
64
+ switch (buildSnapshotSystemProperty ) {
65
+ case "true" :
66
+ isSnapshotBuild = true ;
67
+ break ;
68
+ case "false" :
69
+ isSnapshotBuild = false ;
70
+ break ;
71
+ default :
72
+ throw new IllegalArgumentException (
73
+ "build.snapshot was set to [" + buildSnapshotSystemProperty + "] but can only be unset or [true|false]"
74
+ );
75
+ }
62
76
final List <JavaHome > javaVersions = new ArrayList <>();
63
77
for (int version = 8 ; version <= Integer .parseInt (minimumCompilerVersion .getMajorVersion ()); version ++) {
64
78
if (System .getenv (getJavaHomeEnvVarName (Integer .toString (version ))) != null ) {
@@ -102,6 +116,7 @@ public void apply(Project project) {
102
116
params .setIsInternal (GlobalBuildInfoPlugin .class .getResource ("/buildSrc.marker" ) != null );
103
117
params .setDefaultParallel (findDefaultParallel (project ));
104
118
params .setInFipsJvm (isInFipsJvm ());
119
+ params .setIsSnapshotBuild (isSnapshotBuild );
105
120
});
106
121
107
122
project .allprojects (
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ public class BuildParams {
33
33
private static Boolean isCi ;
34
34
private static Boolean isInternal ;
35
35
private static Integer defaultParallel ;
36
+ private static Boolean isSnapshotBuild ;
36
37
37
38
/**
38
39
* Initialize global build parameters. This method accepts and a initialization function which in turn accepts a
@@ -112,6 +113,10 @@ public static Integer getDefaultParallel() {
112
113
return value (defaultParallel );
113
114
}
114
115
116
+ public static boolean isSnapshotBuild () {
117
+ return value (BuildParams .isSnapshotBuild );
118
+ }
119
+
115
120
private static <T > T value (T object ) {
116
121
if (object == null ) {
117
122
String callingMethod = Thread .currentThread ().getStackTrace ()[2 ].getMethodName ();
@@ -225,6 +230,11 @@ public void setIsInternal(Boolean isInternal) {
225
230
public void setDefaultParallel (int defaultParallel ) {
226
231
BuildParams .defaultParallel = defaultParallel ;
227
232
}
233
+
234
+ public void setIsSnapshotBuild (final boolean isSnapshotBuild ) {
235
+ BuildParams .isSnapshotBuild = isSnapshotBuild ;
236
+ }
237
+
228
238
}
229
239
230
240
/**
Original file line number Diff line number Diff line change 15
15
* KIND, either express or implied. See the License for the
16
16
*/
17
17
18
-
19
18
import org.elasticsearch.gradle.LoggedExec
20
19
import org.elasticsearch.gradle.MavenFilteringHack
21
- import org.redline_rpm.header.Flags
22
20
import org.elasticsearch.gradle.OS
21
+ import org.elasticsearch.gradle.info.BuildParams
22
+ import org.redline_rpm.header.Flags
23
23
24
24
import java.nio.file.Files
25
25
import java.nio.file.Path
@@ -281,7 +281,7 @@ ospackage {
281
281
url ' https://www.elastic.co/'
282
282
283
283
// signing setup
284
- if (project. hasProperty(' signing.password' ) && System . getProperty( ' build.snapshot ' , ' true ' ) == ' false' ) {
284
+ if (project. hasProperty(' signing.password' ) && BuildParams . isSnapshotBuild( ) == false ) {
285
285
signingKeyId = project. hasProperty(' signing.keyId' ) ? project. property(' signing.keyId' ) : ' D88E42B4'
286
286
signingKeyPassphrase = project. property(' signing.password' )
287
287
signingKeyRingFile = project. hasProperty(' signing.secretKeyRingFile' ) ?
Original file line number Diff line number Diff line change
1
+ import org.elasticsearch.gradle.info.BuildParams
2
+
1
3
import static org.elasticsearch.gradle.testclusters.TestDistribution.DEFAULT
2
4
3
5
/*
@@ -42,7 +44,7 @@ buildRestTests.expectedUnconvertedCandidates = [
42
44
testClusters. integTest {
43
45
if (singleNode(). testDistribution == DEFAULT ) {
44
46
setting ' xpack.license.self_generated.type' , ' trial'
45
- if (" false " . equals( System . getProperty( " build.snapshot " )) == false ) {
47
+ if (BuildParams . isSnapshotBuild() ) {
46
48
setting ' xpack.autoscaling.enabled' , ' true'
47
49
}
48
50
}
Original file line number Diff line number Diff line change
1
+ import org.elasticsearch.gradle.info.BuildParams
2
+
1
3
apply plugin : ' elasticsearch.testclusters'
2
4
apply plugin : ' elasticsearch.standalone-rest-test'
3
5
apply plugin : ' elasticsearch.rest-test'
@@ -65,8 +67,7 @@ integTest.runner {
65
67
66
68
// TODO: fix this rest test to not depend on a hardcoded port!
67
69
def blacklist = [' getting_started/10_monitor_cluster_health/*' ]
68
- boolean snapshot = Boolean . valueOf(System . getProperty(" build.snapshot" , " true" ))
69
- if (! snapshot) {
70
+ if (BuildParams . isSnapshotBuild() == false ) {
70
71
// these tests attempt to install basic/internal licenses signed against the dev/public.key
71
72
// Since there is no infrastructure in place (anytime soon) to generate licenses using the production
72
73
// private key, these tests are blacklisted in non-snapshot test runs
Original file line number Diff line number Diff line change 1
1
import org.elasticsearch.gradle.MavenFilteringHack
2
+ import org.elasticsearch.gradle.info.BuildParams
2
3
3
4
import java.nio.file.Files
4
5
import java.nio.file.Paths
@@ -68,11 +69,10 @@ processResources {
68
69
inputs. properties(expansions)
69
70
MavenFilteringHack . filter(it, expansions)
70
71
}
71
- boolean snapshot = " true" . equals(System . getProperty(" build.snapshot" , " true" ))
72
72
String licenseKey = System . getProperty(" license.key" )
73
73
if (licenseKey != null ) {
74
74
println " Using provided license key from ${ licenseKey} "
75
- } else if (snapshot ) {
75
+ } else if (BuildParams . isSnapshotBuild() ) {
76
76
licenseKey = Paths . get(project. projectDir. path, ' snapshot.key' )
77
77
} else {
78
78
throw new IllegalArgumentException (' Property license.key must be set for release build' )
You can’t perform that action at this time.
0 commit comments