Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ class ClusterFormationTasks {
}
if (unreleasedInfo != null) {
dependency = project.dependencies.project(
path: ":distribution:bwc:${unreleasedInfo.gradleProjectName}", configuration: snapshotProject)
path: unreleasedInfo.gradleProjectPath, configuration: snapshotProject
)
} else if (internalBuild && elasticsearchVersion.equals(VersionProperties.elasticsearch)) {
dependency = project.dependencies.project(path: ":distribution:archives:${snapshotProject}")
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ class VagrantTestPlugin implements Plugin<Project> {
// handle snapshots pointing to bwc build
UPGRADE_FROM_ARCHIVES.each {
dependencies.add(project.dependencies.project(
path: ":distribution:bwc:${unreleasedInfo.gradleProjectName}", configuration: it))
path: "${unreleasedInfo.gradleProjectPath}", configuration: it))
if (upgradeFromVersion.onOrAfter('6.3.0')) {
dependencies.add(project.dependencies.project(
path: ":distribution:bwc:${unreleasedInfo.gradleProjectName}", configuration: "oss-${it}"))
path: "${unreleasedInfo.gradleProjectPath}", configuration: "oss-${it}"))
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
* <ul>
* <li>the unreleased <b>major</b>, M+1.0.0 on the `master` branch</li>
* <li>the unreleased <b>minor</b>, M.N.0 on the `M.x` (x is literal) branch</li>
* <li>the unreleased <b>bugfix</b>, M.N.c (c &gt; 0) on the `M.b` branch</li>
* <li>the unreleased <b>bugfix</b>, M.N.c (c &gt; 0) on the `M.N` branch</li>
* <li>the unreleased <b>maintenance</b>, M-1.d.e ( d &gt; 0, e &gt; 0) on the `(M-1).d` branch</li>
* </ul>
* In addition to these, there will be a fifth one when a minor reaches feature freeze, we call this the <i>staged</i>
Expand All @@ -74,7 +74,7 @@
* We can reliably figure out which the unreleased versions are due to the convention of always adding the next unreleased
* version number to server in all branches when a version is released.
* E.x when M.N.c is released M.N.c+1 is added to the Version class mentioned above in all the following branches:
* `M.b`, `M.x` and `master` so we can reliably assume that the leafs of the version tree are unreleased.
* `M.N`, `M.x` and `master` so we can reliably assume that the leafs of the version tree are unreleased.
* This convention is enforced by checking the versions we consider to be unreleased against an
* authoritative source (maven central).
* We are then able to map the unreleased version to branches in git and Gradle projects that are capable of checking
Expand All @@ -93,12 +93,12 @@ public class VersionCollection {
public class UnreleasedVersionInfo {
public final Version version;
public final String branch;
public final String gradleProjectName;
public final String gradleProjectPath;

UnreleasedVersionInfo(Version version, String branch, String gradleProjectName) {
UnreleasedVersionInfo(Version version, String branch, String gradleProjectPath) {
this.version = version;
this.branch = branch;
this.gradleProjectName = gradleProjectName;
this.gradleProjectPath = gradleProjectPath;
}
}

Expand Down Expand Up @@ -135,11 +135,8 @@ protected VersionCollection(List<String> versionLines, Version currentVersionPro

Map<Version, UnreleasedVersionInfo> unreleased = new HashMap<>();
for (Version unreleasedVersion : getUnreleased()) {
if (unreleasedVersion.equals(currentVersion)) {
continue;
}
unreleased.put(unreleasedVersion,
new UnreleasedVersionInfo(unreleasedVersion, getBranchFor(unreleasedVersion), getGradleProjectNameFor(unreleasedVersion)));
new UnreleasedVersionInfo(unreleasedVersion, getBranchFor(unreleasedVersion), getGradleProjectPathFor(unreleasedVersion)));
}
this.unreleased = Collections.unmodifiableMap(unreleased);
}
Expand Down Expand Up @@ -176,17 +173,19 @@ public void forPreviousUnreleased(Consumer<UnreleasedVersionInfo> consumer) {
.map(version -> new UnreleasedVersionInfo(
version,
getBranchFor(version),
getGradleProjectNameFor(version)
getGradleProjectPathFor(version)
)
)
.collect(Collectors.toList());

collect.forEach(uvi -> consumer.accept(uvi));
}

private String getGradleProjectNameFor(Version version) {
private String getGradleProjectPathFor(Version version) {
// We have Gradle projects set up to check out and build unreleased versions based on the our branching
// conventions described in this classes javadoc
if (version.equals(currentVersion)) {
throw new IllegalArgumentException("The Gradle project to build " + version + " is the current build.");
return ":distribution";
}

Map<Integer, List<Version>> releasedMajorGroupedByMinor = getReleasedMajorGroupedByMinor();
Expand All @@ -197,31 +196,37 @@ private String getGradleProjectNameFor(Version version) {
.collect(Collectors.toList());
if (unreleasedStagedOrMinor.size() > 2) {
if (unreleasedStagedOrMinor.get(unreleasedStagedOrMinor.size() - 2).equals(version)) {
return "minor";
return ":distribution:bwc:minor";
} else{
return "staged";
return ":distribution:bwc:staged";
}
} else {
return "minor";
return ":distribution:bwc:minor";
}
} else {
if (releasedMajorGroupedByMinor
.getOrDefault(version.getMinor(), emptyList())
.contains(version)) {
return "bugfix";
return ":distribution:bwc:bugfix";
} else {
return "maintenance";
return ":distribution:bwc:maintenance";
}
}
}

private String getBranchFor(Version version) {
switch (getGradleProjectNameFor(version)) {
case "minor":
// based on the rules described in this classes javadoc, figure out the branch on which an unreleased version
// lives.
// We do this based on the Gradle project path because there's a direct correlation, so we dont have to duplicate
// the logic from there
switch (getGradleProjectPathFor(version)) {
case ":distribution":
return "master";
case ":distribution:bwc:minor":
return version.getMajor() + ".x";
case "staged":
case "maintenance":
case "bugfix":
case ":distribution:bwc:staged":
case ":distribution:bwc:maintenance":
case ":distribution:bwc:bugfix":
return version.getMajor() + "." + version.getMinor();
default:
throw new IllegalStateException("Unexpected Gradle project name");
Expand Down Expand Up @@ -320,7 +325,6 @@ public List<Version> getIndexCompatible() {
groupByMajor.get(currentVersion.getMajor() - 1).stream(),
groupByMajor.get(currentVersion.getMajor()).stream()
)
.filter(version -> version.equals(currentVersion) == false)
.collect(Collectors.toList())
);
}
Expand All @@ -337,7 +341,6 @@ public List<Version> getWireCompatible() {
wireCompat.add(prevMajors.get(i));
}
wireCompat.addAll(groupByMajor.get(currentVersion.getMajor()));
wireCompat.remove(currentVersion);
wireCompat.sort(Version::compareTo);

return unmodifiableList(wireCompat);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,77 +110,77 @@ public void testExceptionOnTooManyMajors() {

public void testWireCompatible() {
assertVersionsEquals(
singletonList("6.5.0-SNAPSHOT"),
asList("6.5.0", "7.0.0"),
getVersionCollection("7.0.0-alpha1").getWireCompatible()
);
assertVersionsEquals(
asList(
"5.6.0", "5.6.1", "5.6.2", "5.6.3", "5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10",
"5.6.11", "5.6.12", "5.6.13-SNAPSHOT",
"5.6.11", "5.6.12", "5.6.13",
"6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4",
"6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4",
"6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2-SNAPSHOT"
"6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2", "6.5.0"
),
getVersionCollection("6.5.0").getWireCompatible()
);

assertVersionsEquals(
asList(
"5.6.0", "5.6.1", "5.6.2", "5.6.3", "5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10",
"5.6.11", "5.6.12", "5.6.13-SNAPSHOT", "6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4",
"6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4", "6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1"
"5.6.11", "5.6.12", "5.6.13", "6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4",
"6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4", "6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2"
),
getVersionCollection("6.4.2").getWireCompatible()
);

assertVersionsEquals(
asList(
"5.6.0", "5.6.1", "5.6.2", "5.6.3", "5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10",
"5.6.11", "5.6.12", "5.6.13-SNAPSHOT",
"5.6.11", "5.6.12", "5.6.13",
"6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4",
"6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4",
"6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2-SNAPSHOT", "6.5.0-SNAPSHOT"
"6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2", "6.5.0", "6.6.0"
),
getVersionCollection("6.6.0").getWireCompatible()
);

assertVersionsEquals(
singletonList("7.3.0"),
asList("7.3.0", "8.0.0"),
getVersionCollection("8.0.0").getWireCompatible()
);
assertVersionsEquals(
asList("6.7.0", "7.0.0"),
asList("6.7.0", "7.0.0", "7.1.0"),
getVersionCollection("7.1.0").getWireCompatible()
);

}

public void testWireCompatibleUnreleased() {
assertVersionsEquals(
singletonList("6.5.0-SNAPSHOT"),
asList("6.5.0", "7.0.0"),
getVersionCollection("7.0.0-alpha1").getUnreleasedWireCompatible()
);
assertVersionsEquals(
asList("5.6.13-SNAPSHOT", "6.4.2-SNAPSHOT"),
asList("5.6.13", "6.4.2", "6.5.0"),
getVersionCollection("6.5.0").getUnreleasedWireCompatible()
);

assertVersionsEquals(
singletonList("5.6.13-SNAPSHOT"),
asList("5.6.13", "6.4.2"),
getVersionCollection("6.4.2").getUnreleasedWireCompatible()
);

assertVersionsEquals(
asList("5.6.13-SNAPSHOT", "6.4.2-SNAPSHOT", "6.5.0-SNAPSHOT"),
asList("5.6.13", "6.4.2", "6.5.0", "6.6.0"),
getVersionCollection("6.6.0").getUnreleasedWireCompatible()
);

assertVersionsEquals(
singletonList("7.3.0"),
asList("7.3.0", "8.0.0"),
getVersionCollection("8.0.0").getUnreleasedWireCompatible()
);
assertVersionsEquals(
asList("6.7.0", "7.0.0"),
asList("6.7.0", "7.0.0", "7.1.0"),
getVersionCollection("7.1.0").getWireCompatible()
);
}
Expand All @@ -190,7 +190,7 @@ public void testIndexCompatible() {
asList(
"6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4",
"6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4", "6.3.0", "6.3.1",
"6.3.2", "6.4.0", "6.4.1", "6.4.2-SNAPSHOT", "6.5.0-SNAPSHOT"
"6.3.2", "6.4.0", "6.4.1", "6.4.2", "6.5.0", "7.0.0"
),
getVersionCollection("7.0.0-alpha1").getIndexCompatible()
);
Expand All @@ -199,9 +199,9 @@ public void testIndexCompatible() {
asList(
"5.0.0", "5.0.1", "5.0.2", "5.1.1", "5.1.2", "5.2.0", "5.2.1", "5.2.2", "5.3.0", "5.3.1", "5.3.2", "5.3.3",
"5.4.0", "5.4.1", "5.4.2", "5.4.3", "5.5.0", "5.5.1", "5.5.2", "5.5.3", "5.6.0", "5.6.1", "5.6.2", "5.6.3",
"5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", "5.6.11", "5.6.12", "5.6.13-SNAPSHOT",
"5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", "5.6.11", "5.6.12", "5.6.13",
"6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4", "6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4",
"6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2-SNAPSHOT"
"6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2", "6.5.0"
),
getVersionCollection("6.5.0").getIndexCompatible()
);
Expand All @@ -210,9 +210,9 @@ public void testIndexCompatible() {
asList(
"5.0.0", "5.0.1", "5.0.2", "5.1.1", "5.1.2", "5.2.0", "5.2.1", "5.2.2", "5.3.0", "5.3.1", "5.3.2", "5.3.3",
"5.4.0", "5.4.1", "5.4.2", "5.4.3", "5.5.0", "5.5.1", "5.5.2", "5.5.3", "5.6.0", "5.6.1", "5.6.2", "5.6.3",
"5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", "5.6.11", "5.6.12", "5.6.13-SNAPSHOT",
"5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", "5.6.11", "5.6.12", "5.6.13",
"6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4", "6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4",
"6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1"
"6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2"
),
getVersionCollection("6.4.2").getIndexCompatible()
);
Expand All @@ -221,42 +221,42 @@ public void testIndexCompatible() {
asList(
"5.0.0", "5.0.1", "5.0.2", "5.1.1", "5.1.2", "5.2.0", "5.2.1", "5.2.2", "5.3.0", "5.3.1", "5.3.2", "5.3.3",
"5.4.0", "5.4.1", "5.4.2", "5.4.3", "5.5.0", "5.5.1", "5.5.2", "5.5.3", "5.6.0", "5.6.1", "5.6.2", "5.6.3",
"5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", "5.6.11", "5.6.12", "5.6.13-SNAPSHOT",
"5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", "5.6.11", "5.6.12", "5.6.13",
"6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4", "6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4",
"6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2-SNAPSHOT", "6.5.0-SNAPSHOT"
"6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2", "6.5.0", "6.6.0"
),
getVersionCollection("6.6.0").getIndexCompatible()
);

assertVersionsEquals(
asList("7.0.0", "7.0.1", "7.1.0", "7.1.1", "7.2.0", "7.3.0"),
asList("7.0.0", "7.0.1", "7.1.0", "7.1.1", "7.2.0", "7.3.0", "8.0.0"),
getVersionCollection("8.0.0").getIndexCompatible()
);
}

public void testIndexCompatibleUnreleased() {
assertVersionsEquals(
asList("6.4.2-SNAPSHOT", "6.5.0-SNAPSHOT"),
asList("6.4.2", "6.5.0", "7.0.0"),
getVersionCollection("7.0.0-alpha1").getUnreleasedIndexCompatible()
);

assertVersionsEquals(
asList("5.6.13-SNAPSHOT", "6.4.2-SNAPSHOT"),
asList("5.6.13", "6.4.2", "6.5.0"),
getVersionCollection("6.5.0").getUnreleasedIndexCompatible()
);

assertVersionsEquals(
singletonList("5.6.13-SNAPSHOT"),
asList("5.6.13", "6.4.2"),
getVersionCollection("6.4.2").getUnreleasedIndexCompatible()
);

assertVersionsEquals(
asList("5.6.13-SNAPSHOT", "6.4.2-SNAPSHOT", "6.5.0-SNAPSHOT"),
asList("5.6.13", "6.4.2", "6.5.0", "6.6.0"),
getVersionCollection("6.6.0").getUnreleasedIndexCompatible()
);

assertVersionsEquals(
asList("7.1.1", "7.2.0", "7.3.0"),
asList("7.1.1", "7.2.0", "7.3.0", "8.0.0"),
getVersionCollection("8.0.0").getUnreleasedIndexCompatible()
);
}
Expand Down Expand Up @@ -307,29 +307,29 @@ public void testGetBranch() {
);
}

public void testGetGradleProjectName() {
assertUnreleasedGradleProjectNames(
asList("bugfix", "minor"),
public void testGetGradleProjectPath() {
assertUnreleasedGradleProjectPaths(
asList(":distribution:bwc:bugfix", ":distribution:bwc:minor"),
getVersionCollection("7.0.0-alpha1")
);
assertUnreleasedGradleProjectNames(
asList("maintenance", "bugfix"),
assertUnreleasedGradleProjectPaths(
asList(":distribution:bwc:maintenance", ":distribution:bwc:bugfix"),
getVersionCollection("6.5.0")
);
assertUnreleasedGradleProjectNames(
singletonList("maintenance"),
assertUnreleasedGradleProjectPaths(
singletonList(":distribution:bwc:maintenance"),
getVersionCollection("6.4.2")
);
assertUnreleasedGradleProjectNames(
asList("maintenance", "bugfix", "minor"),
assertUnreleasedGradleProjectPaths(
asList(":distribution:bwc:maintenance", ":distribution:bwc:bugfix", ":distribution:bwc:minor"),
getVersionCollection("6.6.0")
);
assertUnreleasedGradleProjectNames(
asList("bugfix", "staged", "minor"),
assertUnreleasedGradleProjectPaths(
asList(":distribution:bwc:bugfix", ":distribution:bwc:staged", ":distribution:bwc:minor"),
getVersionCollection("8.0.0")
);
assertUnreleasedGradleProjectNames(
asList("staged", "minor"),
assertUnreleasedGradleProjectPaths(
asList(":distribution:bwc:staged", ":distribution:bwc:minor"),
getVersionCollection("7.1.0")
);
}
Expand Down Expand Up @@ -382,10 +382,10 @@ public void testCompareToAuthoritativeNotReallyRelesed() {
vc.compareToAuthoritative(authoritativeReleasedVersions);
}

private void assertUnreleasedGradleProjectNames(List<String> expectedNAmes, VersionCollection versionCollection) {
private void assertUnreleasedGradleProjectPaths(List<String> expectedNAmes, VersionCollection versionCollection) {
List<String> actualNames = new ArrayList<>();
versionCollection.forPreviousUnreleased(unreleasedVersion ->
actualNames.add(unreleasedVersion.gradleProjectName)
actualNames.add(unreleasedVersion.gradleProjectPath)
);
assertEquals(expectedNAmes, actualNames);
}
Expand Down
Loading