File tree 7 files changed +45
-10
lines changed
main/java/org/elasticsearch/gradle/info
minimumRuntime/java/org/elasticsearch/gradle/info
7 files changed +45
-10
lines changed Original file line number Diff line number Diff line change @@ -276,8 +276,17 @@ class VersionPropertiesLoader {
276
276
}
277
277
elasticsearch + = " -" + qualifier
278
278
}
279
- if (" true" . equals(systemProperties. getProperty(" build.snapshot" , " true" ))) {
280
- elasticsearch + = " -SNAPSHOT"
279
+ final String buildSnapshotSystemProperty = systemProperties. getProperty(" build.snapshot" , " true" );
280
+ switch (buildSnapshotSystemProperty) {
281
+ case " true" :
282
+ elasticsearch + = " -SNAPSHOT"
283
+ break ;
284
+ case " false" :
285
+ // do nothing
286
+ break ;
287
+ default :
288
+ throw new IllegalArgumentException (
289
+ " build.snapshot was set to [" + buildSnapshotSystemProperty + " ] but can only be unset or [true|false]" );
281
290
}
282
291
loadedProps. put(" elasticsearch" , elasticsearch)
283
292
}
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 @@ -120,8 +120,7 @@ integTest.runner {
120
120
121
121
// TODO: fix this rest test to not depend on a hardcoded port!
122
122
def blacklist = [' getting_started/10_monitor_cluster_health/*' ]
123
- boolean snapshot = Boolean . valueOf(System . getProperty(" build.snapshot" , " true" ))
124
- if (! snapshot) {
123
+ if (BuildParams . isSnapshotBuild() == false ) {
125
124
// these tests attempt to install basic/internal licenses signed against the dev/public.key
126
125
// Since there is no infrastructure in place (anytime soon) to generate licenses using the production
127
126
// 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
@@ -67,11 +68,10 @@ processResources {
67
68
inputs. properties(expansions)
68
69
MavenFilteringHack . filter(it, expansions)
69
70
}
70
- boolean snapshot = " true" . equals(System . getProperty(" build.snapshot" , " true" ))
71
71
String licenseKey = System . getProperty(" license.key" )
72
72
if (licenseKey != null ) {
73
73
println " Using provided license key from ${ licenseKey} "
74
- } else if (snapshot ) {
74
+ } else if (BuildParams . isSnapshotBuild() ) {
75
75
licenseKey = Paths . get(project. projectDir. path, ' snapshot.key' )
76
76
} else {
77
77
throw new IllegalArgumentException (' Property license.key must be set for release build' )
You can’t perform that action at this time.
0 commit comments