public override bool Execute()
        {
            Log.LogDebugMessage("CalculateAdditionalResourceCacheDirectories Task");
            Log.LogDebugTaskItems("  AdditionalAndroidResourcePaths:", AdditionalAndroidResourcePaths);
            Log.LogDebugMessage("  CacheDirectory: {0}", CacheDirectory);

            if (!AdditionalAndroidResourcePaths.Any())
            {
                return(true);
            }

            var md5 = MD5.Create();

            Directory.CreateDirectory(CacheDirectory);
            var directories = new List <ITaskItem> ();

            foreach (var path in AdditionalAndroidResourcePaths)
            {
                var cacheSubDirectory = string.Concat(md5.ComputeHash(
                                                          Encoding.UTF8.GetBytes(path)).Select(b => b.ToString("X02"))
                                                      );
                var targetDir = Path.Combine(CacheDirectory, cacheSubDirectory);
                directories.Add(new TaskItem(Path.GetFullPath(targetDir).TrimEnd(Path.DirectorySeparatorChar)));
            }
            AdditionalResourceCachePaths = directories.ToArray();

            Log.LogDebugTaskItems("  [Output] AdditionalResourceCachePaths:", AdditionalResourceCachePaths);
            return(!Log.HasLoggedErrors);
        }
        public override bool Execute()
        {
            if (!File.Exists(CacheFile))
            {
                Log.LogDebugMessage("{0} does not exist. No Additional Resources found", CacheFile);
                return(!Log.HasLoggedErrors);
            }
            var doc = XDocument.Load(CacheFile);

            AdditionalAndroidResourcePaths = doc.GetPaths("AdditionalAndroidResourcePaths",
                                                          "AdditionalAndroidResourcePath");
            AdditionalJavaLibraryReferences = doc.GetPaths("AdditionalJavaLibraryReferences",
                                                           "AdditionalJavaLibraryReference");
            AdditionalNativeLibraryReferences = doc.GetPaths("AdditionalNativeLibraryReferences",
                                                             "AdditionalNativeLibraryReference");

            Log.LogDebugTaskItems("  AdditionalAndroidResourcePaths: ", AdditionalAndroidResourcePaths);
            Log.LogDebugTaskItems("  AdditionalJavaLibraryReferences: ", AdditionalJavaLibraryReferences);
            Log.LogDebugTaskItems("  AdditionalNativeLibraryReferences: ", AdditionalNativeLibraryReferences);

            IsResourceCacheValid = AdditionalAndroidResourcePaths.All(x => Directory.Exists(x)) &&
                                   AdditionalJavaLibraryReferences.All(x => File.Exists(x)) &&
                                   AdditionalNativeLibraryReferences.All(x => File.Exists(x));

            Log.LogDebugMessage("  IsValid: {0}", IsResourceCacheValid);

            return(!Log.HasLoggedErrors);
        }
Beispiel #3
0
        public override bool RunTask()
        {
            if (!AdditionalAndroidResourcePaths.Any())
            {
                return(true);
            }

            Directory.CreateDirectory(CacheDirectory);
            var directories = new List <ITaskItem> ();

            foreach (var path in AdditionalAndroidResourcePaths)
            {
                var targetDir = Path.Combine(CacheDirectory, Files.HashString(path));
                directories.Add(new TaskItem(Path.GetFullPath(targetDir).TrimEnd(Path.DirectorySeparatorChar)));
            }
            AdditionalResourceCachePaths = directories.ToArray();

            Log.LogDebugTaskItems("  [Output] AdditionalResourceCachePaths:", AdditionalResourceCachePaths);
            return(!Log.HasLoggedErrors);
        }