diff --git a/src/main/java/com/gluonhq/substrate/target/AbstractTargetConfiguration.java b/src/main/java/com/gluonhq/substrate/target/AbstractTargetConfiguration.java index ba6cef2f..f777ce6e 100644 --- a/src/main/java/com/gluonhq/substrate/target/AbstractTargetConfiguration.java +++ b/src/main/java/com/gluonhq/substrate/target/AbstractTargetConfiguration.java @@ -35,7 +35,7 @@ import com.gluonhq.substrate.model.Triplet; import com.gluonhq.substrate.util.FileDeps; import com.gluonhq.substrate.util.FileOps; -import com.gluonhq.substrate.util.JavaLib; +import com.gluonhq.substrate.util.Lib; import com.gluonhq.substrate.util.Logger; import com.gluonhq.substrate.util.ProcessRunner; import com.gluonhq.substrate.util.Strings; @@ -101,20 +101,11 @@ public abstract class AbstractTargetConfiguration implements TargetConfiguration protected final boolean crossCompile; private final List defaultAdditionalSourceFiles = Collections.singletonList("launcher.c"); - private final List defaultStaticJavaLibs = List.of( - JavaLib.of("java"), - JavaLib.of("nio"), - JavaLib.of("zip"), - JavaLib.of("net"), - JavaLib.of("prefs"), - JavaLib.of("jvm"), - JavaLib.upto(20, "fdlibm"), - JavaLib.of("z"), - JavaLib.of("dl"), - JavaLib.of("j2pkcs11"), - JavaLib.upto(11, "sunec"), - JavaLib.of("jaas"), - JavaLib.of("extnet") + private final List defaultStaticJavaLibs = List.of( + Lib.of("java"), Lib.of("nio"), Lib.of("zip"), Lib.of("net"), + Lib.of("prefs"), Lib.of("jvm"), Lib.upTo(20, "fdlibm"), Lib.of("z"), + Lib.of("dl"), Lib.of("j2pkcs11"), Lib.upTo(11, "sunec"), Lib.of("jaas"), + Lib.of("extnet") ); AbstractTargetConfiguration(ProcessPaths paths, InternalProjectConfiguration configuration) { @@ -957,14 +948,14 @@ List getOtherStaticLibs() { /** * Return the list of library names applicable to the used java version. - * @param libs List to validate based on {@link JavaLib#inRange(int)}. + * @param libs List to validate based on {@link Lib#inRange(int)}. * @return The list of library names applicable to the used java version. */ - List filterApplicableLibs(List libs) { + final List filterApplicableLibs(List libs) { int major = projectConfiguration.getJavaVersion().getMajor(); return libs.stream() .filter(l -> l.inRange(major)) - .map(JavaLib::getLibName) + .map(Lib::getLibName) .collect(Collectors.toList()); } diff --git a/src/main/java/com/gluonhq/substrate/target/LinuxTargetConfiguration.java b/src/main/java/com/gluonhq/substrate/target/LinuxTargetConfiguration.java index 8d00b8ff..42fa0589 100644 --- a/src/main/java/com/gluonhq/substrate/target/LinuxTargetConfiguration.java +++ b/src/main/java/com/gluonhq/substrate/target/LinuxTargetConfiguration.java @@ -31,7 +31,7 @@ import com.gluonhq.substrate.model.InternalProjectConfiguration; import com.gluonhq.substrate.model.ProcessPaths; import com.gluonhq.substrate.util.FileOps; -import com.gluonhq.substrate.util.JavaLib; +import com.gluonhq.substrate.util.Lib; import com.gluonhq.substrate.util.Logger; import com.gluonhq.substrate.util.ProcessRunner; import com.gluonhq.substrate.util.Version; @@ -60,21 +60,11 @@ public class LinuxTargetConfiguration extends PosixTargetConfiguration { private static final List linuxLibs = Arrays.asList("z", "dl", "stdc++", "pthread"); - private static final List staticJavaLibs = List.of( - JavaLib.of("java"), - JavaLib.of("nio"), - JavaLib.of("zip"), - JavaLib.of("net"), - JavaLib.of("prefs"), - JavaLib.of("j2pkcs11"), - JavaLib.upto(11, "sunec"), - JavaLib.of("extnet"), - JavaLib.upto(20, "fdlibm"), - JavaLib.of("fontmanager"), - JavaLib.of("javajpeg"), - JavaLib.of("lcms"), - JavaLib.of("awt_headless"), - JavaLib.of("awt") + private static final List staticJavaLibs = List.of( + Lib.of("java"), Lib.of("nio"), Lib.of("zip"), Lib.of("net"), + Lib.of("prefs"), Lib.of("j2pkcs11"), Lib.upTo(11, "sunec"), Lib.of("extnet"), + Lib.upTo(20, "fdlibm"), Lib.of("fontmanager"), Lib.of("javajpeg"), Lib.of("lcms"), + Lib.of("awt_headless"), Lib.of("awt") ); private static final List staticJvmLibs = Arrays.asList( "jvm", "libchelper" diff --git a/src/main/java/com/gluonhq/substrate/target/MacOSTargetConfiguration.java b/src/main/java/com/gluonhq/substrate/target/MacOSTargetConfiguration.java index bef7da63..f4605141 100644 --- a/src/main/java/com/gluonhq/substrate/target/MacOSTargetConfiguration.java +++ b/src/main/java/com/gluonhq/substrate/target/MacOSTargetConfiguration.java @@ -30,7 +30,7 @@ import com.gluonhq.substrate.model.InternalProjectConfiguration; import com.gluonhq.substrate.model.ProcessPaths; import com.gluonhq.substrate.util.FileOps; -import com.gluonhq.substrate.util.JavaLib; +import com.gluonhq.substrate.util.Lib; import com.gluonhq.substrate.util.Logger; import com.gluonhq.substrate.util.XcodeUtils; import com.gluonhq.substrate.util.macos.CodeSigning; @@ -57,16 +57,10 @@ public class MacOSTargetConfiguration extends DarwinTargetConfiguration { "ApplicationServices", "OpenGL", "QuartzCore", "Security", "Accelerate" ); - private static final List staticJavaLibs = Arrays.asList( - JavaLib.of("java"), - JavaLib.of("nio"), - JavaLib.of("zip"), - JavaLib.of("net"), - JavaLib.of("prefs"), - JavaLib.of("j2pkcs11"), - JavaLib.upto(20, "fdlibm"), - JavaLib.upto(11, "sunec"), - JavaLib.of("extnet") + private static final List staticJavaLibs = Arrays.asList( + Lib.of("java"), Lib.of("nio"), Lib.of("zip"), Lib.of("net"), + Lib.of("prefs"), Lib.of("j2pkcs11"), Lib.upTo(20, "fdlibm"), Lib.upTo(11, "sunec"), + Lib.of("extnet") ); private static final List staticJvmLibs = Arrays.asList( "jvm", "libchelper", "darwin" diff --git a/src/main/java/com/gluonhq/substrate/target/WindowsTargetConfiguration.java b/src/main/java/com/gluonhq/substrate/target/WindowsTargetConfiguration.java index 0ce393e9..0ec64b43 100644 --- a/src/main/java/com/gluonhq/substrate/target/WindowsTargetConfiguration.java +++ b/src/main/java/com/gluonhq/substrate/target/WindowsTargetConfiguration.java @@ -31,7 +31,7 @@ import com.gluonhq.substrate.model.InternalProjectConfiguration; import com.gluonhq.substrate.model.ProcessPaths; import com.gluonhq.substrate.util.FileOps; -import com.gluonhq.substrate.util.JavaLib; +import com.gluonhq.substrate.util.Lib; import com.gluonhq.substrate.util.Logger; import com.gluonhq.substrate.util.ProcessRunner; import com.gluonhq.substrate.util.windows.MSIBundler; @@ -47,29 +47,15 @@ public class WindowsTargetConfiguration extends AbstractTargetConfiguration { - private static final List javaWindowsLibs = List.of( - JavaLib.of("advapi32"), - JavaLib.of("iphlpapi"), - JavaLib.of("secur32"), - JavaLib.of("userenv"), - JavaLib.of("version"), - JavaLib.of("ws2_32"), - JavaLib.of("winhttp"), - JavaLib.of("ncrypt"), - JavaLib.of("crypt32"), - JavaLib.from(20, "mswsock") + private static final List javaWindowsLibs = List.of( + Lib.of("advapi32"), Lib.of("iphlpapi"), Lib.of("secur32"), Lib.of("userenv"), + Lib.of("version"), Lib.of("ws2_32"), Lib.of("winhttp"), Lib.of("ncrypt"), + Lib.of("crypt32"), Lib.from(20, "mswsock") ); - private static final List staticJavaLibs = List.of( - JavaLib.of("j2pkcs11"), - JavaLib.of("java"), - JavaLib.of("net"), - JavaLib.of("nio"), - JavaLib.of("prefs"), - JavaLib.upto(20, "fdlibm"), - JavaLib.upto(11, "sunec"), - JavaLib.of("zip"), - JavaLib.of("sunmscapi"), - JavaLib.from(21, "extnet") + private static final List staticJavaLibs = List.of( + Lib.of("j2pkcs11"), Lib.of("java"), Lib.of("net"), Lib.of("nio"), + Lib.of("prefs"), Lib.upTo(20, "fdlibm"), Lib.upTo(11, "sunec"), Lib.of("zip"), + Lib.of("sunmscapi"), Lib.from(21, "extnet") ); private static final List staticJvmLibs = Arrays.asList( "jvm", "libchelper"); diff --git a/src/main/java/com/gluonhq/substrate/util/JavaLib.java b/src/main/java/com/gluonhq/substrate/util/Lib.java similarity index 81% rename from src/main/java/com/gluonhq/substrate/util/JavaLib.java rename to src/main/java/com/gluonhq/substrate/util/Lib.java index b3811cc3..636fbcfd 100644 --- a/src/main/java/com/gluonhq/substrate/util/JavaLib.java +++ b/src/main/java/com/gluonhq/substrate/util/Lib.java @@ -30,7 +30,7 @@ /** * This class represents a java library constrained to the optional lower and upper bounds. */ -public class JavaLib { +public class Lib { /** * lower bound of the applicable version range, inclusive */ @@ -41,7 +41,7 @@ public class JavaLib { private final Integer upperBound; private final String libName; - private JavaLib(Integer lowerBound, Integer upperBound, String libName) { + private Lib(Integer lowerBound, Integer upperBound, String libName) { this.lowerBound = lowerBound; this.upperBound = upperBound; this.libName = libName; @@ -59,19 +59,19 @@ public boolean inRange(int javaMajorVersion) { return true; } - public static JavaLib of(String libName) { - return new JavaLib(null, null, libName); + public static Lib of(String libName) { + return new Lib(null, null, libName); } - public static JavaLib range(int lowerBound, int upperBound, String libName) { - return new JavaLib(lowerBound, upperBound, libName); + public static Lib range(int lowerBound, int upperBound, String libName) { + return new Lib(lowerBound, upperBound, libName); } - public static JavaLib from(int lowerBound, String libName) { - return new JavaLib(lowerBound, null, libName); + public static Lib from(int lowerBound, String libName) { + return new Lib(lowerBound, null, libName); } - public static JavaLib upto(int upperBound, String libName) { - return new JavaLib(null, upperBound, libName); + public static Lib upTo(int upperBound, String libName) { + return new Lib(null, upperBound, libName); } } diff --git a/src/test/java/com/gluonhq/substrate/util/JavaLibTest.java b/src/test/java/com/gluonhq/substrate/util/LibTest.java similarity index 91% rename from src/test/java/com/gluonhq/substrate/util/JavaLibTest.java rename to src/test/java/com/gluonhq/substrate/util/LibTest.java index 6021f82c..13ecd986 100644 --- a/src/test/java/com/gluonhq/substrate/util/JavaLibTest.java +++ b/src/test/java/com/gluonhq/substrate/util/LibTest.java @@ -31,17 +31,17 @@ import static org.junit.jupiter.api.Assertions.*; -class JavaLibTest { +class LibTest { @Test void testNoBound() { - JavaLib lib = JavaLib.of(""); + Lib lib = Lib.of(""); assertTrue(lib.inRange(0)); assertTrue(lib.inRange(100)); } @Test void testLowerBound() { - JavaLib lib = JavaLib.from(10, ""); + Lib lib = Lib.from(10, ""); assertFalse(lib.inRange(9)); assertTrue(lib.inRange(10)); assertTrue(lib.inRange(11)); @@ -49,7 +49,7 @@ void testLowerBound() { @Test void testUpperBound() { - JavaLib lib = JavaLib.upto(10, ""); + Lib lib = Lib.upTo(10, ""); assertTrue(lib.inRange(9)); assertTrue(lib.inRange(10)); assertFalse(lib.inRange(11)); @@ -57,7 +57,7 @@ void testUpperBound() { @Test void testRange() { - JavaLib lib = JavaLib.range(10, 12, ""); + Lib lib = Lib.range(10, 12, ""); assertFalse(lib.inRange(9)); assertTrue(lib.inRange(10)); assertTrue(lib.inRange(11));