Exemple #1
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
def testMerge():
    newP3 = Pom('pom.xml')
    newModule = newP3.buildModule('myModule')
    newP3.addModules([newModule])
    newP3.writeOut()