def checkgoodpom(path, group="org.codehaus.mojo", artifact="simplest", version="1.0", packaging="jar"): p = maven.parse(path) eq_(group, p._groupId) eq_(artifact, p._artifactId) eq_(version, p._version) eq_(packaging, p._packaging) return p
def test_localrepo(): reso = maven.Resolver() reso.addlocalrepo('test/repo') reso.addpom(maven.parse('test/goodpoms/basic/simplestuser.xml')) reso.resolve() resolved = reso[('org.codehaus.mojo', 'simplestuser', 'jar', '1.0')] eq_(set(), resolved.missing) eq_([("org.codehaus.mojo", "simplest", "jar", "1.0")], [dep.versioned for dep in resolved.dependencies.values()])
def test_updatedep(): reso = createreso() resolved = reso[('org.codehaus.mojo', 'setfields', 'swc', '1.0')] initialdepcount = len(reso) eq_(0, len(resolved.dependencies)) reso.addpom(maven.parse('test/goodpoms/setfields_with_dep.xml')) resolved = reso[('org.codehaus.mojo', 'setfields', 'swc', '1.0')] eq_(("org.codehaus.mojo", "simplest", "jar", "1.0"), resolved.dependencies.values()[0].versioned) eq_(initialdepcount, len(reso))
def _addrootsaction(self, roots): print "Adding roots", [os.path.abspath(root) for root in roots] # TODO only count as a newpom if it's not already present newpoms = [] for root in roots: for fn in maven.findpoms(os.path.abspath(root)): print "Adding pom", fn newpoms.append(maven.parse(fn)) # TODO add roots to watchdog for newpom in newpoms: newpom.srcclasses = [classloc for root in newpom.srcdirs for classloc in get_classes_in_root(root)] newpom.testclasses = [classloc for root in newpom.testsrcdirs for classloc in get_classes_in_root(root)] with self.modlock: for newpom in newpoms: self.resolver.addpom(newpom) self.resolver.resolve()
def checkbadpom(path): maven.parse(path)
def test_standalonelib(): parsed = maven.parse("test/javaproject/live/base/pom.xml") classlocs = list(nav.get_classes(parsed, test=True)) eq_(1, len(classlocs)) eq_("jproj.base.Main", classlocs[0].classname) eq_(os.path.abspath("test/javaproject/live/base/src/main/java/jproj/base/Main.java"), classlocs[0].path)
def createreso(base="test/goodpoms/basic"): reso = maven.Resolver() for fn in maven.findpoms(base): reso.addpom(maven.parse(fn)) return reso
def pom_visitor(poms, dirname, names): if 'pom.xml' in names: pom = '%s/pom.xml' % dirname poms.append(maven.parse(pom))