Exemple #1
0
        internal IPlugin CreatePlugin(PomXmlElement element)
        {
            var plugin = new Plugin();

            plugin.LoadFromElement(element);
            return(plugin);
        }
Exemple #2
0
        internal protected virtual void LoadFromElement(PomXmlElement element)
        {
            //load project properties
            var propertiesNode = element.ReadElement("properties");

            if (propertiesNode != null)
            {
                Properties = propertiesNode.Elements
                             .Select(e => (IProperty) new Property(e)).ToList();
            }

            //load modules
            Modules = element.ReadElements("modules", "module")
                      .Select(e => (IModule) new Module(e)).ToList();

            //load dependencies
            Dependencies = element.ReadElements("dependencies", "dependency")
                           .Select(e => _dataFactory.CreateDependency(e)).ToList();

            // load plugins
            Plugins = element.ReadElements("build", "plugins", "plugin")
                      .Select(e => _dataFactory.CreatePlugin(e)).ToList();

            // load pluginManagement
            PluginManagement = element.ReadElements("build", "pluginManagement", "plugins", "plugin")
                               .Select(e => _dataFactory.CreatePlugin(e)).ToList();
        }
Exemple #3
0
        internal IProfile CreateProfile(PomXmlElement element)
        {
            var profile = new Profile();

            profile.LoadFromElement(element);
            return(profile);
        }
Exemple #4
0
        internal IDependency CreateDependency(PomXmlElement element)
        {
            var dependency = new Dependency();

            dependency.LoadFromElement(element);
            return(dependency);
        }
Exemple #5
0
        // TODO: factory
        internal IParentReference CreateParentReference(PomXmlElement parentNode)
        {
            var parent = new ParentReference();

            parent.LoadFromElement(parentNode);
            return(parent);
        }
Exemple #6
0
        internal protected override void LoadFromElement(PomXmlElement element)
        {
            base.LoadFromElement(element);

            Scope      = element.ReadElementValue("scope");
            Type       = element.ReadElementValue("type");
            Classifier = element.ReadElementValue("classifier");

            bool optional;

            Optional = bool.TryParse(element.ReadElementValue("optional"), out optional) && optional;
        }
Exemple #7
0
        internal protected override void SaveToElement(PomXmlElement element)
        {
            base.SaveToElement(element);

            element.SetElementValue("type", Type);
            element.SetElementValue("classifier", Classifier);
            element.SetElementValue("scope", Scope);

            if (Optional)
            {
                element.SetElementValue("optional", "true");
            }
        }
Exemple #8
0
        protected internal override void SaveToElement(PomXmlElement element)
        {
            base.SaveToElement(element);

            if (Executions != null)
            {
                element.AddElement(Executions);
            }

            if (Configuration != null)
            {
                element.AddElement(Configuration);
            }
        }
Exemple #9
0
        protected internal override void SaveToElement(PomXmlElement profileElem)
        {
            var idElem = profileElem.ReadOrCreateElement("id");

            if (string.IsNullOrEmpty(Id))
            {
                idElem.Remove();
            }
            else
            {
                idElem.Value = Id;
            }

            base.SaveToElement(profileElem);
        }
Exemple #10
0
        protected internal override void LoadFromElement(PomXmlElement element)
        {
            base.LoadFromElement(element);

            Packaging    = element.ReadElementValue("packaging");
            Name         = element.ReadElementValue("name");
            ModelVersion = element.ReadElementValue("modelVersion");

            //read parent
            var parentNode = element.ReadElement("parent");

            Parent = parentNode == null ? null : _dataFactory.CreateParentReference(parentNode);

            _container.LoadFromElement(element);

            //load profiles
            Profiles = element.ReadElements("profiles", "profile")
                       .Select(e => _dataFactory.CreateProfile(e)).ToList();
        }
Exemple #11
0
 internal protected virtual void LoadFromElement(PomXmlElement element)
 {
     ArtifactId = element.ReadElementValue("artifactId");
     GroupId    = element.ReadElementValue("groupId");
     Version    = element.ReadElementValue("version");
 }
