// Extracts library project contents under e.g. obj/Debug/[__library_projects__/*.jar | res/*/*] // Extracts library project contents under e.g. obj/Debug/[lp/*.jar | res/*/*] public override bool RunTask() { var jars = new Dictionary <string, ITaskItem> (); var resolvedResourceDirectories = new List <ITaskItem> (); var resolvedAssetDirectories = new List <ITaskItem> (); var resolvedEnvironmentFiles = new List <ITaskItem> (); assemblyMap.Load(AssemblyIdentityMapFile); try { Extract(jars, resolvedResourceDirectories, resolvedAssetDirectories, resolvedEnvironmentFiles); } catch (ZipIOException ex) { Log.LogCodedError("XA1004", ex.Message); Log.LogDebugMessage(ex.ToString()); } Jars = jars.Values.ToArray(); ResolvedResourceDirectories = resolvedResourceDirectories.ToArray(); ResolvedAssetDirectories = resolvedAssetDirectories.ToArray(); ResolvedEnvironmentFiles = resolvedEnvironmentFiles.ToArray(); ResolvedResourceDirectoryStamps = ResolvedResourceDirectories .Select(s => new TaskItem(Path.GetFullPath(Path.Combine(s.ItemSpec, "../..")) + ".stamp")) .ToArray(); foreach (var directory in ResolvedResourceDirectories) { MonoAndroidHelper.SetDirectoryWriteable(directory.ItemSpec); } foreach (var directory in ResolvedAssetDirectories) { MonoAndroidHelper.SetDirectoryWriteable(directory.ItemSpec); } if (!string.IsNullOrEmpty(CacheFile)) { var document = new XDocument( new XDeclaration("1.0", "UTF-8", null), new XElement("Paths", new XElement("Jars", Jars.Select(e => new XElement("Jar", e))), new XElement("ResolvedResourceDirectories", XDocumentExtensions.ToXElements(ResolvedResourceDirectories, "ResolvedResourceDirectory", knownMetadata) ), new XElement("ResolvedAssetDirectories", XDocumentExtensions.ToXElements(ResolvedAssetDirectories, "ResolvedAssetDirectory", knownMetadata)), new XElement("ResolvedEnvironmentFiles", XDocumentExtensions.ToXElements(ResolvedEnvironmentFiles, "ResolvedEnvironmentFile", knownMetadata)), new XElement("ResolvedResourceDirectoryStamps", XDocumentExtensions.ToXElements(ResolvedResourceDirectoryStamps, "ResolvedResourceDirectoryStamp", knownMetadata)) )); document.SaveIfChanged(CacheFile); } assemblyMap.Save(AssemblyIdentityMapFile); Log.LogDebugTaskItems(" Jars: ", Jars); Log.LogDebugTaskItems(" ResolvedResourceDirectories: ", ResolvedResourceDirectories); Log.LogDebugTaskItems(" ResolvedAssetDirectories: ", ResolvedAssetDirectories); Log.LogDebugTaskItems(" ResolvedEnvironmentFiles: ", ResolvedEnvironmentFiles); Log.LogDebugTaskItems(" ResolvedResourceDirectoryStamps: ", ResolvedResourceDirectoryStamps); return(!Log.HasLoggedErrors); }
// Extracts library project contents under e.g. obj/Debug/[__library_projects__/*.jar | res/*/*] // Extracts library project contents under e.g. obj/Debug/[lp/*.jar | res/*/*] public override bool Execute() { var jars = new Dictionary <string, ITaskItem> (); var resolvedResourceDirectories = new List <ITaskItem> (); var resolvedAssetDirectories = new List <ITaskItem> (); var resolvedEnvironmentFiles = new List <ITaskItem> (); assemblyMap.Load(AssemblyIdentityMapFile); assembliesToSkipCaseFixup = new HashSet <string> (StringComparer.OrdinalIgnoreCase); assembliestoSkipExtraction = new HashSet <string> (StringComparer.OrdinalIgnoreCase); bool metaDataValue; foreach (var asm in Assemblies) { if (bool.TryParse(asm.GetMetadata(AndroidSkipResourceProcessing), out metaDataValue) && metaDataValue) { assembliesToSkipCaseFixup.Add(asm.ItemSpec); } if (bool.TryParse(asm.GetMetadata(GetAdditionalResourcesFromAssemblies.AndroidSkipResourceExtraction), out metaDataValue) && metaDataValue) { assembliestoSkipExtraction.Add(asm.ItemSpec); } } using (var resolver = new DirectoryAssemblyResolver(this.CreateTaskLogger(), loadDebugSymbols: false)) { try { Extract(resolver, jars, resolvedResourceDirectories, resolvedAssetDirectories, resolvedEnvironmentFiles); } catch (ZipIOException ex) { Log.LogCodedError("XA1004", ex.Message); Log.LogDebugMessage(ex.ToString()); } } Jars = jars.Values.ToArray(); ResolvedResourceDirectories = resolvedResourceDirectories.ToArray(); ResolvedAssetDirectories = resolvedAssetDirectories.ToArray(); ResolvedEnvironmentFiles = resolvedEnvironmentFiles.ToArray(); ResolvedResourceDirectoryStamps = ResolvedResourceDirectories .Select(s => new TaskItem(Path.GetFullPath(Path.Combine(s.ItemSpec, "../..")) + ".stamp")) .ToArray(); foreach (var directory in ResolvedResourceDirectories) { MonoAndroidHelper.SetDirectoryWriteable(directory.ItemSpec); } foreach (var directory in ResolvedAssetDirectories) { MonoAndroidHelper.SetDirectoryWriteable(directory.ItemSpec); } if (!string.IsNullOrEmpty(CacheFile)) { var document = new XDocument( new XDeclaration("1.0", "UTF-8", null), new XElement("Paths", new XElement("Jars", Jars.Select(e => new XElement("Jar", e))), new XElement("ResolvedResourceDirectories", XDocumentExtensions.ToXElements(ResolvedResourceDirectories, "ResolvedResourceDirectory", knownMetadata) ), new XElement("ResolvedAssetDirectories", XDocumentExtensions.ToXElements(ResolvedAssetDirectories, "ResolvedAssetDirectory", knownMetadata)), new XElement("ResolvedEnvironmentFiles", XDocumentExtensions.ToXElements(ResolvedEnvironmentFiles, "ResolvedEnvironmentFile", knownMetadata)), new XElement("ResolvedResourceDirectoryStamps", XDocumentExtensions.ToXElements(ResolvedResourceDirectoryStamps, "ResolvedResourceDirectoryStamp", knownMetadata)) )); document.SaveIfChanged(CacheFile); } assemblyMap.Save(AssemblyIdentityMapFile); Log.LogDebugTaskItems(" Jars: ", Jars); Log.LogDebugTaskItems(" ResolvedResourceDirectories: ", ResolvedResourceDirectories); Log.LogDebugTaskItems(" ResolvedAssetDirectories: ", ResolvedAssetDirectories); Log.LogDebugTaskItems(" ResolvedEnvironmentFiles: ", ResolvedEnvironmentFiles); Log.LogDebugTaskItems(" ResolvedResourceDirectoryStamps: ", ResolvedResourceDirectoryStamps); return(!Log.HasLoggedErrors); }