Esempio n. 1
0
 def groupId(self):
     """
     Effective groupId of the pom Artifact taking into account parent groupId
     """
     gId = POMReader.find(self.__doc, './pom:groupId')
     if gId is None:
         gId = POMReader.find(self.__doc, './pom:parent/pom:groupId')
     if gId is None:
         raise PomLoadingException("Unable to determine groupId")
     if len(gId) != 0:
         raise PomLoadingException("Unexpected child nodes under groupId")
     return gId.text.strip()
Esempio n. 2
0
 def version(self):
     """
     Effective version of the pom Artifact taking into account parent
     version
     """
     version = POMReader.find(self.__doc, './pom:version')
     if version is None:
         version = POMReader.find(self.__doc, './pom:parent/pom:version')
     if version is None:
         raise PomLoadingException("Unable to determine artifact version")
     if len(version) != 0:
         raise PomLoadingException("Unexpected child nodes under version")
     return version.text.strip()
Esempio n. 3
0
 def pluginManagement(self):
     """
     List of plugins from plugin management section
     """
     xmlnodes = POMReader.xpath(
         self.__doc, './pom:pluginManagement/pom:plugins/pom:plugin')
     return [Plugin.from_xml_element(x) for x in xmlnodes]
Esempio n. 4
0
 def plugins(self):
     """
     List of artifact's plugins
     """
     xmlnodes = POMReader.xpath(self.__doc,
                                './pom:build/pom:plugins/pom:plugin')
     return [Plugin.from_xml_element(x) for x in xmlnodes]
Esempio n. 5
0
 def extensions(self):
     """
     List of artifact's extensions
     """
     xmlnodes = POMReader.xpath(self.__doc,
                                './pom:build/pom:extensions/pom:extension')
     return [Extension.from_xml_element(x) for x in xmlnodes]
Esempio n. 6
0
 def dependencies(self):
     """
     List of artifact's dependencies
     """
     xmlnodes = POMReader.xpath(self.__doc,
                                './pom:dependencies/pom:dependency')
     return [Dependency.from_xml_element(x) for x in xmlnodes]
Esempio n. 7
0
 def version(self):
     version = POMReader.find(self.__doc, '/ivy-module/info')
     if version is not None:
         try:
             version = version.attrib["revision"]
         except KeyError:
             raise PomLoadingException("Unable to determine version")
     return version
Esempio n. 8
0
 def artifactId(self):
     aId = POMReader.find(self.__doc, '/ivy-module/info')
     if aId is not None:
         try:
             aId = aId.attrib["module"]
         except KeyError:
             raise PomLoadingException("Unable to determine artifactId")
     return aId
Esempio n. 9
0
 def parentVersion(self):
     """
     version of the parent artifact or None
     """
     ver = POMReader.find(self.__doc, './pom:parent/pom:version')
     if ver is None:
         return None
     return ver.text.strip()
Esempio n. 10
0
 def parentGroupId(self):
     """
     groupId of the parent artifact or None
     """
     gId = POMReader.find(self.__doc, './pom:parent/pom:groupId')
     if gId is None:
         return None
     return gId.text.strip()
Esempio n. 11
0
 def parentArtifactId(self):
     """
     artifactId of the parent artifact or None
     """
     aId = POMReader.find(self.__doc, './pom:parent/pom:artifactId')
     if aId is None:
         return None
     return aId.text.strip()
Esempio n. 12
0
 def dependencyManagement(self):
     """
     List of dependencies from dependency management section
     """
     xmlnodes = POMReader.xpath(
         self.__doc,
         './pom:dependencyManagement/pom:dependencies/pom:dependency')
     return [Dependency.from_xml_element(x) for x in xmlnodes]
Esempio n. 13
0
 def groupId(self):
     gId = POMReader.find(self.__doc, '/ivy-module/info')
     if gId is not None:
         try:
             gId = gId.attrib["organisation"]
         except:
             raise PomLoadingException("Unable to determine groupId")
     return gId
