-
Notifications
You must be signed in to change notification settings - Fork 31
[Xamarin.Android.Tools.AndroidSdk] Add JdkInfo #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Current example usage: $ csharp -r:bin/Debug/Xamarin.Android.Tools.AndroidSdk.dll
Mono C# Shell, type "help;" for help
Enter statements below.
csharp> var info = new Xamarin.Android.Tools.JdkInfo ("/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home");
csharp> info;
JdkInfo(Version=1.8.0.77, Vendor="Oracle Corporation", HomePath="/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home")
csharp> info.JarPath;
"/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/jar"
csharp> info.ReleaseProperties
{
{ "JAVA_VERSION", "1.8.0_77" },
{ "OS_NAME", "Darwin" },
{ "OS_VERSION", "11.2" },
{ "OS_ARCH", "x86_64" },
{ "SOURCE", " .:3fbef9f4cddf corba:e8dc6eb11c76 deploy:d84f06512943 hotspot:223b64a19e94 hotspot/make/closed:477ad98b429e hotspot/src/closed:59776a84c75d hotspot/test/closed:960f70129730 install:9e94ca99871e jaxp:1c71899e8566 jaxws:c6f67bea4466 jdk:e29d2956631e jdk/make/closed:9dbc2900ee6c jdk/src/closed:3912d596b196 jdk/test/closed:0d90cb7caa56 langtools:094308b2ca1c nashorn:b6ee21a35619 pubs:116f6084ae4a sponsors:1ec3827eadc4" },
{ "BUILD_TYPE", "commercial" },
}
csharp> info.JavaProperties
{
{ "awt.toolkit", { "sun.lwawt.macosx.LWCToolkit" } },
{ "file.encoding", { "UTF-8" } },
{ "file.encoding.pkg", { "sun.io" } },
{ "file.separator", { "/" } },
{ "ftp.nonProxyHosts", { "local|*.local|169.254/16|*.169.254/16" } },
{ "gopherProxySet", { "false" } },
{ "http.nonProxyHosts", { "local|*.local|169.254/16|*.169.254/16" } },
{ "java.awt.graphicsenv", { "sun.awt.CGraphicsEnvironment" } },
{ "java.awt.printerjob", { "sun.lwawt.macosx.CPrinterJob" } },
{ "java.class.path", { "." } },
{ "java.class.version", { "52.0" } },
{ "java.endorsed.dirs", { "/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/endorsed" } },
{ "java.ext.dirs", {
"/Users/jon/Library/Java/Extensions",
"/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/ext",
"/Library/Java/Extensions",
"/Network/Library/Java/Extensions",
"/System/Library/Java/Extensions",
"/usr/lib/java" } },
{ "java.home", { "/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre" } },
{ "java.io.tmpdir", { "/var/folders/1y/wwmg3hv5685ft661f5q2w2100000gn/T/" } },
{ "java.library.path", {
"/Users/jon/Library/Java/Extensions",
"/Library/Java/Extensions",
"/Network/Library/Java/Extensions",
"/System/Library/Java/Extensions",
"/usr/lib/java",
"." } },
{ "java.runtime.name", { "Java(TM) SE Runtime Environment" } },
{ "java.runtime.version", { "1.8.0_77-b03" } },
{ "java.specification.name", { "Java Platform API Specification" } },
{ "java.specification.vendor", { "Oracle Corporation" } },
{ "java.specification.version", { "1.8" } },
{ "java.vendor", { "Oracle Corporation" } },
{ "java.vendor.url", { "http://java.oracle.com/" } },
{ "java.vendor.url.bug", { "http://bugreport.sun.com/bugreport/" } },
{ "java.version", { "1.8.0_77" } },
{ "java.vm.info", { "mixed mode" } },
{ "java.vm.name", { "Java HotSpot(TM) 64-Bit Server VM" } },
{ "java.vm.specification.name", { "Java Virtual Machine Specification" } },
{ "java.vm.specification.vendor", { "Oracle Corporation" } },
{ "java.vm.specification.version", { "1.8" } },
{ "java.vm.vendor", { "Oracle Corporation" } },
{ "java.vm.version", { "25.77-b03" } },
{ "line.separator", { "\n " } },
{ "os.arch", { "x86_64" } },
{ "os.name", { "Mac OS X" } },
{ "os.version", { "10.13.5" } },
{ "path.separator", { ":" } },
{ "socksNonProxyHosts", { "local|*.local|169.254/16|*.169.254/16" } },
{ "sun.arch.data.model", { "64" } },
{ "sun.boot.class.path", {
"/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/resources.jar",
"/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/rt.jar",
"/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/sunrsasign.jar",
"/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/jsse.jar",
"/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/jce.jar",
"/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/charsets.jar",
"/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/jfr.jar",
"/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/classes" } },
{ "sun.boot.library.path", { "/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib" } },
{ "sun.cpu.endian", { "little" } },
{ "sun.cpu.isalist", { "" } },
{ "sun.io.unicode.encoding", { "UnicodeBig" } },
{ "sun.java.launcher", { "SUN_STANDARD" } },
{ "sun.jnu.encoding", { "UTF-8" } },
{ "sun.management.compiler", { "HotSpot 64-Bit Tiered Compilers" } },
{ "sun.os.patch.level", { "unknown" } },
{ "user.country", { "US" } },
{ "user.dir", { "/Volumes/Seagate4TB/work/xamarin-android/external/xamarin-android-tools" } },
{ "user.home", { "/Users/jon" } },
{ "user.language", { "en" } },
{ "user.name", { "jon" } },
{ "user.timezone", { "" } },
} |
|
@grendello: I'm not sold on the name |
|
@jonpryor yeah... This type should be named enum ValueKind
{
Simple,
List,
}
abstract class InfoValueBase
{
public abstract ValueKind { get; }
//...
}
class InfoValue<T> : InfoValueBase
{
public T Value <T> { get; set; }
}And use |
| if (IsMac) | ||
| NativeLibraryFormat = "lib{0}.dylib"; | ||
| if (!IsWindows && !IsMac) | ||
| NativeLibraryFormat = "lib{0}.so"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to special-case Linux here as well. In theory the code can run on e.g. the *BSD family of Unix systems (other than macOS) and if you know you're running on Linux then you can check what distribution you're on and use that distribution's mechanisms to detect Java instances (e.g. on Debian + family you can use /usr/sbin/update-java-alternatives -l but you can't use it, say, on Manjaro)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't special-case systems I'm not running. :-)
BSD contributions welcome. In the meantime, there is support for $JAVA_HOME and $PATH already.
5c7107e to
fbbf15a
Compare
Fixes: dotnet#26 Context: dotnet#29 (comment) Refactor out the [underlying functionality][0] of the [`<JdkInfo/>` task][1] so that it is more easily usable. [0]: dotnet/java-interop@4bd9297 [1]: https://github.com/xamarin/java.interop/blob/master/src/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/JdkInfo.cs
Context: #29 (comment)
Refactor out the underlying functionality of the
<JdkInfo/>task so that it is more easily usable.