Exemple #12
0
 internal protected override void LoadFromElement(PomXmlElement element)
 {
     base.LoadFromElement(element);
     Executions    = element.ReadElement("executions");
     Configuration = element.ReadElement("configuration");
 }
Exemple #13
0
 public void SaveTo(PomXmlElement externalModuleNode)
 {
     externalModuleNode.SetElementValue("artifactId", ArtifactId);
     externalModuleNode.SetElementValue("groupId", GroupId);
     externalModuleNode.SetElementValue("version", Version);
 }
Exemple #14
0
 internal protected override void LoadFromElement(PomXmlElement element)
 {
     Id = element.ReadElementValue("id");
     base.LoadFromElement(element);
 }
Exemple #15
0
 public Property(PomXmlElement e)
 {
     Name  = e.LocalName;
     Value = e.Value;
 }
Exemple #16
0
 public void SaveTo(PomXmlElement propertiesNode)
 {
     propertiesNode.SetElementValue(Name, Value);
 }
Exemple #17
0
        internal protected virtual void SaveToElement(PomXmlElement element)
        {
            //writing modules
            var modulesNode = element.ReadOrCreateElement("modules");

            if (!Modules.Any())
            {
                modulesNode.Remove();
            }
            else
            {
                modulesNode.RemoveAllChildElements();
                foreach (Module module in Modules)
                {
                    if (!string.IsNullOrEmpty(module.Path))
                    {
                        var moduleNode = modulesNode.CreateElement("module");
                        module.SaveTo(moduleNode);
                    }
                }
            }

            //writing dependencies
            var dependenciesNode = element.ReadOrCreateElement("dependencies");

            if (!Dependencies.Any())
            {
                dependenciesNode.Remove();
            }
            else
            {
                dependenciesNode.RemoveAllChildElements();
                foreach (Dependency dependency in Dependencies)
                {
                    var dependencyNode = dependenciesNode.CreateElement("dependency");
                    dependency.SaveToElement(dependencyNode);
                }
            }

            //writing properties
            var propertiesNode = element.ReadOrCreateElement("properties");

            if (!Properties.Any())
            {
                propertiesNode.Remove();
            }
            else
            {
                propertiesNode.RemoveAllChildElements();
                foreach (Property prop in Properties)
                {
                    prop.SaveTo(propertiesNode);
                }
            }

            var buildNode = element.ReadOrCreateElement("build");

            if (!Plugins.Any() && !PluginManagement.Any())             // empty build section
            {
                buildNode.Remove();
            }
            else
            {
                var pluginsNode = buildNode.ReadOrCreateElement("plugins");
                if (!Plugins.Any())
                {
                    pluginsNode.Remove();
                }
                else
                {
                    pluginsNode.RemoveAllChildElements();
                    foreach (Plugin plugin in Plugins)
                    {
                        var pluginNode = pluginsNode.CreateElement("plugin");
                        plugin.SaveToElement(pluginNode);
                    }
                }

                var pluginManagementNode        = buildNode.ReadOrCreateElement("pluginManagement");
                var pluginManagementPluginsNode = pluginManagementNode.ReadOrCreateElement("plugins");

                if (!PluginManagement.Any())
                {
                    pluginManagementNode.Remove();
                }
                else
                {
                    pluginManagementPluginsNode.RemoveAllChildElements();
                    foreach (Plugin plugin in PluginManagement)
                    {
                        var pluginNode = pluginManagementPluginsNode.CreateElement("plugin");
                        plugin.SaveToElement(pluginNode);
                    }
                }
            }
        }
Exemple #18
0
 internal protected override void LoadFromElement(PomXmlElement element)
 {
     base.LoadFromElement(element);
     RelativePath = element.ReadElementValue("relativePath");
 }
Exemple #19
0
 protected internal override void SaveToElement(PomXmlElement parentNode)
 {
     base.SaveToElement(parentNode);
     parentNode.SetElementValue("relativePath", RelativePath);
 }
Exemple #20
0
 internal protected virtual void SaveToElement(PomXmlElement element)
 {
     element.SetElementValue("groupId", GroupId);
     element.SetElementValue("artifactId", ArtifactId);
     element.SetElementValue("version", Version);
 }