Esempio n. 14
0
    def parent(self):
        aId = POMReader.find(self.__doc, './pom:parent/pom:artifactId')
        if aId is None:
            return None
        aId = aId.text

        gId = POMReader.find(self.__doc, './pom:parent/pom:groupId')
        if gId is not None:
            gId = gId.text

        ver = POMReader.find(self.__doc, './pom:parent/pom:version')
        if ver is not None:
            ver = ver.text

        relativePath = POMReader.find(self.__doc,
                                      './pom:parent/pom:relativePath')
        if relativePath is not None:
            relativePath = relativePath.text

        return ParentPOM(gId, aId, ver, relativePath)
Esempio n. 15
0
 def artifactId(self):
     """
     Effective artifactId of the pom Artifact
     """
     aId = POMReader.find(self.__doc, './pom:artifactId')
     if aId is None:
         raise PomLoadingException("Unable to determine artifactId")
     if len(aId) != 0:
         raise PomLoadingException(
             "Unexpected child nodes under artifactId")
     return aId.text.strip()
Esempio n. 16
0
 def packaging(self):
     """
     Packaging type of artifact or None if unspecified
     """
     packaging = POMReader.find(self.__doc, './pom:packaging')
     if packaging is None:
         # use default packaging type
         return "jar"
     if len(packaging) != 0:
         raise PomLoadingException("Unexpected child nodes under packaging")
     return packaging.text.strip()
Esempio n. 17
0
    def from_xml_element(cls, xmlnode):
        """
        Create Plugin from xml.etree.ElementTree.Element as contained
        within pom.xml.
        """

        parts = {'groupId': '', 'artifactId': '', 'version': ''}
        parts = POMReader.find_parts(xmlnode, parts)

        if not parts['artifactId']:
            raise ArtifactFormatException("Empty artifactId encountered. "
                                          "This is a bug, please report it!")

        # dependencies
        depnodes = POMReader.xpath(xmlnode, "./dependencies/dependency")

        deps = []
        for d in [Dependency.from_xml_element(x) for x in depnodes]:
            deps.append(d)

        return cls(parts['groupId'], parts['artifactId'], parts['version'],
                   deps)
Esempio n. 18
0
    def from_xml_element(cls, xmlnode):
        """
        Create Extension from xml.etree.ElementTree.Element as contained
        within pom.xml.
        """

        parts = {'groupId': '', 'artifactId': '', 'version': ''}
        parts = POMReader.find_parts(xmlnode, parts)

        if not parts['groupId'] or not parts['artifactId']:
            raise ArtifactFormatException(
                "Empty groupId or artifactId encountered. "
                "This is a bug, please report it!")

        return cls(parts['groupId'], parts['artifactId'], parts['version'])
Esempio n. 19
0
    def properties(self):
        """
        Dictionary consisting of properties specified in pom.xml
        """
        properties = {}
        xmlnodes = POMReader.find(self.__doc, './pom:properties')
        if xmlnodes is None:
            return properties
        propnodes = xmlnodes.getchildren()
        for node in propnodes:
            if node.tag.startswith('{'):
                tag = node.tag[node.tag.find('}') + 1:]
            else:
                tag = node.tag
            properties[tag] = node.text

        return properties
Esempio n. 20
0
    def from_xml_element(cls, xmlnode):
        """
        Create Dependency from xml.etree.ElementTree.Element as contained
        within pom.xml.
        """

        parts = {'groupId': '',
                 'artifactId': '',
                 'type': '',
                 'classifier': '',
                 'version': '',
                 'scope': '',
                 'optional': ''}

        parts = POMReader.find_parts(xmlnode, parts)

        if not parts['groupId'] or not parts['artifactId']:
            raise ArtifactFormatException(
                "Empty groupId or artifactId encountered. "
                "This is a bug, please report it!")

        # exclusions
        excnodes = xmlnode.findall("{*}exclusions/{*}exclusion")

        exclusions = set()
        for e in [Exclusion.from_xml_element(x) for x in excnodes]:
            exclusions.add(e)

        return cls(parts['groupId'],
                   parts['artifactId'],
                   extension=parts['type'],
                   classifier=parts['classifier'],
                   version=parts['version'],
                   scope=parts['scope'],
                   optional=parts['optional'],
                   exclusions=exclusions)
Esempio n. 21
0
 def __init__(self, path):
     self.__doc = POMReader.load(path)
     self._path = os.path.join(path)