preprocessor - Java dependencies according to operation system? -
so, have lot of projects based on java. uses lot of native libraries. of them(projects/libraries) in same repository. , of corse each os different dlls/jars idea change of them import according os. possible without using maven,gradle.. e.t.c? think using c++ preprocessor..
upt sorry misinformation, we`r using ant.. nice know solution it?
the ideal job use maven define dependencies need operating systems. project contain necessary libs each operating system. , using libs in code dynamically, detect os programmatically instruction :
system.getproperty("os.name")
and define switch loop or "if series" example of libs invocation.
here example can edit:
public class osvalidator { private static string os = system.getproperty("os.name").tolowercase(); public static void main(string[] args) { system.out.println(os); if (iswindows()) { system.out.println("this windows"); } else if (ismac()) { system.out.println("this mac"); } else if (isunix()) { system.out.println("this unix or linux"); } else if (issolaris()) { system.out.println("this solaris"); } else { system.out.println("your os not support!!"); } } public static boolean iswindows() { return (os.indexof("win") >= 0); } public static boolean ismac() { return (os.indexof("mac") >= 0); } public static boolean isunix() { return (os.indexof("nix") >= 0 || os.indexof("nux") >= 0 || os.indexof("aix") > 0 ); } public static boolean issolaris() { return (os.indexof("sunos") >= 0); }
}
Comments
Post a Comment