示例#1
0
def test_dependencies():
    pom = Pom('org.eclipse.birt.core-2.6.2.pom')

    eq_('/project/dependencies', xmlPath(pom.project.dependencies))
    eq_(
        '[org.eclipse.core:org.eclipse.core.runtime:[3.2.0,4.0.0), org.mozilla.javascript:org.mozilla.javascript:[1.6.0,2.0.0), com.ibm.icu:com.ibm.icu:[4.2.1,5.0.0)]',
        repr(pom.dependencies()))
    def analyzePOM(self, pomFile):
        pom = Pom(pomFile)
        self.pomFiles.append(pom)
        log.debug('Analyzing %s %s' % (pomFile, pom.key()))

        shortKey = pom.shortKey()
        other = self.pomByKey.get(shortKey, None)
        if other is not None:
            self.newProblem(ProblemSameKeyDifferentVersion(pom, other))
        self.pomByKey[shortKey] = pom

        for d in pom.dependencies():
            key = d.groupId + ":" + d.artifactId
            dependencies = self.dependencies.setdefault(key, [])
            dependencies.append(pom)

            if not d.version or d.version == '[0,)':
                self.newProblem(ProblemWithDependency(pom, d))

            versions = self.versions.setdefault(key, set())
            versions.add(d.version)

            versionBackRefs = self.versionBackRefs.setdefault(key, {})
            backRefs = versionBackRefs.setdefault(d.version, [])
            backRefs.append(pom)
    def analyzePOM(self, pomFile):
        pom = Pom(pomFile)
        self.pomFiles.append( pom )
        log.debug('Analyzing %s %s' % (pomFile, pom.key()))
        
        shortKey = pom.shortKey()
        other = self.pomByKey.get(shortKey, None)
        if other is not None:
            self.newProblem(ProblemSameKeyDifferentVersion(pom, other))
        self.pomByKey[shortKey] = pom
        
        for d in pom.dependencies():
            key = d.groupId + ":" + d.artifactId
            dependencies = self.dependencies.setdefault(key, [])
            dependencies.append( pom )
            
            if not d.version or d.version == '[0,)':
                self.newProblem(ProblemWithDependency(pom, d))
            
            versions = self.versions.setdefault(key, set())
            versions.add( d.version )

            versionBackRefs = self.versionBackRefs.setdefault(key, {})
            backRefs = versionBackRefs.setdefault(d.version, [])
            backRefs.append( pom )
示例#4
0
    def applyPatches(self, pomFile):
        pom = Pom(pomFile)

        before = repr(pom)
        self.patchTool.apply(pom)
        after = repr(pom)

        if before == after:
            log.debug('No changes in %s' % pomFile)
            return

        log.info('Patching %s' % pomFile)
        pom.save()
 def applyPatches(self, pomFile):
     pom = Pom(pomFile)
     
     before = repr(pom)
     self.patchTool.apply(pom)
     after = repr(pom)
     
     if before == after:
         log.debug('No changes in %s' % pomFile)
         return
     
     log.info('Patching %s' % pomFile)
     pom.save()
示例#6
0
def test_removeNonOptional():
    pom = Pom('org.eclipse.birt.core-2.6.2.pom')

    tool = RemoveNonOptional()
    tool.run(pom)

    expected = 'withoutNonOptional.pom'
    tmp = '../tmp/%s' % expected
    pom.save(tmp)

    pos = repr(pom).find('<optional>false</optional>')
    eq_(-1, pos, 'POM still contains non-optional elements')

    compareFiles(expected, tmp)
def test_removeNonOptional():
    pom = Pom('org.eclipse.birt.core-2.6.2.pom')
    
    tool = RemoveNonOptional()
    tool.run(pom)
    
    expected = 'withoutNonOptional.pom'
    tmp = '../tmp/%s' % expected
    pom.save(tmp)

    pos = repr(pom).find('<optional>false</optional>')
    eq_(-1, pos, 'POM still contains non-optional elements')
    
    compareFiles(expected, tmp)
示例#8
0
def test_stripQualifier():
    pom = Pom('org.eclipse.persistence.moxy-2.1.2.pom')

    StripQualifiers().run(pom)
    with open('org.eclipse.persistence.moxy-2.1.2.fixed') as fh:
        expected = fh.read()

    compareStrings(expected, repr(pom))
