IGNITE-7117 .NET: Improve IgniteHome resolver
authorPavel Tupitsyn <ptupitsyn@apache.org>
Fri, 19 Jan 2018 13:19:52 +0000 (16:19 +0300)
committerPavel Tupitsyn <ptupitsyn@apache.org>
Fri, 19 Jan 2018 13:19:52 +0000 (16:19 +0300)
This closes #3402

modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteHome.cs

index d61c6b4..615798c 100644 (file)
@@ -112,16 +112,25 @@ namespace Apache.Ignite.Core.Impl.Common
         {
             try
             {
-                return dir.Exists &&
-                       (dir.EnumerateDirectories().Count(x => x.Name == "examples" || x.Name == "bin") == 2 &&
-                        dir.EnumerateDirectories().Count(x => x.Name == "modules" || x.Name == "platforms") == 1)
-                       || // NuGet home
-                       (dir.EnumerateDirectories().Any(x => x.Name == "libs") &&
-                        (dir.EnumerateFiles("Apache.Ignite.Core.dll").Any() ||
-                         dir.EnumerateFiles("Apache.Ignite.*.nupkg").Any() ||
-                         dir.EnumerateFiles("apache.ignite.*.nupkg").Any() ||  // Lowercase on Linux
-                         dir.EnumerateFiles("apache.ignite.nuspec").Any() ||  // Lowercase on Linux
-                         dir.EnumerateFiles("Apache.Ignite.nuspec").Any()));
+                if (!dir.Exists)
+                {
+                    return false;
+                }
+
+                // Binary release or NuGet home:
+                var libs = Path.Combine(dir.FullName, "libs");
+
+                if (Directory.Exists(libs) &&
+                    Directory.EnumerateFiles(libs, "ignite-core-*.jar", SearchOption.TopDirectoryOnly).Any())
+                {
+                    return true;
+                }
+
+                // Source release home:
+                var javaSrc = Path.Combine(dir.FullName,
+                    "modules", "core", "src", "main", "java", "org", "apache", "ignite");
+
+                return Directory.Exists(javaSrc);
             }
             catch (IOException)
             {