示例#1
0
def testGetId():
    XPaths = [('dependencies',[('dependency',[('artifactId',None),('groupId',None)])])]
    
    newP2 = Pom()
    pomDoc = minidom.parse('pom.xml')
    id = newP2.getId(pomDoc.firstChild, XPaths)
    
    print id
示例#2
0
def testAddDependencies():
    newP2 = Pom('pom.xml')
    impl = minidom.getDOMImplementation()
    pomDoc = impl.createDocument('http://maven.apache.org/POM/4.0.0', 'project',None)
    deps = []
    
    e1 = pomDoc.createElement('dependency')
    e12 = pomDoc.createElement('groupId')
    et12 = pomDoc.createTextNode('bu')
    e12.childNodes.append(et12)
    e1.childNodes.append(e12)
    e13 = pomDoc.createElement('artifactId')
    et13 = pomDoc.createTextNode('ba')
    e13.childNodes.append(et13)
    e1.childNodes.append(e13)
    deps.append(e1)
    
    newP2.addDependencies(deps)

    print newP2.toxml()
示例#3
0
def modularize(pomPath, newModuleName):
    #create new directory
    os.mkdir(pomPath+'/'+newModuleName)
    #copy everything but the pom
    for f in os.listdir(pomPath) :
        if f != 'pom.xml' and f != newModuleName:
            shutil.copytree(pomPath + '/' + f, pomPath + '/' + newModuleName + '/' + f)
    #create the new pom
    #merge plugins and dependencies
    pm = Pom()
    pmOrig = Pom(pomPath+'/pom.xml')
    head = pmOrig.getHead()
    pm.provideHead(head['groupId'] + '.' + head['artifactId'],newModuleName, head['version'], head['name'], head['packaging'], head['url'])
    pm.addPlugins(pmOrig.getPlugins())
    pm.addDependencies(pmOrig.getDependencies())
    pm.writeOut(pomPath + '/' + newModuleName + '/pom.xml')
    #change header of supoerpom and add modules
    pmOrig.provideHead(head['groupId'], head['artifactId'], head['version'], head['name'], 'pom', head['url'])
    newModule = pmOrig.buildModule(newModuleName)
    pmOrig.addModules([newModule])
    pmOrig.writeOut()
    pass
示例#4
0
def testMerge():
    newP3 = Pom('pom.xml')
    newModule = newP3.buildModule('myModule')
    newP3.addModules([newModule])
    newP3.writeOut()
示例#5
0
    e1.childNodes.append(e13)
    deps.append(e1)
    
    newP2.addDependencies(deps)

    print newP2.toxml()

def testMerge():
    newP3 = Pom('pom.xml')
    newModule = newP3.buildModule('myModule')
    newP3.addModules([newModule])
    newP3.writeOut()

if __name__ == '__main__':
    
    newP = Pom()
    st = newP.toxml()
    assert (st.count(expected) == 1)
    
    #set the header
    newP.provideHead('org.twitterNotifier', 'twitterNotifier', '0.1-SNAPSHOT','','','')
    st = newP.toxml()
    
    assert(st.count('org.twitterNotifier') > 0)
    assert(st.count('0.1-SNAPSHOT') > 0)
    assert(st.count('4.0.0') > 0)
    
    #reset the header
    newP.provideHead('org.whateverelse', 'whateverelse', '1.0','','','')
    st = newP.toxml()
    #print(st)