Skip to content

Commit 5814576

Browse files
committed
modularize launchers and java_version_checker
1 parent e792a96 commit 5814576

File tree

8 files changed

+43
-8
lines changed

8 files changed

+43
-8
lines changed

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionModuleCheckTaskProvider.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public void execute(Task task) {
6363
}
6464

6565
private static final String ES_JAR_PREFIX = "elasticsearch-";
66-
// ES jars in the lib directory that are not modularized. For now, launchers and es-log4j are the only ones
67-
private static final List<String> ES_JAR_EXCLUDES = List.of("elasticsearch-launchers", "elasticsearch-log4j");
66+
// ES jars in the lib directory that are not modularized. For now, es-log4j is the only one
67+
private static final List<String> ES_JAR_EXCLUDES = List.of("elasticsearch-log4j");
6868

6969
private static Predicate<Path> isESJar = path -> path.getFileName().toString().startsWith(ES_JAR_PREFIX);
7070
private static Predicate<Path> isNotExcluded = path -> ES_JAR_EXCLUDES.stream()
@@ -98,6 +98,8 @@ private static void assertAllESJarsAreModular(Path libsPath) {
9898
"org.elasticsearch.cli",
9999
"org.elasticsearch.core",
100100
"org.elasticsearch.geo",
101+
"org.elasticsearch.java_version_checker",
102+
"org.elasticsearch.launchers",
101103
"org.elasticsearch.lz4",
102104
"org.elasticsearch.plugin.classloader",
103105
"org.elasticsearch.secure_sm",

distribution/src/bin/elasticsearch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ while [ $# -gt 0 ]; do
4444
done
4545

4646
if [ -z "$ES_TMPDIR" ]; then
47-
ES_TMPDIR=`"$JAVA" "$XSHARE" -cp "$ES_CLASSPATH" org.elasticsearch.tools.launchers.TempDirectory`
47+
ES_TMPDIR=`"$JAVA" "$XSHARE" --module-path "$ES_MODULEPATH" -m org.elasticsearch.launchers/org.elasticsearch.tools.launchers.TempDirectory`
4848
fi
4949

5050
if [ -z "$LIBFFI_TMPDIR" ]; then
@@ -106,7 +106,7 @@ fi
106106
# - second, JVM options are read from jvm.options and jvm.options.d/*.options
107107
# - third, JVM options from ES_JAVA_OPTS are applied
108108
# - fourth, ergonomic JVM options are applied
109-
ES_JAVA_OPTS=`export ES_TMPDIR; "$JAVA" "$XSHARE" -cp "$ES_CLASSPATH" org.elasticsearch.tools.launchers.JvmOptionsParser "$ES_PATH_CONF" "$ES_HOME/plugins"`
109+
ES_JAVA_OPTS=`export ES_TMPDIR; "$JAVA" "$XSHARE" --module-path "$ES_MODULEPATH" -m org.elasticsearch.launchers/org.elasticsearch.tools.launchers.JvmOptionsParser "$ES_PATH_CONF" "$ES_HOME/plugins"`
110110

111111
# Remove enrollment related parameters before passing the arg list to Elasticsearch
112112
for i in "${!ARG_LIST[@]}"; do

distribution/tools/java-version-checker/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
apply plugin: 'elasticsearch.build'
22

3-
targetCompatibility = JavaVersion.VERSION_1_7
4-
53
// java_version_checker do not depend on core so only JDK signatures should be checked
64
tasks.named('forbiddenApisMain').configure {
75
replaceSignatureFiles 'jdk-signatures'
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
module org.elasticsearch.java_version_checker {
10+
exports org.elasticsearch.tools.java_version_checker;
11+
}

distribution/tools/java-version-checker/src/main/java/org/elasticsearch/tools/java_version_checker/JavaVersion.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public class JavaVersion {
1717
public static final List<Integer> CURRENT = parse(System.getProperty("java.specification.version"));
1818
public static final List<Integer> JAVA_17 = parse("17");
1919

20+
private JavaVersion() {}
21+
2022
static List<Integer> parse(final String value) {
2123
if (value.matches("^0*[0-9]+(\\.[0-9]+)*$") == false) {
2224
throw new IllegalArgumentException(value);

distribution/tools/launchers/build.gradle

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis
1010
apply plugin: 'elasticsearch.build'
1111

1212
dependencies {
13-
compileOnly project(':distribution:tools:java-version-checker')
14-
implementation "org.yaml:snakeyaml:${versions.snakeyaml}"
13+
moduleCompileOnly project(':distribution:tools:java-version-checker')
14+
moduleImplementation "org.yaml:snakeyaml:${versions.snakeyaml}"
1515
testImplementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
1616
testImplementation "junit:junit:${versions.junit}"
1717
testImplementation "org.hamcrest:hamcrest:${versions.hamcrest}"
@@ -35,3 +35,7 @@ tasks.named("testingConventions").configure {
3535
["javadoc", "loggerUsageCheck", "jarHell"].each { tsk ->
3636
tasks.named(tsk).configure { enabled = false }
3737
}
38+
39+
tasks.named("compileJava").configure {
40+
options.compilerArgs.add("-Xlint:-requires-automatic")
41+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
module org.elasticsearch.launchers {
10+
requires jdk.management;
11+
requires org.elasticsearch.java_version_checker;
12+
requires org.yaml.snakeyaml;
13+
14+
exports org.elasticsearch.tools.launchers;
15+
}

distribution/tools/launchers/src/main/java/org/elasticsearch/tools/launchers/BootstrapJvmOptions.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
* additional JVM options, in order to configure the bootstrap plugins.
2626
*/
2727
public class BootstrapJvmOptions {
28+
29+
private BootstrapJvmOptions() {}
30+
2831
public static List<String> bootstrapJvmOptions(Path plugins) throws IOException {
2932
if (Files.isDirectory(plugins) == false) {
3033
throw new IllegalArgumentException("Plugins path " + plugins + " must be a directory");

0 commit comments

Comments
 (0)