mirror of
https://github.com/apache/nifi.git
synced 2025-02-28 22:49:10 +00:00
NIFI-5820 NiFi built on Java 8 can run on Java 11
Updated RunNiFi.java to add libs needed to run on Java 11 when it is the detected runtime java version and grant access to the necessary module (java.xml.bind) when running on Java 9 or 10 Added dependencies/includes/excludes to nifi-assembly configurations for enabling NiFi to run on Java 11 This closes #3174. Signed-off-by: Mark Payne <markap14@hotmail.com>
This commit is contained in:
parent
d0224f7897
commit
2453c36710
@ -745,6 +745,34 @@ language governing permissions and limitations under the License. -->
|
||||
<version>1.10.0-SNAPSHOT</version>
|
||||
<type>nar</type>
|
||||
</dependency>
|
||||
|
||||
<!-- dependencies for jaxb/activation/annotation for running NiFi on Java 11 -->
|
||||
<!-- TODO: remove these once minimum Java version is 11 -->
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>javax.activation-api</artifactId>
|
||||
<version>1.2.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
@ -992,6 +1020,13 @@ language governing permissions and limitations under the License. -->
|
||||
which are also not in bootstrap -->
|
||||
<exclude>org.apache.nifi:nifi-resources</exclude>
|
||||
<exclude>org.apache.nifi:nifi-docs</exclude>
|
||||
<!-- exclude jaxb/activation/annotation libs from lib, they'll be included in the java11 subdir -->
|
||||
<!-- TODO: remove these once minimum Java version is 11 -->
|
||||
<exclude>javax.xml.bind:jaxb-api</exclude>
|
||||
<exclude>com.sun.xml.bind:jaxb-impl</exclude>
|
||||
<exclude>com.sun.xml.bind:jaxb-core</exclude>
|
||||
<exclude>javax.activation:javax.activation-api</exclude>
|
||||
<exclude>javax.annotation:javax.annotation-api</exclude>
|
||||
</excludes>
|
||||
</dependency>
|
||||
</mapping>
|
||||
@ -1030,6 +1065,19 @@ language governing permissions and limitations under the License. -->
|
||||
</includes>
|
||||
</dependency>
|
||||
</mapping>
|
||||
<mapping>
|
||||
<!-- TODO: remove this mapping once minimum Java version is 11 -->
|
||||
<directory>/opt/nifi/nifi-${project.version}/lib/java11</directory>
|
||||
<dependency>
|
||||
<includes>
|
||||
<include>javax.xml.bind:jaxb-api</include>
|
||||
<include>com.sun.xml.bind:jaxb-impl</include>
|
||||
<include>com.sun.xml.bind:jaxb-core</include>
|
||||
<include>javax.activation:javax.activation-api</include>
|
||||
<include>javax.annotation:javax.annotation-api</include>
|
||||
</includes>
|
||||
</dependency>
|
||||
</mapping>
|
||||
<mapping>
|
||||
<directory>/opt/nifi/nifi-${project.version}/docs</directory>
|
||||
<sources>
|
||||
|
@ -31,6 +31,24 @@
|
||||
</includes>
|
||||
</dependencySet>
|
||||
|
||||
<!-- Write out the bootstrap libs for java11 to its own dir -->
|
||||
<!-- TODO: remove this dependency set once minimum Java version is 11 -->
|
||||
<dependencySet>
|
||||
<scope>runtime</scope>
|
||||
<useProjectArtifact>false</useProjectArtifact>
|
||||
<outputDirectory>lib/java11</outputDirectory>
|
||||
<directoryMode>0770</directoryMode>
|
||||
<fileMode>0664</fileMode>
|
||||
<useTransitiveFiltering>true</useTransitiveFiltering>
|
||||
<includes>
|
||||
<include>javax.xml.bind:jaxb-api</include>
|
||||
<include>com.sun.xml.bind:jaxb-impl</include>
|
||||
<include>com.sun.xml.bind:jaxb-core</include>
|
||||
<include>javax.activation:javax.activation-api</include>
|
||||
<include>javax.annotation:javax.annotation-api</include>
|
||||
</includes>
|
||||
</dependencySet>
|
||||
|
||||
<!-- Write out the conf directory contents -->
|
||||
<dependencySet>
|
||||
<scope>runtime</scope>
|
||||
|
@ -35,6 +35,14 @@
|
||||
<exclude>nifi-bootstrap</exclude>
|
||||
<exclude>nifi-resources</exclude>
|
||||
<exclude>nifi-docs</exclude>
|
||||
|
||||
<!-- exclude jaxb/activation/annotation libs from lib, they'll be included in the java11 subdir -->
|
||||
<!-- TODO: remove these once minimum Java version is 11 -->
|
||||
<exclude>javax.xml.bind:jaxb-api</exclude>
|
||||
<exclude>com.sun.xml.bind:jaxb-impl</exclude>
|
||||
<exclude>com.sun.xml.bind:jaxb-core</exclude>
|
||||
<exclude>javax.activation:javax.activation-api</exclude>
|
||||
<exclude>javax.annotation:javax.annotation-api</exclude>
|
||||
</excludes>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
|
@ -49,6 +49,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@ -993,6 +994,23 @@ public class RunNiFi {
|
||||
cpFiles.add(file.getAbsolutePath());
|
||||
}
|
||||
|
||||
String runtimeJavaVersion = System.getProperty("java.version");
|
||||
defaultLogger.info("Runtime Java version: {}", runtimeJavaVersion);
|
||||
if (Integer.parseInt(runtimeJavaVersion.substring(0, runtimeJavaVersion.indexOf('.'))) >= 11) {
|
||||
/* If running on Java 11 or greater, add the JAXB/activation/annotation libs to the classpath.
|
||||
*
|
||||
* TODO: Once the minimum Java version requirement of NiFi is 11, this processing should be removed.
|
||||
* JAXB/activation/annotation will be added as an actual dependency via pom.xml.
|
||||
*/
|
||||
final String libJava11Filename = replaceNull(props.get("lib.dir"), "./lib").trim() + "/java11";
|
||||
File libJava11Dir = getFile(libJava11Filename, workingDir);
|
||||
if (libJava11Dir.exists()) {
|
||||
for (final File file : Objects.requireNonNull(libJava11Dir.listFiles((dir, filename) -> filename.toLowerCase().endsWith(".jar")))) {
|
||||
cpFiles.add(file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final StringBuilder classPathBuilder = new StringBuilder();
|
||||
for (int i = 0; i < cpFiles.size(); i++) {
|
||||
final String filename = cpFiles.get(i);
|
||||
@ -1032,8 +1050,8 @@ public class RunNiFi {
|
||||
cmd.add("-Dnifi.bootstrap.listen.port=" + listenPort);
|
||||
cmd.add("-Dapp=NiFi");
|
||||
cmd.add("-Dorg.apache.nifi.bootstrap.config.log.dir=" + nifiLogDir);
|
||||
if (!System.getProperty("java.version").startsWith("1.")) {
|
||||
// running on Java 9+, java.xml.bind module must be made available
|
||||
if (runtimeJavaVersion.startsWith("9") || runtimeJavaVersion.startsWith("10")) {
|
||||
// running on Java 9 or 10, internal module java.xml.bind module must be made available
|
||||
cmd.add("--add-modules=java.xml.bind");
|
||||
}
|
||||
cmd.add("org.apache.nifi.NiFi");
|
||||
|
Loading…
x
Reference in New Issue
Block a user