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 {
|
||||
reaper project('reaper')
|
||||
distribution project(':distribution:archives:windows-zip')
|
||||
distribution project(':distribution:archives:darwin-tar')
|
||||
distribution project(':distribution:archives:linux-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"))
|
||||
}
|
||||
|
|
|
@ -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_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 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;
|
||||
|
||||
public enum OS {
|
||||
WINDOWS,
|
||||
FREEBSD,
|
||||
LINUX,
|
||||
MAC,
|
||||
LINUX;
|
||||
WINDOWS;
|
||||
|
||||
public static OS current() {
|
||||
String os = System.getProperty("os.name", "");
|
||||
if (os.startsWith("Windows")) {
|
||||
return OS.WINDOWS;
|
||||
if (os.startsWith("FreeBSD")) {
|
||||
return OS.FREEBSD;
|
||||
}
|
||||
if (os.startsWith("Linux") || os.startsWith("LINUX")) {
|
||||
return OS.LINUX;
|
||||
|
@ -53,6 +54,9 @@ public enum OS {
|
|||
if (os.startsWith("Mac")) {
|
||||
return OS.MAC;
|
||||
}
|
||||
if (os.startsWith("Windows")) {
|
||||
return OS.WINDOWS;
|
||||
}
|
||||
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<>();
|
||||
|
||||
public Conditional<T> onWindows(Supplier<T> supplier) {
|
||||
conditions.put(WINDOWS, supplier);
|
||||
public Conditional<T> onLinux(Supplier<T> supplier) {
|
||||
conditions.put(LINUX, supplier);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Conditional<T> onLinux(Supplier<T> supplier) {
|
||||
conditions.put(LINUX, supplier);
|
||||
public Conditional<T> onFreeBSD(Supplier<T> supplier) {
|
||||
conditions.put(FREEBSD, supplier);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -76,8 +80,14 @@ public enum OS {
|
|||
}
|
||||
|
||||
public Conditional<T> onUnix(Supplier<T> supplier) {
|
||||
conditions.put(MAC, supplier);
|
||||
conditions.put(FREEBSD, supplier);
|
||||
conditions.put(LINUX, supplier);
|
||||
conditions.put(MAC, supplier);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Conditional<T> onWindows(Supplier<T> supplier) {
|
||||
conditions.put(WINDOWS, supplier);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,9 +48,10 @@ import java.util.Locale;
|
|||
public class OpenSearchDistribution implements Buildable, Iterable<File> {
|
||||
|
||||
public enum Platform {
|
||||
DARWIN,
|
||||
FREEBSD,
|
||||
LINUX,
|
||||
WINDOWS,
|
||||
DARWIN;
|
||||
WINDOWS;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -85,9 +86,10 @@ public class OpenSearchDistribution implements Buildable, Iterable<File> {
|
|||
|
||||
// package private to tests can use
|
||||
public static final Platform CURRENT_PLATFORM = OS.<Platform>conditional()
|
||||
.onFreeBSD(() -> Platform.FREEBSD)
|
||||
.onLinux(() -> Platform.LINUX)
|
||||
.onWindows(() -> Platform.WINDOWS)
|
||||
.onMac(() -> Platform.DARWIN)
|
||||
.onWindows(() -> Platform.WINDOWS)
|
||||
.supply();
|
||||
|
||||
private final String name;
|
||||
|
|
|
@ -59,6 +59,8 @@ public class VersionProperties {
|
|||
case "darwin": // fall trough
|
||||
case "mac":
|
||||
return bundledJdkDarwin;
|
||||
case "freebsd":
|
||||
return bundledJdkFreeBSD;
|
||||
case "linux":
|
||||
return bundledJdkLinux;
|
||||
case "windows":
|
||||
|
@ -79,6 +81,7 @@ public class VersionProperties {
|
|||
private static final String opensearch;
|
||||
private static final String lucene;
|
||||
private static final String bundledJdkDarwin;
|
||||
private static final String bundledJdkFreeBSD;
|
||||
private static final String bundledJdkLinux;
|
||||
private static final String bundledJdkWindows;
|
||||
private static final String bundledJdkVendor;
|
||||
|
@ -91,6 +94,7 @@ public class VersionProperties {
|
|||
bundledJdkVendor = props.getProperty("bundled_jdk_vendor");
|
||||
final String bundledJdk = props.getProperty("bundled_jdk");
|
||||
bundledJdkDarwin = props.getProperty("bundled_jdk_darwin", bundledJdk);
|
||||
bundledJdkFreeBSD = props.getProperty("bundled_jdk_freebsd", bundledJdk);
|
||||
bundledJdkLinux = props.getProperty("bundled_jdk_linux", bundledJdk);
|
||||
bundledJdkWindows = props.getProperty("bundled_jdk_windows", bundledJdk);
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ public class InternalDistributionBwcSetupPlugin implements Plugin<Project> {
|
|||
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
|
||||
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
|
||||
projects.addAll(asList("zip", "tar"));
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ public class JdkDownloadPluginTests extends GradleUnitTestCase {
|
|||
"11.0.2+33",
|
||||
"unknown",
|
||||
"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 {
|
||||
archiveClassifier = 'darwin-x64'
|
||||
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 {
|
||||
archiveClassifier = 'linux-arm64'
|
||||
content {
|
||||
|
@ -136,6 +136,20 @@ distribution_archives {
|
|||
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 {
|
||||
|
|
|
@ -279,7 +279,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
|
|||
|
||||
// Setup all required JDKs
|
||||
project.jdks {
|
||||
['darwin', 'windows', 'linux'].each { platform ->
|
||||
['darwin', 'linux', 'windows'].each { platform ->
|
||||
(platform == 'linux' ? ['x64', 'aarch64'] : ['x64']).each { architecture ->
|
||||
"bundled_${platform}_${architecture}" {
|
||||
it.platform = platform
|
||||
|
@ -353,7 +353,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
|
|||
}
|
||||
}
|
||||
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) {
|
||||
excludePlatforms.remove(excludePlatforms.indexOf(platform))
|
||||
} 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-tar',
|
||||
'archives:integ-test-zip',
|
||||
'packages:rpm', 'packages:deb',
|
||||
'packages:arm64-rpm', 'packages:arm64-deb'
|
||||
'archives:windows-zip',
|
||||
'packages:arm64-rpm', 'packages:arm64-deb',
|
||||
'packages:rpm', 'packages:deb'
|
||||
].forEach { subName ->
|
||||
Project subproject = project("${project.path}:${subName}")
|
||||
Configuration configuration = configurations.create(subproject.name)
|
||||
|
|
|
@ -36,6 +36,8 @@ List projects = [
|
|||
'distribution:archives:no-jdk-windows-zip',
|
||||
'distribution:archives: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-tar',
|
||||
'distribution:archives:no-jdk-linux-tar',
|
||||
|
|
Loading…
Reference in New Issue