def test_ApplyPatches():
    
    loader = PatchLoader('../patches')
    loader.addRemoveNonOptional()
    loader.run()
    
    eq_('[RemoveNonOptional(), PatchSet(../patches/eclipse-3.6.2.patches), StripQualifiers()]', repr(loader.patches))
    
    pom = Pom('org.eclipse.birt.core-2.6.2.pom')
    
    tool = PatchTool(loader.patches)
    tool.apply(pom)
    
    expected = 'patchedPom.pom'
    tmp = '../tmp/%s' % expected
    pom.save(tmp)

    compareFiles(expected, tmp)
    def processPom(self, path):
        log.debug('Reading %s' % (path, ))
        pom = Pom(path)

        dep = etree.SubElement(self.dependencies, POM_NS_PREFIX + 'dependency')

        setOptionalText(dep, 'groupId', pom.project.groupId.text)
        setOptionalText(dep, 'artifactId', pom.project.artifactId.text)
        setOptionalText(dep, 'version', pom.project.version.text)
示例#11
0
def test_PomReader():
    reader = Pom('org.eclipse.birt.core-2.6.2.pom')

    eq_(types.StringType, type(reader.xml.getroot().tag))
    eq_('{http://maven.apache.org/POM/4.0.0}project', reader.xml.getroot().tag)
    eq_([], reader.xml.getroot().xpath('version'))

    eq_('/project', xmlPath(reader.project))
    eq_('/project/version', xmlPath(reader.project.version))
    eq_('2.6.2', reader.project.version.text)
示例#12
0
def test_ApplyPatches():

    loader = PatchLoader('../patches')
    loader.addRemoveNonOptional()
    loader.run()

    eq_(
        '[RemoveNonOptional(), PatchSet(../patches/eclipse-3.6.2.patches), StripQualifiers()]',
        repr(loader.patches))

    pom = Pom('org.eclipse.birt.core-2.6.2.pom')

    tool = PatchTool(loader.patches)
    tool.apply(pom)

    expected = 'patchedPom.pom'
    tmp = '../tmp/%s' % expected
    pom.save(tmp)

    compareFiles(expected, tmp)
示例#13
0
def test_patchScope_3():
    pom = Pom(StringIO.StringIO(POM_WITH_JAVASCRIPT_DEPENDENCY))

    op = ReplaceDependency(
        'org.mozilla.javascript:org.mozilla.javascript:[1.6.0,2.0.0)',
        'rhino:js:1.7R2:scope=test:optional=false')
    tool = DependencyPatcher('m4e.orbit', 'm4e.maven-central', [op], [])

    tool.run(pom)

    expected = POM_WITH_RHINO_DEPENDENCY.replace(
        '${opt}', '          <scope>test</scope>')
    compareStrings(expected, repr(pom))
示例#14
0
def test_patchDelete():
    pom = Pom(StringIO.StringIO(POM_WITH_JAVASCRIPT_DEPENDENCY))

    op = DeleteDependency(
        'org.mozilla.javascript:org.mozilla.javascript:[1.6.0,2.0.0)')
    tool = DependencyPatcher(None, None, [], [op])

    tool.run(pom)

    print repr(pom)
    compareStrings(
        '''<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <dependencies/>
</project>
''', repr(pom))
示例#15
0
def test_noDependencies():
    xml = '<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"></project>'
    pom = Pom(StringIO.StringIO(xml))

    eq_([], pom.dependencies())
def test_noDependencies():
    xml = '<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"></project>'
    pom = Pom(StringIO.StringIO(xml))
    
    eq_([], pom.dependencies())
def test_dependencies():
    pom = Pom('org.eclipse.birt.core-2.6.2.pom')
    
    eq_('/project/dependencies', xmlPath(pom.project.dependencies))
    eq_('[org.eclipse.core:org.eclipse.core.runtime:[3.2.0,4.0.0), org.mozilla.javascript:org.mozilla.javascript:[1.6.0,2.0.0), com.ibm.icu:com.ibm.icu:[4.2.1,5.0.0)]', repr(pom.dependencies()))