class ApplyPatches(object): def run(self, patchDir, repoDir): log.info('Applying patches from %s to M2 repository in %s' % (patchDir, repoDir)) self.loadPatches(patchDir) self.process(repoDir) log.info('Done.') def loadPatches(self, path): loader = PatchLoader(path) loader.addRemoveNonOptional() loader.run() self.patchTool = PatchTool(loader.patches) def process(self, root): for name in os.listdir(root): path = os.path.join(root, name) if os.path.isdir(path): self.process(path) elif path.endswith('.pom'): self.applyPatches(path) 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 loadPatches(self, path): loader = PatchLoader(path) loader.addRemoveNonOptional() loader.run() self.patchTool = PatchTool(loader.patches)