Introduce build qualifier parameter (#35155)
* Introduce property to set version qualifier - VersionProperties.elasticsearch is now a string which can have qualifier and snapshot too - The Version class in the build no longer cares about snapshot and qualifier.
This commit is contained in:
parent
dbc7c9259c
commit
f22700812e
|
@ -39,7 +39,7 @@ if (properties.get("org.elasticsearch.acceptScanTOS", "false") == "true") {
|
|||
// common maven publishing configuration
|
||||
subprojects {
|
||||
group = 'org.elasticsearch'
|
||||
version = VersionProperties.elasticsearch.toString()
|
||||
version = VersionProperties.elasticsearch
|
||||
description = "Elasticsearch subproject ${project.path}"
|
||||
}
|
||||
|
||||
|
@ -282,7 +282,7 @@ subprojects {
|
|||
// other packages (e.g org.elasticsearch.client) will point to server rather than
|
||||
// their own artifacts.
|
||||
if (project.plugins.hasPlugin(BuildPlugin) || project.plugins.hasPlugin(PluginBuildPlugin)) {
|
||||
String artifactsHost = VersionProperties.elasticsearch.isSnapshot() ? "https://snapshots.elastic.co" : "https://artifacts.elastic.co"
|
||||
String artifactsHost = VersionProperties.elasticsearch.endsWith("-SNAPSHOT") ? "https://snapshots.elastic.co" : "https://artifacts.elastic.co"
|
||||
Closure sortClosure = { a, b -> b.group <=> a.group }
|
||||
Closure depJavadocClosure = { shadowed, dep ->
|
||||
if (dep.group == null || false == dep.group.startsWith('org.elasticsearch')) {
|
||||
|
|
|
@ -41,46 +41,29 @@ if (project == rootProject) {
|
|||
* Propagating version.properties to the rest of the build *
|
||||
*****************************************************************************/
|
||||
|
||||
Properties props = new Properties()
|
||||
props.load(project.file('version.properties').newDataInputStream())
|
||||
version = props.getProperty('elasticsearch')
|
||||
boolean snapshot = "true".equals(System.getProperty("build.snapshot", "true"));
|
||||
if (snapshot) {
|
||||
// we update the version property to reflect if we are building a snapshot or a release build
|
||||
// we write this back out below to load it in the Build.java which will be shown in rest main action
|
||||
// to indicate this being a snapshot build or a release build.
|
||||
version += "-SNAPSHOT"
|
||||
props.put("elasticsearch", version);
|
||||
}
|
||||
|
||||
File tempPropertiesFile = new File(project.buildDir, "version.properties")
|
||||
task writeVersionProperties {
|
||||
inputs.properties(props)
|
||||
outputs.file(tempPropertiesFile)
|
||||
doLast {
|
||||
OutputStream stream = Files.newOutputStream(tempPropertiesFile.toPath());
|
||||
try {
|
||||
props.store(stream, "UTF-8");
|
||||
} finally {
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Properties props = VersionPropertiesLoader.loadBuildSrcVersion(project.file('version.properties'))
|
||||
version = props.getProperty("elasticsearch")
|
||||
processResources {
|
||||
dependsOn writeVersionProperties
|
||||
from tempPropertiesFile
|
||||
doLast {
|
||||
Writer writer = file("$destinationDir/version.properties").newWriter()
|
||||
try {
|
||||
props.store(writer, "Generated version properties")
|
||||
} finally {
|
||||
writer.close()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (JavaVersion.current() < JavaVersion.VERSION_1_10) {
|
||||
throw new GradleException('At least Java 10 is required to build elasticsearch gradle tools')
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Java version *
|
||||
*****************************************************************************/
|
||||
|
||||
if (JavaVersion.current() < JavaVersion.VERSION_1_10) {
|
||||
throw new GradleException('At least Java 10 is required to build elasticsearch gradle tools')
|
||||
}
|
||||
// Gradle 4.10 does not support setting this to 11 yet
|
||||
targetCompatibility = "10"
|
||||
sourceCompatibility = "10"
|
||||
|
@ -232,3 +215,42 @@ if (project != rootProject) {
|
|||
generatePomFileForPluginMavenPublication.enabled = false
|
||||
}
|
||||
}
|
||||
|
||||
// Define this here because we need it early.
|
||||
class VersionPropertiesLoader {
|
||||
static Properties loadBuildSrcVersion(File input) throws IOException {
|
||||
Properties props = new Properties();
|
||||
InputStream is = new FileInputStream(input)
|
||||
try {
|
||||
props.load(is)
|
||||
} finally {
|
||||
is.close()
|
||||
}
|
||||
loadBuildSrcVersion(props, System.getProperties())
|
||||
return props
|
||||
}
|
||||
|
||||
protected static void loadBuildSrcVersion(Properties loadedProps, Properties systemProperties) {
|
||||
String elasticsearch = loadedProps.getProperty("elasticsearch")
|
||||
if (elasticsearch == null) {
|
||||
throw new IllegalStateException("Elasticsearch version is missing from properties.")
|
||||
}
|
||||
if (elasticsearch.matches("[0-9]+\\.[0-9]+\\.[0-9]+") == false) {
|
||||
throw new IllegalStateException(
|
||||
"Expected elasticsearch version to be numbers only of the form X.Y.Z but it was: " +
|
||||
elasticsearch
|
||||
)
|
||||
}
|
||||
String qualifier = systemProperties.getProperty("build.version_qualifier", "alpha1");
|
||||
if (qualifier.isEmpty() == false) {
|
||||
if (qualifier.matches("(alpha|beta|rc)\\d+") == false) {
|
||||
throw new IllegalStateException("Invalid qualifier: " + qualifier)
|
||||
}
|
||||
elasticsearch += "-" + qualifier
|
||||
}
|
||||
if ("true".equals(systemProperties.getProperty("build.snapshot", "true"))) {
|
||||
elasticsearch += "-SNAPSHOT"
|
||||
}
|
||||
loadedProps.put("elasticsearch", elasticsearch)
|
||||
}
|
||||
}
|
|
@ -696,18 +696,12 @@ class BuildPlugin implements Plugin<Project> {
|
|||
jarTask.destinationDir = new File(project.buildDir, 'distributions')
|
||||
// fixup the jar manifest
|
||||
jarTask.doFirst {
|
||||
final Version versionWithoutSnapshot = new Version(
|
||||
VersionProperties.elasticsearch.major,
|
||||
VersionProperties.elasticsearch.minor,
|
||||
VersionProperties.elasticsearch.revision,
|
||||
VersionProperties.elasticsearch.suffix,
|
||||
false)
|
||||
// this doFirst is added before the info plugin, therefore it will run
|
||||
// after the doFirst added by the info plugin, and we can override attributes
|
||||
jarTask.manifest.attributes(
|
||||
'X-Compile-Elasticsearch-Version': versionWithoutSnapshot,
|
||||
'X-Compile-Elasticsearch-Version': VersionProperties.elasticsearch.replace("-SNAPSHOT", ""),
|
||||
'X-Compile-Lucene-Version': VersionProperties.lucene,
|
||||
'X-Compile-Elasticsearch-Snapshot': VersionProperties.elasticsearch.isSnapshot(),
|
||||
'X-Compile-Elasticsearch-Snapshot': VersionProperties.isElasticsearchSnapshot(),
|
||||
'Build-Date': ZonedDateTime.now(ZoneOffset.UTC),
|
||||
'Build-Java-Version': project.compilerJavaVersion)
|
||||
if (jarTask.manifest.attributes.containsKey('Change') == false) {
|
||||
|
|
|
@ -42,7 +42,7 @@ public class DocsTestPlugin extends RestTestPlugin {
|
|||
* to the version being built for testing but needs to resolve to
|
||||
* the last released version for docs. */
|
||||
'\\{version\\}':
|
||||
VersionProperties.elasticsearch.toString().replace('-SNAPSHOT', ''),
|
||||
VersionProperties.elasticsearch.replace('-SNAPSHOT', ''),
|
||||
'\\{lucene_version\\}' : VersionProperties.lucene.replaceAll('-snapshot-\\w+$', ''),
|
||||
'\\{build_flavor\\}' :
|
||||
project.integTestCluster.distribution.startsWith('oss-') ? 'oss' : 'default',
|
||||
|
|
|
@ -98,7 +98,7 @@ public class PluginBuildPlugin extends BuildPlugin {
|
|||
project.pluginProperties.extension.name + "-client"
|
||||
)
|
||||
project.tasks.withType(GenerateMavenPom.class) { GenerateMavenPom generatePOMTask ->
|
||||
generatePOMTask.ext.pomFileName = "${project.archivesBaseName}-client-${project.version}.pom"
|
||||
generatePOMTask.ext.pomFileName = "${project.archivesBaseName}-client-${project.versions.elasticsearch}.pom"
|
||||
}
|
||||
} else {
|
||||
project.plugins.withType(MavenPublishPlugin).whenPluginAdded {
|
||||
|
|
|
@ -76,7 +76,7 @@ class PluginPropertiesTask extends Copy {
|
|||
'name': extension.name,
|
||||
'description': extension.description,
|
||||
'version': stringSnap(extension.version),
|
||||
'elasticsearchVersion': stringSnap(VersionProperties.elasticsearch.toString()),
|
||||
'elasticsearchVersion': stringSnap(VersionProperties.elasticsearch),
|
||||
'javaVersion': project.targetCompatibility as String,
|
||||
'classname': extension.classname,
|
||||
'extendedPlugins': extension.extendedPlugins.join(','),
|
||||
|
|
|
@ -22,6 +22,7 @@ import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
|
|||
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis
|
||||
import de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin
|
||||
import org.elasticsearch.gradle.ExportElasticsearchBuildResourcesTask
|
||||
import org.elasticsearch.gradle.VersionProperties
|
||||
import org.gradle.api.JavaVersion
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
|
@ -220,7 +221,7 @@ class PrecommitTasks {
|
|||
private static Task configureLoggerUsage(Project project) {
|
||||
project.configurations.create('loggerUsagePlugin')
|
||||
project.dependencies.add('loggerUsagePlugin',
|
||||
"org.elasticsearch.test:logger-usage:${org.elasticsearch.gradle.VersionProperties.elasticsearch}")
|
||||
"org.elasticsearch.test:logger-usage:${VersionProperties.elasticsearch}")
|
||||
return project.tasks.create('loggerUsageCheck', LoggerUsageTask.class) {
|
||||
classpath = project.configurations.loggerUsagePlugin
|
||||
javaHome = project.runtimeJavaHome
|
||||
|
|
|
@ -101,7 +101,7 @@ class ClusterFormationTasks {
|
|||
// from here on everything else works the same as if it's the current version, we fetch the BWC version
|
||||
// from mirrors using gradles built-in mechanism etc.
|
||||
|
||||
configureDistributionDependency(project, config.distribution, bwcDistro, config.bwcVersion)
|
||||
configureDistributionDependency(project, config.distribution, bwcDistro, config.bwcVersion.toString())
|
||||
for (Map.Entry<String, Object> entry : config.plugins.entrySet()) {
|
||||
configureBwcPluginDependency(project, entry.getValue(), bwcPlugins, config.bwcVersion)
|
||||
}
|
||||
|
@ -112,9 +112,12 @@ class ClusterFormationTasks {
|
|||
// we start N nodes and out of these N nodes there might be M bwc nodes.
|
||||
// for each of those nodes we might have a different configuration
|
||||
final Configuration distro
|
||||
final Version elasticsearchVersion
|
||||
final String elasticsearchVersion
|
||||
if (i < config.numBwcNodes) {
|
||||
elasticsearchVersion = config.bwcVersion
|
||||
elasticsearchVersion = config.bwcVersion.toString()
|
||||
if (project.bwcVersions.unreleased.contains(config.bwcVersion)) {
|
||||
elasticsearchVersion += "-SNAPSHOT"
|
||||
}
|
||||
distro = bwcDistro
|
||||
} else {
|
||||
elasticsearchVersion = VersionProperties.elasticsearch
|
||||
|
@ -156,8 +159,10 @@ class ClusterFormationTasks {
|
|||
}
|
||||
|
||||
/** Adds a dependency on the given distribution */
|
||||
static void configureDistributionDependency(Project project, String distro, Configuration configuration, Version elasticsearchVersion) {
|
||||
if (elasticsearchVersion.before('6.3.0') && distro.startsWith('oss-')) {
|
||||
static void configureDistributionDependency(Project project, String distro, Configuration configuration, String elasticsearchVersion) {
|
||||
if (Version.fromString(elasticsearchVersion).before('6.3.0') &&
|
||||
distro.startsWith('oss-')
|
||||
) {
|
||||
distro = distro.substring('oss-'.length())
|
||||
}
|
||||
String packaging = distro
|
||||
|
@ -227,7 +232,7 @@ class ClusterFormationTasks {
|
|||
setup = configureAddKeystoreFileTasks(prefix, project, setup, node)
|
||||
|
||||
if (node.config.plugins.isEmpty() == false) {
|
||||
if (node.nodeVersion == VersionProperties.elasticsearch) {
|
||||
if (node.nodeVersion == Version.fromString(VersionProperties.elasticsearch)) {
|
||||
setup = configureCopyPluginsTask(taskName(prefix, node, 'copyPlugins'), project, setup, node, prefix)
|
||||
} else {
|
||||
setup = configureCopyBwcPluginsTask(taskName(prefix, node, 'copyBwcPlugins'), project, setup, node, prefix)
|
||||
|
@ -591,7 +596,7 @@ class ClusterFormationTasks {
|
|||
|
||||
static Task configureInstallPluginTask(String name, Project project, Task setup, NodeInfo node, String pluginName, String prefix) {
|
||||
final FileCollection pluginZip;
|
||||
if (node.nodeVersion != VersionProperties.elasticsearch) {
|
||||
if (node.nodeVersion != Version.fromString(VersionProperties.elasticsearch)) {
|
||||
pluginZip = project.configurations.getByName(pluginBwcConfigurationName(prefix, pluginName))
|
||||
} else {
|
||||
pluginZip = project.configurations.getByName(pluginConfigurationName(prefix, pluginName))
|
||||
|
|
|
@ -112,7 +112,7 @@ class NodeInfo {
|
|||
Version nodeVersion
|
||||
|
||||
/** Holds node configuration for part of a test cluster. */
|
||||
NodeInfo(ClusterConfiguration config, int nodeNum, Project project, String prefix, Version nodeVersion, File sharedDir) {
|
||||
NodeInfo(ClusterConfiguration config, int nodeNum, Project project, String prefix, String nodeVersion, File sharedDir) {
|
||||
this.config = config
|
||||
this.nodeNum = nodeNum
|
||||
this.project = project
|
||||
|
@ -124,7 +124,7 @@ class NodeInfo {
|
|||
}
|
||||
baseDir = new File(project.buildDir, "cluster/${prefix} node${nodeNum}")
|
||||
pidFile = new File(baseDir, 'es.pid')
|
||||
this.nodeVersion = nodeVersion
|
||||
this.nodeVersion = Version.fromString(nodeVersion)
|
||||
homeDir = homeDir(baseDir, config.distribution, nodeVersion)
|
||||
pathConf = pathConf(baseDir, config.distribution, nodeVersion)
|
||||
if (config.dataDir != null) {
|
||||
|
@ -173,11 +173,11 @@ class NodeInfo {
|
|||
}
|
||||
|
||||
|
||||
if (nodeVersion.before("6.2.0")) {
|
||||
if (this.nodeVersion.before("6.2.0")) {
|
||||
javaVersion = 8
|
||||
} else if (nodeVersion.onOrAfter("6.2.0") && nodeVersion.before("6.3.0")) {
|
||||
} else if (this.nodeVersion.onOrAfter("6.2.0") && this.nodeVersion.before("6.3.0")) {
|
||||
javaVersion = 9
|
||||
} else if (nodeVersion.onOrAfter("6.3.0") && nodeVersion.before("6.5.0")) {
|
||||
} else if (this.nodeVersion.onOrAfter("6.3.0") && this.nodeVersion.before("6.5.0")) {
|
||||
javaVersion = 10
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ class NodeInfo {
|
|||
}
|
||||
|
||||
/** Returns the directory elasticsearch home is contained in for the given distribution */
|
||||
static File homeDir(File baseDir, String distro, Version nodeVersion) {
|
||||
static File homeDir(File baseDir, String distro, String nodeVersion) {
|
||||
String path
|
||||
switch (distro) {
|
||||
case 'integ-test-zip':
|
||||
|
@ -321,7 +321,7 @@ class NodeInfo {
|
|||
return new File(baseDir, path)
|
||||
}
|
||||
|
||||
static File pathConf(File baseDir, String distro, Version nodeVersion) {
|
||||
static File pathConf(File baseDir, String distro, String nodeVersion) {
|
||||
switch (distro) {
|
||||
case 'integ-test-zip':
|
||||
case 'zip':
|
||||
|
|
|
@ -12,28 +12,17 @@ public final class Version implements Comparable<Version> {
|
|||
private final int minor;
|
||||
private final int revision;
|
||||
private final int id;
|
||||
private final boolean snapshot;
|
||||
/**
|
||||
* Suffix on the version name.
|
||||
*/
|
||||
private final String suffix;
|
||||
|
||||
private static final Pattern pattern =
|
||||
Pattern.compile("(\\d)+\\.(\\d+)\\.(\\d+)(-alpha\\d+|-beta\\d+|-rc\\d+)?(-SNAPSHOT)?");
|
||||
|
||||
public Version(int major, int minor, int revision) {
|
||||
this(major, minor, revision, "", false);
|
||||
}
|
||||
|
||||
public Version(int major, int minor, int revision, String suffix, boolean snapshot) {
|
||||
Objects.requireNonNull(major, "major version can't be null");
|
||||
Objects.requireNonNull(minor, "minor version can't be null");
|
||||
Objects.requireNonNull(revision, "revision version can't be null");
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
this.revision = revision;
|
||||
this.snapshot = snapshot;
|
||||
this.suffix = suffix == null ? "" : suffix;
|
||||
|
||||
// currently snapshot is not taken into account
|
||||
this.id = major * 10000000 + minor * 100000 + revision * 1000;
|
||||
|
@ -58,17 +47,13 @@ public final class Version implements Comparable<Version> {
|
|||
return new Version(
|
||||
Integer.parseInt(matcher.group(1)),
|
||||
parseSuffixNumber(matcher.group(2)),
|
||||
parseSuffixNumber(matcher.group(3)),
|
||||
matcher.group(4),
|
||||
matcher.group(5) != null
|
||||
parseSuffixNumber(matcher.group(3))
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final String snapshotStr = snapshot ? "-SNAPSHOT" : "";
|
||||
return String.valueOf(getMajor()) + "." + String.valueOf(getMinor()) + "." + String.valueOf(getRevision()) +
|
||||
(suffix == null ? "" : suffix) + snapshotStr;
|
||||
return String.valueOf(getMajor()) + "." + String.valueOf(getMinor()) + "." + String.valueOf(getRevision());
|
||||
}
|
||||
|
||||
public boolean before(Version compareTo) {
|
||||
|
@ -103,19 +88,6 @@ public final class Version implements Comparable<Version> {
|
|||
return after(fromString(compareTo));
|
||||
}
|
||||
|
||||
public boolean onOrBeforeIncludingSuffix(Version otherVersion) {
|
||||
if (id != otherVersion.getId()) {
|
||||
return id < otherVersion.getId();
|
||||
}
|
||||
|
||||
if (suffix.equals("")) {
|
||||
return otherVersion.getSuffix().equals("");
|
||||
}
|
||||
|
||||
|
||||
return otherVersion.getSuffix().equals("") || suffix.compareTo(otherVersion.getSuffix()) < 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -128,8 +100,7 @@ public final class Version implements Comparable<Version> {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
return Objects.hash(major, minor, revision, id, snapshot, suffix);
|
||||
return Objects.hash(major, minor, revision, id);
|
||||
}
|
||||
|
||||
public int getMajor() {
|
||||
|
@ -148,14 +119,6 @@ public final class Version implements Comparable<Version> {
|
|||
return id;
|
||||
}
|
||||
|
||||
public boolean isSnapshot() {
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
public String getSuffix() {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Version other) {
|
||||
return Integer.compare(getId(), other.getId());
|
||||
|
|
|
@ -100,7 +100,7 @@ public class VersionCollection {
|
|||
}
|
||||
|
||||
public VersionCollection(List<String> versionLines) {
|
||||
this(versionLines, VersionProperties.getElasticsearch());
|
||||
this(versionLines, Version.fromString(VersionProperties.getElasticsearch()));
|
||||
}
|
||||
|
||||
protected VersionCollection(List<String> versionLines, Version currentVersionProperty) {
|
||||
|
@ -110,12 +110,10 @@ public class VersionCollection {
|
|||
.map(match -> new Version(
|
||||
Integer.parseInt(match.group(1)),
|
||||
Integer.parseInt(match.group(2)),
|
||||
Integer.parseInt(match.group(3)),
|
||||
(match.group(4) == null ? "" : match.group(4)).replace('_', '-'),
|
||||
false
|
||||
Integer.parseInt(match.group(3))
|
||||
))
|
||||
.sorted()
|
||||
.filter(version -> version.getSuffix().isEmpty() || version.equals(currentVersionProperty))
|
||||
.distinct()
|
||||
.collect(Collectors.groupingBy(Version::getMajor, Collectors.toList()));
|
||||
|
||||
if (groupByMajor.isEmpty()) {
|
||||
|
@ -131,22 +129,11 @@ public class VersionCollection {
|
|||
assertCurrentVersionMatchesParsed(currentVersionProperty);
|
||||
|
||||
assertNoOlderThanTwoMajors();
|
||||
|
||||
markUnreleasedAsSnapshot();
|
||||
}
|
||||
|
||||
private void markUnreleasedAsSnapshot() {
|
||||
getUnreleased().forEach(uv ->
|
||||
groupByMajor.get(uv.getMajor()).set(
|
||||
groupByMajor.get(uv.getMajor()).indexOf(uv),
|
||||
new Version(uv.getMajor(), uv.getMinor(), uv.getRevision(),uv.getSuffix(), true)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private void assertNoOlderThanTwoMajors() {
|
||||
Set<Integer> majors = groupByMajor.keySet();
|
||||
if (majors.size() != 2 && currentVersion.getMinor() != 0 && currentVersion.getMajor() != 0) {
|
||||
if (majors.size() != 2 && currentVersion.getMinor() != 0 && currentVersion.getRevision() != 0) {
|
||||
throw new IllegalStateException(
|
||||
"Expected exactly 2 majors in parsed versions but found: " + majors
|
||||
);
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.Properties;
|
|||
* Accessor for shared dependency versions used by elasticsearch, namely the elasticsearch and lucene versions.
|
||||
*/
|
||||
public class VersionProperties {
|
||||
public static Version getElasticsearch() {
|
||||
public static String getElasticsearch() {
|
||||
return elasticsearch;
|
||||
}
|
||||
|
||||
|
@ -22,12 +22,12 @@ public class VersionProperties {
|
|||
return versions;
|
||||
}
|
||||
|
||||
private static final Version elasticsearch;
|
||||
private static final String elasticsearch;
|
||||
private static final String lucene;
|
||||
private static final Map<String, String> versions = new HashMap<String, String>();
|
||||
static {
|
||||
Properties props = getVersionProperties();
|
||||
elasticsearch = Version.fromString(props.getProperty("elasticsearch"));
|
||||
elasticsearch = props.getProperty("elasticsearch");
|
||||
lucene = props.getProperty("lucene");
|
||||
for (String property : props.stringPropertyNames()) {
|
||||
versions.put(property, props.getProperty(property));
|
||||
|
@ -38,13 +38,17 @@ public class VersionProperties {
|
|||
Properties props = new Properties();
|
||||
InputStream propsStream = VersionProperties.class.getResourceAsStream("/version.properties");
|
||||
if (propsStream == null) {
|
||||
throw new RuntimeException("/version.properties resource missing");
|
||||
throw new IllegalStateException("/version.properties resource missing");
|
||||
}
|
||||
try {
|
||||
props.load(propsStream);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new IllegalStateException("Failed to load version properties", e);
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
public static boolean isElasticsearchSnapshot() {
|
||||
return elasticsearch.endsWith("-SNAPSHOT");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ public class VersionCollectionTests extends GradleUnitTestCase {
|
|||
formatVersionToLine("6.5.0"),
|
||||
formatVersionToLine("7.0.0")
|
||||
),
|
||||
Version.fromString("7.0.0")
|
||||
Version.fromString("6.5.0")
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,11 +33,11 @@ public class VersionTests extends GradleUnitTestCase {
|
|||
public ExpectedException expectedEx = ExpectedException.none();
|
||||
|
||||
public void testVersionParsing() {
|
||||
assertVersionEquals("7.0.1", 7, 0, 1, "", false);
|
||||
assertVersionEquals("7.0.1-alpha2", 7, 0, 1, "-alpha2", false);
|
||||
assertVersionEquals("5.1.2-rc3", 5, 1, 2, "-rc3", false);
|
||||
assertVersionEquals("6.1.2-SNAPSHOT", 6, 1, 2, "", true);
|
||||
assertVersionEquals("6.1.2-beta1-SNAPSHOT", 6, 1, 2, "-beta1", true);
|
||||
assertVersionEquals("7.0.1", 7, 0, 1);
|
||||
assertVersionEquals("7.0.1-alpha2", 7, 0, 1);
|
||||
assertVersionEquals("5.1.2-rc3", 5, 1, 2);
|
||||
assertVersionEquals("6.1.2-SNAPSHOT", 6, 1, 2);
|
||||
assertVersionEquals("6.1.2-beta1-SNAPSHOT", 6, 1, 2);
|
||||
}
|
||||
|
||||
public void testCompareWithStringVersions() {
|
||||
|
@ -74,21 +74,12 @@ public class VersionTests extends GradleUnitTestCase {
|
|||
}
|
||||
|
||||
public void testToString() {
|
||||
assertEquals("7.0.1", new Version(7, 0, 1, null, false).toString());
|
||||
assertEquals("7.0.1", new Version(7, 0, 1).toString());
|
||||
}
|
||||
|
||||
public void testCompareVersions() {
|
||||
assertEquals(0, new Version(7, 0, 0, null, true).compareTo(
|
||||
new Version(7, 0, 0, null, true)
|
||||
));
|
||||
assertEquals(0, new Version(7, 0, 0, null, true).compareTo(
|
||||
new Version(7, 0, 0, "", true)
|
||||
));
|
||||
|
||||
assertEquals(
|
||||
0,
|
||||
new Version(7, 0, 0, "-alpha1", false).compareTo(
|
||||
new Version(7, 0, 0, "", true))
|
||||
assertEquals(0,
|
||||
new Version(7, 0, 0).compareTo(new Version(7, 0, 0))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -108,17 +99,11 @@ public class VersionTests extends GradleUnitTestCase {
|
|||
assertEquals(smaller + " should be smaller than " + bigger, -1, smaller.compareTo(bigger));
|
||||
}
|
||||
|
||||
private void assertVersionEquals(String stringVersion, int major, int minor, int revision, String sufix, boolean snapshot) {
|
||||
private void assertVersionEquals(String stringVersion, int major, int minor, int revision) {
|
||||
Version version = Version.fromString(stringVersion);
|
||||
assertEquals(major, version.getMajor());
|
||||
assertEquals(minor, version.getMinor());
|
||||
assertEquals(revision, version.getRevision());
|
||||
if (snapshot) {
|
||||
assertTrue("Expected version to be a snapshot but it was not", version.isSnapshot());
|
||||
} else {
|
||||
assertFalse("Expected version not to be a snapshot but it was", version.isSnapshot());
|
||||
}
|
||||
assertEquals(sufix, version.getSuffix());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
elasticsearch = 7.0.0-alpha1
|
||||
elasticsearch = 7.0.0
|
||||
lucene = 8.0.0-snapshot-7d0a7782fa
|
||||
|
||||
# optional dependencies
|
||||
|
|
|
@ -129,10 +129,10 @@ bwcVersions.forPreviousUnreleased { VersionCollection.UnreleasedVersionInfo unre
|
|||
baseDir += project == 'zip' ? '/archives' : '/packages'
|
||||
// add oss variant first
|
||||
projectDirs.add("${baseDir}/oss-${project}")
|
||||
artifactFiles.add(file("${checkoutDir}/${baseDir}/oss-${project}/build/distributions/elasticsearch-oss-${bwcVersion}.${project}"))
|
||||
artifactFiles.add(file("${checkoutDir}/${baseDir}/oss-${project}/build/distributions/elasticsearch-oss-${bwcVersion}-SNAPSHOT.${project}"))
|
||||
}
|
||||
projectDirs.add("${baseDir}/${project}")
|
||||
artifactFiles.add(file("${checkoutDir}/${baseDir}/${project}/build/distributions/elasticsearch-${bwcVersion}.${project}"))
|
||||
artifactFiles.add(file("${checkoutDir}/${baseDir}/${project}/build/distributions/elasticsearch-${bwcVersion}-SNAPSHOT.${project}"))
|
||||
}
|
||||
|
||||
task buildBwcVersion(type: Exec) {
|
||||
|
|
|
@ -71,4 +71,5 @@ precommit.dependsOn namingConventionsMain
|
|||
test.configure {
|
||||
systemProperty 'tests.gradle_index_compat_versions', bwcVersions.indexCompatible.join(',')
|
||||
systemProperty 'tests.gradle_wire_compat_versions', bwcVersions.wireCompatible.join(',')
|
||||
systemProperty 'tests.gradle_unreleased_versions', bwcVersions.unreleased.join(',')
|
||||
}
|
||||
|
|
|
@ -24,8 +24,10 @@ import org.elasticsearch.common.collect.Tuple;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.stream.Collectors.toCollection;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
@ -389,13 +391,19 @@ public class VersionUtilsTests extends ESTestCase {
|
|||
private final List<String> unreleased = new ArrayList<>();
|
||||
|
||||
private VersionsFromProperty(String property) {
|
||||
Set<String> allUnreleased = new HashSet<>(Arrays.asList(
|
||||
System.getProperty("tests.gradle_unreleased_versions", "").split(",")
|
||||
));
|
||||
if (allUnreleased.isEmpty()) {
|
||||
fail("[tests.gradle_unreleased_versions] not set or empty. Gradle should set this before running.");
|
||||
}
|
||||
String versions = System.getProperty(property);
|
||||
assertNotNull("Couldn't find [" + property + "]. Gradle should set these before running the tests.", versions);
|
||||
assertNotNull("Couldn't find [" + property + "]. Gradle should set this before running the tests.", versions);
|
||||
logger.info("Looked up versions [{}={}]", property, versions);
|
||||
|
||||
for (String version : versions.split(",")) {
|
||||
if (version.endsWith("-SNAPSHOT")) {
|
||||
unreleased.add(version.replace("-SNAPSHOT", ""));
|
||||
if (allUnreleased.contains(version)) {
|
||||
unreleased.add(version);
|
||||
} else {
|
||||
released.add(version);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue