Example #1
0
        void GeneratePluginXml(string nativeOutputPath, string scriptOutputPath)
        {
            Log.Message("    plugin.xml");

            PluginInfo pluginInfo;
            string     pluginXmlPath = Path.Combine(this.SourcePath, "ts", this.TargetName, "plugin.xml");

            using (StreamReader reader = File.OpenText(pluginXmlPath))
            {
                pluginInfo = PluginInfo.FromXml(reader, PluginInfo.C3PNamespaceUri);
            }

            CordovaPluginLinker.CollectSourceFilesInfo(nativeOutputPath, pluginInfo);

            foreach (string scriptFile in Directory.GetFiles(scriptOutputPath, "*.js"))
            {
                string scriptModuleName = Path.GetFileNameWithoutExtension(scriptFile);
                PluginInfo.JavaScriptModuleInfo jsModule = new PluginInfo.JavaScriptModuleInfo
                {
                    Name   = scriptModuleName,
                    Source = "www/" + scriptModuleName + ".js",
                };

                if (scriptModuleName == "CordovaWindowsBridge")
                {
                    jsModule.Runs = "true";
                    pluginInfo.WindowsPlatform.JavaScriptModules.Add(jsModule);
                }
                else
                {
                    pluginInfo.JavaScriptModules.Add(jsModule);
                }
            }

            using (StreamWriter writer = File.CreateText(Path.Combine(this.TargetOutputPath, "plugin.xml")))
            {
                pluginInfo.ToXml(writer, CordovaPluginLinker.cordovaPluginXmlNamespace);
            }
        }
Example #2
0
        protected virtual void Init()
        {
            if (String.IsNullOrEmpty(this.SourcePath))
            {
                throw new ArgumentNullException(nameof(SourcePath));
            }
            else if (this.IntermediatePaths == null || this.IntermediatePaths.Count == 0 ||
                     this.IntermediatePaths.Any(p => String.IsNullOrEmpty(p)))
            {
                throw new ArgumentNullException(nameof(IntermediatePaths));
            }
            else if (String.IsNullOrEmpty(this.OutputPath))
            {
                throw new ArgumentNullException(nameof(OutputPath));
            }

            if (!Directory.Exists(this.SourcePath))
            {
                throw new DirectoryNotFoundException("Source path not found: " + this.SourcePath);
            }

            // Don't check for existence of the last one because it was not specified explicitly.
            for (int i = 0; i < this.IntermediatePaths.Count - 1; i++)
            {
                if (!Directory.Exists(this.IntermediatePaths[i]))
                {
                    throw new DirectoryNotFoundException("Intermediate path not found: " + this.IntermediatePaths[i]);
                }
            }

            string pluginInfoFilePath = Path.Combine(this.SourcePath, "plugin.xml");

            if (!File.Exists(pluginInfoFilePath))
            {
                throw new FileNotFoundException("Plugin info file not found: " + pluginInfoFilePath);
            }

            using (StreamReader reader = File.OpenText(pluginInfoFilePath))
            {
                this.PluginInfo = PluginInfo.FromXml(reader);
            }

            if (!Directory.Exists(this.OutputPath))
            {
                Directory.CreateDirectory(this.OutputPath);
            }

            this.TargetOutputPath = Path.Combine(this.OutputPath, this.TargetName);
            if (!Directory.Exists(this.TargetOutputPath))
            {
                Directory.CreateDirectory(this.TargetOutputPath);
            }
            else
            {
                Utils.ClearDirectory(this.TargetOutputPath, new string[] { "tools" });
            }

            this.PluginInfo.Id = this.PluginInfo.Id + "-" + this.TargetName;

            Log.Important($"Linking {this.TargetName} plugin at\n" +
                          Utils.EnsureTrailingSlash(Path.GetFullPath(this.TargetOutputPath)));
        }
Example #3
0
        protected virtual void Init()
        {
            if (String.IsNullOrEmpty(this.SourcePath))
            {
                throw new ArgumentNullException(nameof(SourcePath));
            }
            else if (String.IsNullOrEmpty(this.IntermediatePath))
            {
                throw new ArgumentNullException(nameof(IntermediatePath));
            }

            if (!Directory.Exists(this.SourcePath))
            {
                throw new DirectoryNotFoundException("Source path not found: " + this.SourcePath);
            }

            this.PlatformSourcePath = Path.Combine(this.SourcePath, this.PlatformName);
            if (!String.IsNullOrEmpty(this.Language))
            {
                this.PlatformSourcePath += "-" + this.Language;
            }

            if (!Directory.Exists(this.PlatformSourcePath))
            {
                throw new DirectoryNotFoundException("Platform source path not found: " + this.PlatformSourcePath);
            }

            string pluginInfoFilePath = Path.Combine(this.SourcePath, "plugin.xml");

            if (!File.Exists(pluginInfoFilePath))
            {
                throw new FileNotFoundException("Plugin info file not found: " + pluginInfoFilePath);
            }

            using (StreamReader reader = File.OpenText(pluginInfoFilePath))
            {
                this.PluginInfo = PluginInfo.FromXml(reader);
            }

            if (!Directory.Exists(this.IntermediatePath))
            {
                Directory.CreateDirectory(this.IntermediatePath);
            }

            this.PlatformIntermediatePath = Path.Combine(this.IntermediatePath, this.PlatformName);
            if (!Directory.Exists(this.PlatformIntermediatePath))
            {
                Directory.CreateDirectory(this.PlatformIntermediatePath);
            }
            else
            {
                Utils.ClearDirectory(this.PlatformIntermediatePath, new string[] { "javadoc", "tools" });
            }

            PluginInfo.PlatformInfo platformInfo =
                this.PluginInfo.Platforms.SingleOrDefault(p => p.Name == this.PlatformName);
            if (platformInfo == null)
            {
                throw new InvalidOperationException(
                          "Platform info for " + this.PlatformName + " platform is missing from plugin.xml.");
            }

            Log.Important($"Compiling {this.PlatformName} APIs at\n" +
                          Utils.EnsureTrailingSlash(Path.GetFullPath(this.PlatformIntermediatePath)));
        }