Exemple #1
0
        // Extracts library project contents under e.g. obj/Debug/[__library_projects__/*.jar | res/*/*]
        public override bool Execute()
        {
            Log.LogDebugMessage("ResolveLibraryProjectImports Task");
            Log.LogDebugMessage("  ImportsDirectory: {0}", ImportsDirectory);
            Log.LogDebugMessage("  OutputDirectory: {0}", OutputDirectory);
            Log.LogDebugMessage("  OutputImportDirectory: {0}", OutputImportDirectory);
            Log.LogDebugMessage("  UseShortFileNames: {0}", UseShortFileNames);
            Log.LogDebugTaskItems("  Assemblies: ", Assemblies);

            var jars = new List <string> ();
            var resolvedResourceDirectories = new List <string> ();
            var resolvedAssetDirectories    = new List <string> ();
            var resolvedEnvironmentFiles    = new List <string> ();

            using (var resolver = new DirectoryAssemblyResolver(Log.LogWarning, loadDebugSymbols: false)) {
                Extract(resolver, jars, resolvedResourceDirectories, resolvedAssetDirectories, resolvedEnvironmentFiles);
            }

            Jars = jars.ToArray();
            ResolvedResourceDirectories = resolvedResourceDirectories
                                          .Select(s => new TaskItem(Path.GetFullPath(s)))
                                          .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);
            }

            if (!string.IsNullOrEmpty(CacheFile))
            {
                var document = new XDocument(
                    new XDeclaration("1.0", "UTF-8", null),
                    new XElement("Paths",
                                 new XElement("Jars", string.Join(";", Jars)),
                                 new XElement("ResolvedResourceDirectories",
                                              ResolvedResourceDirectories.Select(e => new XElement("ResolvedResourceDirectory", e))),
                                 new XElement("ResolvedAssetDirectories",
                                              ResolvedAssetDirectories.Select(e => new XElement("ResolvedAssetDirectory", e))),
                                 new XElement("ResolvedEnvironmentFiles",
                                              ResolvedEnvironmentFiles.Select(e => new XElement("ResolvedEnvironmentFile", e))),
                                 new XElement("ResolvedResourceDirectoryStamps",
                                              ResolvedResourceDirectoryStamps.Select(e => new XElement("ResolvedResourceDirectoryStamp", e)))
                                 ));
                document.Save(CacheFile);
            }

            Log.LogDebugTaskItems("  Jars: ", Jars.Select(s => new TaskItem(s)).ToArray());
            Log.LogDebugTaskItems("  ResolvedResourceDirectories: ", ResolvedResourceDirectories.Select(s => new TaskItem(s)).ToArray());
            Log.LogDebugTaskItems("  ResolvedAssetDirectories: ", ResolvedAssetDirectories.Select(s => new TaskItem(s)).ToArray());
            Log.LogDebugTaskItems("  ResolvedEnvironmentFiles: ", ResolvedEnvironmentFiles.Select(s => new TaskItem(s)).ToArray());
            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);
        }
Exemple #3
0
        // 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 List <string> ();
            var resolvedResourceDirectories = new List <ITaskItem> ();
            var resolvedAssetDirectories    = new List <string> ();
            var resolvedEnvironmentFiles    = new List <string> ();

            assemblyMap.Load(AssemblyIdentityMapFile);
            assembliesToSkip = new HashSet <string> (AssembliesToSkipCases ?? new string [0], StringComparer.OrdinalIgnoreCase);

            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.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);
            }

            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",
                                              ResolvedResourceDirectories.Select(dir => {
                    var e = new XElement("ResolvedResourceDirectory", dir.ItemSpec);
                    foreach (var name in knownMetadata)
                    {
                        var value = dir.GetMetadata(name);
                        if (!string.IsNullOrEmpty(value))
                        {
                            e.SetAttributeValue(name, value);
                        }
                    }
                    return(e);
                })),
                                 new XElement("ResolvedAssetDirectories",
                                              ResolvedAssetDirectories.Select(e => new XElement("ResolvedAssetDirectory", e))),
                                 new XElement("ResolvedEnvironmentFiles",
                                              ResolvedEnvironmentFiles.Select(e => new XElement("ResolvedEnvironmentFile", e))),
                                 new XElement("ResolvedResourceDirectoryStamps",
                                              ResolvedResourceDirectoryStamps.Select(e => new XElement("ResolvedResourceDirectoryStamp", e)))
                                 ));
                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);
        }