[Git][java-team/jboss-modules][upstream] New upstream version 1.10.2
Markus Koschany
gitlab at salsa.debian.org
Thu Aug 27 21:40:29 BST 2020
Markus Koschany pushed to branch upstream at Debian Java Maintainers / jboss-modules
Commits:
afaba9c6 by Markus Koschany at 2020-08-27T22:30:14+02:00
New upstream version 1.10.2
- - - - -
3 changed files:
- pom.xml
- + pom.xml.versionsBackup
- src/main/java/org/jboss/modules/NativeLibraryResourceLoader.java
Changes:
=====================================
pom.xml
=====================================
@@ -23,7 +23,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.modules</groupId>
<artifactId>jboss-modules</artifactId>
- <version>1.10.1.Final</version>
+ <version>1.10.2.Final</version>
<name>JBoss Modules</name>
<parent>
=====================================
pom.xml.versionsBackup
=====================================
@@ -0,0 +1,302 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2015 Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.modules</groupId>
+ <artifactId>jboss-modules</artifactId>
+ <version>1.10.2.Final-SNAPSHOT</version>
+ <name>JBoss Modules</name>
+
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>36</version>
+ </parent>
+
+ <licenses>
+ <license>
+ <name>Apache License 2.0</name>
+ <url>http://repository.jboss.org/licenses/apache-2.0.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ <license>
+ <name>Indiana University Extreme! Lab Software License 1.1.1</name>
+ <url>http://www.bearcave.com/software/java/xml/xmlpull_license.html</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <properties>
+ <skip.compile>false</skip.compile>
+ <version.org.wildfly.checkstyle-config>1.0.5.Final</version.org.wildfly.checkstyle-config>
+ <version.bridger>1.4.Final</version.bridger>
+
+ <jdk.min.version>9</jdk.min.version>
+ </properties>
+
+ <profiles>
+ <profile>
+ <id>java8-test-profile</id>
+ <activation>
+ <property>
+ <name>java8.home</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>java8-test</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <jvm>${java8.home}/bin/java</jvm>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/java</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>false</filtering>
+ </resource>
+ <resource>
+ <directory>target/generated-resources</directory>
+ <filtering>false</filtering>
+ </resource>
+ </resources>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>${version.checkstyle.plugin}</version>
+ <configuration>
+ <configLocation>wildfly-checkstyle/checkstyle.xml</configLocation>
+ <consoleOutput>true</consoleOutput>
+ <failsOnError>true</failsOnError>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <useFile/>
+ <excludes>**/MXParser.java</excludes>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.wildfly.checkstyle</groupId>
+ <artifactId>wildfly-checkstyle-config</artifactId>
+ <version>${version.org.wildfly.checkstyle-config}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>check-style</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>checkstyle</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+ <plugins>
+ <!-- Compiler -->
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.7.0-jboss-1</version>
+ <executions>
+ <execution>
+ <id>default-compile</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ <configuration>
+ <release>8</release>
+ <buildDirectory>${project.build.directory}</buildDirectory>
+ <compileSourceRoots>${project.compileSourceRoots}</compileSourceRoots>
+ <outputDirectory>${project.build.outputDirectory}</outputDirectory>
+ <additionalClasspathElements>
+ <additionalClasspathElement>${project.build.directory}/jdk-misc.jar</additionalClasspathElement>
+ </additionalClasspathElements>
+ </configuration>
+ </execution>
+ <execution>
+ <id>compile-java9</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ <configuration>
+ <release>9</release>
+ <buildDirectory>${project.build.directory}</buildDirectory>
+ <compileSourceRoots>${project.basedir}/src/main/java9</compileSourceRoots>
+ <outputDirectory>${project.build.directory}/classes/META-INF/versions/9</outputDirectory>
+ <additionalClasspathElements>
+ <additionalClasspathElement>${project.build.outputDirectory}</additionalClasspathElement>
+ </additionalClasspathElements>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <showDeprecation>true</showDeprecation>
+ <showWarnings>true</showWarnings>
+ <skipMain>${skip.compile}</skipMain>
+ <skip>${skip.compile}</skip>
+ </configuration>
+ </plugin>
+
+ <!-- Surefire -->
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <trimStackTrace>false</trimStackTrace>
+ <!-- Modules ignores Class-Path -->
+ <useManifestOnlyJar>false</useManifestOnlyJar>
+ <printSummary>true</printSummary>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ <forkMode>always</forkMode>
+ </configuration>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <configuration>
+ <classesDirectory>${project.build.directory}/classes/META-INF/versions/9</classesDirectory>
+ <additionalClasspathElements>
+ <additionalClasspathElement>${project.build.directory}/classes</additionalClasspathElement>
+ </additionalClasspathElements>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- JAR -->
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.jboss.modules.Main</mainClass>
+ </manifest>
+ <manifestEntries>
+ <Multi-Release>true</Multi-Release>
+ <Jar-Version>${project.version}</Jar-Version>
+ <Jar-Name>${project.artifactId}</Jar-Name>
+ <Agent-Class>org.jboss.modules.ModularAgent</Agent-Class>
+ <Premain-Class>org.jboss.modules.ModularAgent</Premain-Class>
+ <Can-Redefine-Classes>true</Can-Redefine-Classes>
+ <Can-Retransform-Classes>true</Can-Retransform-Classes>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+
+ <!-- Javadoc -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>${version.javadoc.plugin}</version>
+ <configuration>
+ <detectJavaApiLink>false</detectJavaApiLink>
+ <excludePackageNames>__redirected</excludePackageNames>
+ <excludePackageNames>org.jboss.modules._private</excludePackageNames>
+ <sourcepath>${project.basedir}/src/main/java9;${project.basedir}/src/main/java</sourcepath>
+ <sourceFileExcludes>
+ <exclude>org/jboss/modules/JDKSpecific.java</exclude>
+ </sourceFileExcludes>
+ </configuration>
+ </plugin>
+
+ <!-- Bridger -->
+ <plugin>
+ <groupId>org.jboss.bridger</groupId>
+ <artifactId>bridger</artifactId>
+ <version>${version.bridger}</version>
+ <executions>
+ <!-- run after "compile", runs bridger on main classes -->
+ <execution>
+ <id>weave</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>transform</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- Dependency -->
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>fetch-misc</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>get</goal>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifact>org.jboss:jdk-misc:2.Final</artifact>
+ <outputDirectory>${project.build.directory}</outputDirectory>
+ <stripVersion>true</stripVersion>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-impl-base</artifactId>
+ <version>1.2.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
=====================================
src/main/java/org/jboss/modules/NativeLibraryResourceLoader.java
=====================================
@@ -18,12 +18,19 @@
package org.jboss.modules;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.net.URI;
+import java.nio.charset.StandardCharsets;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* A base class for resource loaders which can load native libraries.
@@ -40,6 +47,16 @@ public class NativeLibraryResourceLoader extends AbstractResourceLoader {
static final String CPU_ID;
static final String ARCH_NAME;
static final String[] NATIVE_SEARCH_PATHS;
+ static final Pattern OS_RELEASE_VERSION_ID_PATTERN = Pattern.compile("([0-9]+).*");
+ static final Pattern DISTRIBUTION_RELEASE_VERSION_PATTERN = Pattern.compile(".*\\s([0-9]+).*");
+ static final Pattern MAC_VERSION_PATTERN = Pattern.compile("([0-9]+\\.[0-9]+)\\.[0-9]+");
+ static final String OS_RELEASE_FILE = "/etc/os-release";
+ static final String FEDORA_RELEASE_FILE = "/etc/fedora-release";
+ static final String REDHAT_RELEASE_FILE = "/etc/redhat-release";
+ static final String ID = "ID=";
+ static final String VERSION_ID = "VERSION_ID=";
+ static final String RHEL = "rhel";
+ static final String FEDORA = "fedora";
static {
final Object[] strings = AccessController.doPrivileged(new PrivilegedAction<Object[]>() {
@@ -47,6 +64,7 @@ public class NativeLibraryResourceLoader extends AbstractResourceLoader {
// First, identify the operating system.
boolean knownOs = true;
String osName;
+ String osVersion = null;
// let the user override it.
osName = System.getProperty("jboss.modules.os-name");
if (osName == null) {
@@ -58,8 +76,14 @@ public class NativeLibraryResourceLoader extends AbstractResourceLoader {
sysOs = sysOs.toUpperCase(Locale.US);
if (sysOs.startsWith("LINUX")) {
osName = "linux";
+ osVersion = getLinuxOSVersion();
} else if (sysOs.startsWith("MAC OS")) {
osName = "macosx";
+ String sysVersion = System.getProperty("os.version");
+ Matcher m = MAC_VERSION_PATTERN.matcher(sysVersion);
+ if (m.matches()) {
+ osVersion = m.group(1);
+ }
} else if (sysOs.startsWith("WINDOWS")) {
osName = "win";
} else if (sysOs.startsWith("OS/2")) {
@@ -244,11 +268,22 @@ public class NativeLibraryResourceLoader extends AbstractResourceLoader {
// Finally, search paths.
final int cpuCount = cpuNames.size();
- String[] searchPaths = new String[cpuCount];
+ final int searchPathsSize = osVersion != null ? cpuCount * 2 : cpuCount;
+ String[] searchPaths = new String[searchPathsSize];
if (knownOs && knownCpu) {
+ // attempt OS-version specific category first
+ String osNameAndVersion = osVersion != null ? osName + "-" + osVersion : osName;
for (int i = 0; i < cpuCount; i++) {
final String name = cpuNames.get(i);
- searchPaths[i] = osName + "-" + name;
+ searchPaths[i] = osNameAndVersion + "-" + name;
+ }
+ // fallback to general category
+ if (osVersion != null) {
+ int j = cpuCount;
+ for (int i = 0; i < cpuCount; i++) {
+ final String name = cpuNames.get(i);
+ searchPaths[j++] = osName + "-" + name;
+ }
}
} else {
searchPaths = new String[0];
@@ -267,6 +302,80 @@ public class NativeLibraryResourceLoader extends AbstractResourceLoader {
ARCH_NAME = strings[2].toString();
NATIVE_SEARCH_PATHS = (String[]) strings[3];
}
+
+ private static String getLinuxOSVersionFromOSReleaseFile() {
+ try (InputStream releaseFile = new FileInputStream(OS_RELEASE_FILE)) {
+ try (InputStreamReader inputStreamReader = new InputStreamReader(releaseFile, StandardCharsets.UTF_8)) {
+ try (BufferedReader reader = new BufferedReader(inputStreamReader)) {
+ String currentLine;
+ String id = null;
+ String versionId = null;
+ while ((id == null || versionId == null) && (currentLine = reader.readLine()) != null) {
+ final String trimmed = currentLine.trim();
+ if (trimmed.startsWith(ID)) {
+ int equalsIndex = trimmed.indexOf('=');
+ id = trimmed.substring(equalsIndex + 1).replaceAll("\"", "");
+ } else if (trimmed.startsWith(VERSION_ID)) {
+ int equalsIndex = trimmed.indexOf('=');
+ versionId = trimmed.substring(equalsIndex + 1).replaceAll("\"", "");
+ }
+ }
+ if (id != null && versionId != null) {
+ String abbreviatedVersionId = versionId;
+ Matcher m = OS_RELEASE_VERSION_ID_PATTERN.matcher(versionId);
+ if (m.matches()) {
+ abbreviatedVersionId = m.group(1);
+ }
+ return id + abbreviatedVersionId;
+ }
+ return null;
+ }
+ }
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ private static String getLinuxOSVersionFromDistributionFile(String distributionFile) {
+ try (InputStream releaseFile = new FileInputStream(distributionFile)) {
+ try (InputStreamReader inputStreamReader = new InputStreamReader(releaseFile, StandardCharsets.UTF_8)) {
+ try (BufferedReader reader = new BufferedReader(inputStreamReader)) {
+ String currentLine;
+ String id = null;
+ String abbreviatedVersionId = null;
+ if ((currentLine = reader.readLine()) != null) {
+ final String trimmed = currentLine.trim();
+ if (trimmed.startsWith("Red Hat Enterprise Linux")) {
+ id = RHEL;
+ } else if (trimmed.startsWith("Fedora")) {
+ id = FEDORA;
+ }
+ Matcher m = DISTRIBUTION_RELEASE_VERSION_PATTERN.matcher(trimmed);
+ if (m.matches()) {
+ abbreviatedVersionId = m.group(1);
+ }
+ }
+ if (id != null && abbreviatedVersionId != null) {
+ return id + abbreviatedVersionId;
+ }
+ return null;
+ }
+ }
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ private static String getLinuxOSVersion() {
+ String osVersion = getLinuxOSVersionFromOSReleaseFile();
+ if (osVersion == null) {
+ osVersion = getLinuxOSVersionFromDistributionFile(FEDORA_RELEASE_FILE);
+ if (osVersion == null) {
+ osVersion = getLinuxOSVersionFromDistributionFile(REDHAT_RELEASE_FILE);
+ }
+ }
+ return osVersion;
+ }
}
/**
View it on GitLab: https://salsa.debian.org/java-team/jboss-modules/-/commit/afaba9c6d45e1e0e26eb7188f053791a30f6a8be
--
View it on GitLab: https://salsa.debian.org/java-team/jboss-modules/-/commit/afaba9c6d45e1e0e26eb7188f053791a30f6a8be
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20200827/f8fd43ce/attachment.html>
More information about the pkg-java-commits
mailing list