use of aQute.bnd.maven.support.MavenRemoteRepository in project bnd by bndtools.
the class MavenTest method testMavenRepo.
/**
* See if we can create a maven repostory as a plugin
*
* @throws Exception
*/
public static void testMavenRepo() throws Exception {
Workspace ws = Workspace.getWorkspace(cwd.getParentFile());
Maven maven = ws.getMaven();
Processor processor = new Processor(ws);
processor.setProperty(Constants.PLUGIN, "aQute.bnd.maven.support.MavenRemoteRepository;repositories=testresources/ws/maven1/m2");
MavenRemoteRepository mr = processor.getPlugin(MavenRemoteRepository.class);
assertNotNull(mr);
assertEquals(maven, mr.getMaven());
// Cleanup the maven cache so we do not get random results
MavenEntry me = maven.getEntry("org.apache.commons", "com.springsource.org.apache.commons.beanutils", "1.6.1");
assertNotNull(me);
me.remove();
Map<String, String> map = MAP.$("groupId", "org.apache.commons");
File file = mr.get("com.springsource.org.apache.commons.beanutils", "1.6.1", Strategy.LOWEST, map);
assertNotNull(file);
assertEquals("com.springsource.org.apache.commons.beanutils-1.6.1.jar", file.getName());
assertTrue(file.isFile());
Map<String, String> map2 = MAP.$("groupId", "org.apache.commons").$("scope", "compile");
file = mr.get("com.springsource.org.apache.commons.beanutils", "1.6.1", Strategy.LOWEST, map2);
assertNotNull(file);
assertTrue(file.isFile());
assertEquals("compile.lib", file.getName());
String lib = IO.collect(file);
System.err.println(lib);
lib = lib.replaceAll("org.apache.commons\\+com.springsource.org.apache.commons.beanutils;version=\"1.6.1\"", "1");
lib = lib.replaceAll("org.apache.commons\\+com.springsource.org.apache.commons.collections;version=\"2.1.1\"", "2");
lib = lib.replaceAll("org.apache.commons\\+com.springsource.org.apache.commons.logging;version=\"1.0.4\"", "3");
assertEquals("1\n2\n3\n", lib);
}
use of aQute.bnd.maven.support.MavenRemoteRepository in project bnd by bndtools.
the class MavenTest method testMavenRepo1.
/**
* Test the maven remote repository
*/
public static void testMavenRepo1() throws Exception {
Maven maven = new Maven(null);
MavenRemoteRepository mr = new MavenRemoteRepository();
mr.setMaven(maven);
MavenEntry me = maven.getEntry("org.apache.commons", "com.springsource.org.apache.commons.beanutils", "1.6.1");
me.remove();
me = maven.getEntry("org.apache.commons", "com.springsource.org.apache.commons.collections", "2.1.1");
me.remove();
me = maven.getEntry("org.apache.commons", "com.springsource.org.apache.commons.logging", "1.0.4");
me.remove();
mr.setRepositories(new URI[] { IO.getFile(new File("").getAbsoluteFile(), "testresources/ws/maven1/m2").toURI() });
Map<String, String> map = new HashMap<String, String>();
map.put("scope", "compile");
File file = mr.get("org.apache.commons+com.springsource.org.apache.commons.beanutils", "1.6.1", Strategy.LOWEST, map);
assertNotNull(file);
assertTrue(file.isFile());
assertEquals("org.apache.commons+com.springsource.org.apache.commons.beanutils;version=\"1.6.1\"\n" + "org.apache.commons+com.springsource.org.apache.commons.collections;version=\"2.1.1\"\n" + "org.apache.commons+com.springsource.org.apache.commons.logging;version=\"1.0.4\"\n", IO.collect(file));
file = mr.get("org.apache.commons+com.springsource.org.apache.commons.beanutils", "1.6.1", Strategy.LOWEST, null);
assertEquals("com.springsource.org.apache.commons.beanutils-1.6.1.jar", file.getName());
}
Aggregations