Allow building on FreeBSD (#1091)
* Allow building on FreeBSD With this set of change, we are able to successfuly run: ``` ./gradlew publishToMavenLocal -Dbuild.snapshot=false ``` This step is used in the OpenSearch repository context when building plugins in the current state of the CI. While here, reorder OS conditions alphabetically. Before building, the openjdk14 package was installed and the environment was adjusted to use it: ``` sudo pkg install openjdk14 export JAVA_HOME=/usr/local/openjdk14/ export PATH=$JAVA_HOME/bin:$PATH ``` Signed-off-by: Romain Tartière <romain@blogreen.org> * Unbreak CI with FreeBSD support Signed-off-by: dblock <dblock@dblock.org> Co-authored-by: dblock <dblock@dblock.org>
This commit is contained in:
parent
3779576c51
commit
ea0fe7bfae
|
@ -183,10 +183,10 @@ if (project != rootProject) {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
reaper project('reaper')
|
reaper project('reaper')
|
||||||
distribution project(':distribution:archives:windows-zip')
|
|
||||||
distribution project(':distribution:archives:darwin-tar')
|
distribution project(':distribution:archives:darwin-tar')
|
||||||
distribution project(':distribution:archives:linux-tar')
|
|
||||||
distribution project(':distribution:archives:linux-arm64-tar')
|
distribution project(':distribution:archives:linux-arm64-tar')
|
||||||
|
distribution project(':distribution:archives:linux-tar')
|
||||||
|
distribution project(':distribution:archives:windows-zip')
|
||||||
|
|
||||||
integTestRuntimeOnly(project(":libs:opensearch-core"))
|
integTestRuntimeOnly(project(":libs:opensearch-core"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,9 @@ public class Jdk implements Buildable, Iterable<File> {
|
||||||
|
|
||||||
private static final List<String> ALLOWED_ARCHITECTURES = Collections.unmodifiableList(Arrays.asList("aarch64", "x64"));
|
private static final List<String> ALLOWED_ARCHITECTURES = Collections.unmodifiableList(Arrays.asList("aarch64", "x64"));
|
||||||
private static final List<String> ALLOWED_VENDORS = Collections.unmodifiableList(Arrays.asList("adoptium", "adoptopenjdk", "openjdk"));
|
private static final List<String> ALLOWED_VENDORS = Collections.unmodifiableList(Arrays.asList("adoptium", "adoptopenjdk", "openjdk"));
|
||||||
private static final List<String> ALLOWED_PLATFORMS = Collections.unmodifiableList(Arrays.asList("darwin", "linux", "windows", "mac"));
|
private static final List<String> ALLOWED_PLATFORMS = Collections.unmodifiableList(
|
||||||
|
Arrays.asList("darwin", "freebsd", "linux", "mac", "windows")
|
||||||
|
);
|
||||||
private static final Pattern VERSION_PATTERN = Pattern.compile("(\\d+)(\\.\\d+\\.\\d+)?\\+(\\d+(?:\\.\\d+)?)(@([a-f0-9]{32}))?");
|
private static final Pattern VERSION_PATTERN = Pattern.compile("(\\d+)(\\.\\d+\\.\\d+)?\\+(\\d+(?:\\.\\d+)?)(@([a-f0-9]{32}))?");
|
||||||
private static final Pattern LEGACY_VERSION_PATTERN = Pattern.compile("(\\d)(u\\d+)\\+(b\\d+?)(@([a-f0-9]{32}))?");
|
private static final Pattern LEGACY_VERSION_PATTERN = Pattern.compile("(\\d)(u\\d+)\\+(b\\d+?)(@([a-f0-9]{32}))?");
|
||||||
|
|
||||||
|
|
|
@ -38,14 +38,15 @@ import java.util.Map;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public enum OS {
|
public enum OS {
|
||||||
WINDOWS,
|
FREEBSD,
|
||||||
|
LINUX,
|
||||||
MAC,
|
MAC,
|
||||||
LINUX;
|
WINDOWS;
|
||||||
|
|
||||||
public static OS current() {
|
public static OS current() {
|
||||||
String os = System.getProperty("os.name", "");
|
String os = System.getProperty("os.name", "");
|
||||||
if (os.startsWith("Windows")) {
|
if (os.startsWith("FreeBSD")) {
|
||||||
return OS.WINDOWS;
|
return OS.FREEBSD;
|
||||||
}
|
}
|
||||||
if (os.startsWith("Linux") || os.startsWith("LINUX")) {
|
if (os.startsWith("Linux") || os.startsWith("LINUX")) {
|
||||||
return OS.LINUX;
|
return OS.LINUX;
|
||||||
|
@ -53,6 +54,9 @@ public enum OS {
|
||||||
if (os.startsWith("Mac")) {
|
if (os.startsWith("Mac")) {
|
||||||
return OS.MAC;
|
return OS.MAC;
|
||||||
}
|
}
|
||||||
|
if (os.startsWith("Windows")) {
|
||||||
|
return OS.WINDOWS;
|
||||||
|
}
|
||||||
throw new IllegalStateException("Can't determine OS from: " + os);
|
throw new IllegalStateException("Can't determine OS from: " + os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,13 +64,13 @@ public enum OS {
|
||||||
|
|
||||||
private final Map<OS, Supplier<T>> conditions = new HashMap<>();
|
private final Map<OS, Supplier<T>> conditions = new HashMap<>();
|
||||||
|
|
||||||
public Conditional<T> onWindows(Supplier<T> supplier) {
|
public Conditional<T> onLinux(Supplier<T> supplier) {
|
||||||
conditions.put(WINDOWS, supplier);
|
conditions.put(LINUX, supplier);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Conditional<T> onLinux(Supplier<T> supplier) {
|
public Conditional<T> onFreeBSD(Supplier<T> supplier) {
|
||||||
conditions.put(LINUX, supplier);
|
conditions.put(FREEBSD, supplier);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,8 +80,14 @@ public enum OS {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Conditional<T> onUnix(Supplier<T> supplier) {
|
public Conditional<T> onUnix(Supplier<T> supplier) {
|
||||||
conditions.put(MAC, supplier);
|
conditions.put(FREEBSD, supplier);
|
||||||
conditions.put(LINUX, supplier);
|
conditions.put(LINUX, supplier);
|
||||||
|
conditions.put(MAC, supplier);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Conditional<T> onWindows(Supplier<T> supplier) {
|
||||||
|
conditions.put(WINDOWS, supplier);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,9 +48,10 @@ import java.util.Locale;
|
||||||
public class OpenSearchDistribution implements Buildable, Iterable<File> {
|
public class OpenSearchDistribution implements Buildable, Iterable<File> {
|
||||||
|
|
||||||
public enum Platform {
|
public enum Platform {
|
||||||
|
DARWIN,
|
||||||
|
FREEBSD,
|
||||||
LINUX,
|
LINUX,
|
||||||
WINDOWS,
|
WINDOWS;
|
||||||
DARWIN;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -85,9 +86,10 @@ public class OpenSearchDistribution implements Buildable, Iterable<File> {
|
||||||
|
|
||||||
// package private to tests can use
|
// package private to tests can use
|
||||||
public static final Platform CURRENT_PLATFORM = OS.<Platform>conditional()
|
public static final Platform CURRENT_PLATFORM = OS.<Platform>conditional()
|
||||||
|
.onFreeBSD(() -> Platform.FREEBSD)
|
||||||
.onLinux(() -> Platform.LINUX)
|
.onLinux(() -> Platform.LINUX)
|
||||||
.onWindows(() -> Platform.WINDOWS)
|
|
||||||
.onMac(() -> Platform.DARWIN)
|
.onMac(() -> Platform.DARWIN)
|
||||||
|
.onWindows(() -> Platform.WINDOWS)
|
||||||
.supply();
|
.supply();
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
|
@ -59,6 +59,8 @@ public class VersionProperties {
|
||||||
case "darwin": // fall trough
|
case "darwin": // fall trough
|
||||||
case "mac":
|
case "mac":
|
||||||
return bundledJdkDarwin;
|
return bundledJdkDarwin;
|
||||||
|
case "freebsd":
|
||||||
|
return bundledJdkFreeBSD;
|
||||||
case "linux":
|
case "linux":
|
||||||
return bundledJdkLinux;
|
return bundledJdkLinux;
|
||||||
case "windows":
|
case "windows":
|
||||||
|
@ -79,6 +81,7 @@ public class VersionProperties {
|
||||||
private static final String opensearch;
|
private static final String opensearch;
|
||||||
private static final String lucene;
|
private static final String lucene;
|
||||||
private static final String bundledJdkDarwin;
|
private static final String bundledJdkDarwin;
|
||||||
|
private static final String bundledJdkFreeBSD;
|
||||||
private static final String bundledJdkLinux;
|
private static final String bundledJdkLinux;
|
||||||
private static final String bundledJdkWindows;
|
private static final String bundledJdkWindows;
|
||||||
private static final String bundledJdkVendor;
|
private static final String bundledJdkVendor;
|
||||||
|
@ -91,6 +94,7 @@ public class VersionProperties {
|
||||||
bundledJdkVendor = props.getProperty("bundled_jdk_vendor");
|
bundledJdkVendor = props.getProperty("bundled_jdk_vendor");
|
||||||
final String bundledJdk = props.getProperty("bundled_jdk");
|
final String bundledJdk = props.getProperty("bundled_jdk");
|
||||||
bundledJdkDarwin = props.getProperty("bundled_jdk_darwin", bundledJdk);
|
bundledJdkDarwin = props.getProperty("bundled_jdk_darwin", bundledJdk);
|
||||||
|
bundledJdkFreeBSD = props.getProperty("bundled_jdk_freebsd", bundledJdk);
|
||||||
bundledJdkLinux = props.getProperty("bundled_jdk_linux", bundledJdk);
|
bundledJdkLinux = props.getProperty("bundled_jdk_linux", bundledJdk);
|
||||||
bundledJdkWindows = props.getProperty("bundled_jdk_windows", bundledJdk);
|
bundledJdkWindows = props.getProperty("bundled_jdk_windows", bundledJdk);
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,7 @@ public class InternalDistributionBwcSetupPlugin implements Plugin<Project> {
|
||||||
projects.addAll(asList("deb", "rpm"));
|
projects.addAll(asList("deb", "rpm"));
|
||||||
|
|
||||||
if (bwcVersion.onOrAfter("7.0.0")) { // starting with 7.0 we bundle a jdk which means we have platform-specific archives
|
if (bwcVersion.onOrAfter("7.0.0")) { // starting with 7.0 we bundle a jdk which means we have platform-specific archives
|
||||||
projects.addAll(asList("windows-zip", "darwin-tar", "linux-tar"));
|
projects.addAll(asList("darwin-tar", "linux-tar", "windows-tar"));
|
||||||
} else { // prior to 7.0 we published only a single zip and tar archives
|
} else { // prior to 7.0 we published only a single zip and tar archives
|
||||||
projects.addAll(asList("zip", "tar"));
|
projects.addAll(asList("zip", "tar"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class JdkDownloadPluginTests extends GradleUnitTestCase {
|
||||||
"11.0.2+33",
|
"11.0.2+33",
|
||||||
"unknown",
|
"unknown",
|
||||||
"x64",
|
"x64",
|
||||||
"unknown platform [unknown] for jdk [testjdk], must be one of [darwin, linux, windows, mac]"
|
"unknown platform [unknown] for jdk [testjdk], must be one of [darwin, freebsd, linux, mac, windows]"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,20 +88,6 @@ distribution_archives {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
windowsZip {
|
|
||||||
archiveClassifier = 'windows-x64'
|
|
||||||
content {
|
|
||||||
archiveFiles(modulesFiles('windows-x64'), 'zip', 'windows', 'x64', true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
noJdkWindowsZip {
|
|
||||||
archiveClassifier = 'no-jdk-windows-x64'
|
|
||||||
content {
|
|
||||||
archiveFiles(modulesFiles('windows-x64'), 'zip', 'windows', 'x64', false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
darwinTar {
|
darwinTar {
|
||||||
archiveClassifier = 'darwin-x64'
|
archiveClassifier = 'darwin-x64'
|
||||||
content {
|
content {
|
||||||
|
@ -116,6 +102,20 @@ distribution_archives {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
freebsdTar {
|
||||||
|
archiveClassifier = 'freebsd-x64'
|
||||||
|
content {
|
||||||
|
archiveFiles(modulesFiles('freebsd-x64'), 'tar', 'freebsd', 'x64', false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
noJdkFreebsdTar {
|
||||||
|
archiveClassifier = 'no-jdk-freebsd-x64'
|
||||||
|
content {
|
||||||
|
archiveFiles(modulesFiles('freebsd-x64'), 'tar', 'freebsd', 'x64', false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
linuxArm64Tar {
|
linuxArm64Tar {
|
||||||
archiveClassifier = 'linux-arm64'
|
archiveClassifier = 'linux-arm64'
|
||||||
content {
|
content {
|
||||||
|
@ -136,6 +136,20 @@ distribution_archives {
|
||||||
archiveFiles(modulesFiles('linux-x64'), 'tar', 'linux', 'x64', false)
|
archiveFiles(modulesFiles('linux-x64'), 'tar', 'linux', 'x64', false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
windowsZip {
|
||||||
|
archiveClassifier = 'windows-x64'
|
||||||
|
content {
|
||||||
|
archiveFiles(modulesFiles('windows-x64'), 'zip', 'windows', 'x64', true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
noJdkWindowsZip {
|
||||||
|
archiveClassifier = 'no-jdk-windows-x64'
|
||||||
|
content {
|
||||||
|
archiveFiles(modulesFiles('windows-x64'), 'zip', 'windows', 'x64', false)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
|
|
|
@ -279,7 +279,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
|
||||||
|
|
||||||
// Setup all required JDKs
|
// Setup all required JDKs
|
||||||
project.jdks {
|
project.jdks {
|
||||||
['darwin', 'windows', 'linux'].each { platform ->
|
['darwin', 'linux', 'windows'].each { platform ->
|
||||||
(platform == 'linux' ? ['x64', 'aarch64'] : ['x64']).each { architecture ->
|
(platform == 'linux' ? ['x64', 'aarch64'] : ['x64']).each { architecture ->
|
||||||
"bundled_${platform}_${architecture}" {
|
"bundled_${platform}_${architecture}" {
|
||||||
it.platform = platform
|
it.platform = platform
|
||||||
|
@ -353,7 +353,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
def buildModules = buildModulesTaskProvider
|
def buildModules = buildModulesTaskProvider
|
||||||
List excludePlatforms = ['linux-x64', 'linux-arm64', 'windows-x64', 'darwin-x64']
|
List excludePlatforms = ['darwin-x64', 'freebsd-x64', 'linux-x64', 'linux-arm64', 'windows-x64']
|
||||||
if (platform != null) {
|
if (platform != null) {
|
||||||
excludePlatforms.remove(excludePlatforms.indexOf(platform))
|
excludePlatforms.remove(excludePlatforms.indexOf(platform))
|
||||||
} else {
|
} else {
|
||||||
|
@ -621,13 +621,13 @@ subprojects {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
['archives:windows-zip',
|
['archives:darwin-tar',
|
||||||
'archives:darwin-tar',
|
'archives:integ-test-zip',
|
||||||
'archives:linux-arm64-tar',
|
'archives:linux-arm64-tar',
|
||||||
'archives:linux-tar',
|
'archives:linux-tar',
|
||||||
'archives:integ-test-zip',
|
'archives:windows-zip',
|
||||||
'packages:rpm', 'packages:deb',
|
'packages:arm64-rpm', 'packages:arm64-deb',
|
||||||
'packages:arm64-rpm', 'packages:arm64-deb'
|
'packages:rpm', 'packages:deb'
|
||||||
].forEach { subName ->
|
].forEach { subName ->
|
||||||
Project subproject = project("${project.path}:${subName}")
|
Project subproject = project("${project.path}:${subName}")
|
||||||
Configuration configuration = configurations.create(subproject.name)
|
Configuration configuration = configurations.create(subproject.name)
|
||||||
|
|
|
@ -36,6 +36,8 @@ List projects = [
|
||||||
'distribution:archives:no-jdk-windows-zip',
|
'distribution:archives:no-jdk-windows-zip',
|
||||||
'distribution:archives:darwin-tar',
|
'distribution:archives:darwin-tar',
|
||||||
'distribution:archives:no-jdk-darwin-tar',
|
'distribution:archives:no-jdk-darwin-tar',
|
||||||
|
'distribution:archives:freebsd-tar',
|
||||||
|
'distribution:archives:no-jdk-freebsd-tar',
|
||||||
'distribution:archives:linux-arm64-tar',
|
'distribution:archives:linux-arm64-tar',
|
||||||
'distribution:archives:linux-tar',
|
'distribution:archives:linux-tar',
|
||||||
'distribution:archives:no-jdk-linux-tar',
|
'distribution:archives:no-jdk-linux-tar',
|
||||||
|
|
Loading…
Reference in New Issue