diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index e01be9796da1d..d970c027b008d 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -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")) } diff --git a/buildSrc/src/main/java/org/opensearch/gradle/Jdk.java b/buildSrc/src/main/java/org/opensearch/gradle/Jdk.java index f305aee7fcbaa..792debe3f350a 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/Jdk.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/Jdk.java @@ -50,7 +50,9 @@ public class Jdk implements Buildable, Iterable { private static final List ALLOWED_ARCHITECTURES = Collections.unmodifiableList(Arrays.asList("aarch64", "x64")); private static final List ALLOWED_VENDORS = Collections.unmodifiableList(Arrays.asList("adoptium", "adoptopenjdk", "openjdk")); - private static final List ALLOWED_PLATFORMS = Collections.unmodifiableList(Arrays.asList("darwin", "linux", "windows", "mac")); + private static final List 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}))?"); diff --git a/buildSrc/src/main/java/org/opensearch/gradle/OS.java b/buildSrc/src/main/java/org/opensearch/gradle/OS.java index fd1f91640cf55..b5243030cbc71 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/OS.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/OS.java @@ -38,14 +38,15 @@ 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 static OS current() { 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 static class Conditional { private final Map> conditions = new HashMap<>(); - public Conditional onWindows(Supplier supplier) { - conditions.put(WINDOWS, supplier); + public Conditional onLinux(Supplier supplier) { + conditions.put(LINUX, supplier); return this; } - public Conditional onLinux(Supplier supplier) { - conditions.put(LINUX, supplier); + public Conditional onFreeBSD(Supplier supplier) { + conditions.put(FREEBSD, supplier); return this; } @@ -76,8 +80,14 @@ public Conditional onMac(Supplier supplier) { } public Conditional onUnix(Supplier supplier) { - conditions.put(MAC, supplier); + conditions.put(FREEBSD, supplier); conditions.put(LINUX, supplier); + conditions.put(MAC, supplier); + return this; + } + + public Conditional onWindows(Supplier supplier) { + conditions.put(WINDOWS, supplier); return this; } diff --git a/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchDistribution.java b/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchDistribution.java index 14202e0a6c203..968bd13bd4011 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchDistribution.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchDistribution.java @@ -48,9 +48,10 @@ public class OpenSearchDistribution implements Buildable, Iterable { public enum Platform { + DARWIN, + FREEBSD, LINUX, - WINDOWS, - DARWIN; + WINDOWS; @Override public String toString() { @@ -85,9 +86,10 @@ public boolean shouldExtract() { // package private to tests can use public static final Platform CURRENT_PLATFORM = OS.conditional() + .onFreeBSD(() -> Platform.FREEBSD) .onLinux(() -> Platform.LINUX) - .onWindows(() -> Platform.WINDOWS) .onMac(() -> Platform.DARWIN) + .onWindows(() -> Platform.WINDOWS) .supply(); private final String name; diff --git a/buildSrc/src/main/java/org/opensearch/gradle/VersionProperties.java b/buildSrc/src/main/java/org/opensearch/gradle/VersionProperties.java index a57746fadd4ad..2b50e59de04d3 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/VersionProperties.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/VersionProperties.java @@ -59,6 +59,8 @@ public static String getBundledJdk(final String platform) { case "darwin": // fall trough case "mac": return bundledJdkDarwin; + case "freebsd": + return bundledJdkFreeBSD; case "linux": return bundledJdkLinux; case "windows": @@ -79,6 +81,7 @@ public static Map getVersions() { 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 static Map getVersions() { 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); diff --git a/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalDistributionBwcSetupPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalDistributionBwcSetupPlugin.java index 9e1211711ecf8..7a39a67d16c2a 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalDistributionBwcSetupPlugin.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalDistributionBwcSetupPlugin.java @@ -158,7 +158,7 @@ private static List resolveArchiveProjects(File checkoutDir 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")); } diff --git a/buildSrc/src/test/java/org/opensearch/gradle/JdkDownloadPluginTests.java b/buildSrc/src/test/java/org/opensearch/gradle/JdkDownloadPluginTests.java index 7facf603c0133..4dcc65cca4c62 100644 --- a/buildSrc/src/test/java/org/opensearch/gradle/JdkDownloadPluginTests.java +++ b/buildSrc/src/test/java/org/opensearch/gradle/JdkDownloadPluginTests.java @@ -92,7 +92,7 @@ public void testUnknownPlatform() { "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]" ); } diff --git a/distribution/archives/build.gradle b/distribution/archives/build.gradle index 801b42c6ee453..2c5b91f7e135d 100644 --- a/distribution/archives/build.gradle +++ b/distribution/archives/build.gradle @@ -88,31 +88,31 @@ distribution_archives { } } - windowsZip { - archiveClassifier = 'windows-x64' + darwinTar { + archiveClassifier = 'darwin-x64' content { - archiveFiles(modulesFiles('windows-x64'), 'zip', 'windows', 'x64', true) + archiveFiles(modulesFiles('darwin-x64'), 'tar', 'darwin', 'x64', true) } } - noJdkWindowsZip { - archiveClassifier = 'no-jdk-windows-x64' + noJdkDarwinTar { + archiveClassifier = 'no-jdk-darwin-x64' content { - archiveFiles(modulesFiles('windows-x64'), 'zip', 'windows', 'x64', false) + archiveFiles(modulesFiles('darwin-x64'), 'tar', 'darwin', 'x64', false) } } - darwinTar { - archiveClassifier = 'darwin-x64' + freebsdTar { + archiveClassifier = 'freebsd-x64' content { - archiveFiles(modulesFiles('darwin-x64'), 'tar', 'darwin', 'x64', true) + archiveFiles(modulesFiles('freebsd-x64'), 'tar', 'freebsd', 'x64', false) } } - noJdkDarwinTar { - archiveClassifier = 'no-jdk-darwin-x64' + noJdkFreebsdTar { + archiveClassifier = 'no-jdk-freebsd-x64' content { - archiveFiles(modulesFiles('darwin-x64'), 'tar', 'darwin', 'x64', false) + archiveFiles(modulesFiles('freebsd-x64'), 'tar', 'freebsd', 'x64', false) } } @@ -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 { diff --git a/distribution/build.gradle b/distribution/build.gradle index 762c2c36bf508..33232195973f0 100644 --- a/distribution/build.gradle +++ b/distribution/build.gradle @@ -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) diff --git a/settings.gradle b/settings.gradle index 271eff9808f4c..b13c767880459 100644 --- a/settings.gradle +++ b/settings.gradle @@ -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',