use of org.apache.karaf.util.maven.Parser in project karaf by apache.
the class KarServiceImpl method copyResourceToJar.
private void copyResourceToJar(JarOutputStream jos, URI location, Map<URI, Integer> locationMap) {
if (locationMap.containsKey(location)) {
return;
}
try {
String noPrefixLocation = location.toString().substring(location.toString().lastIndexOf(":") + 1);
Parser parser = new Parser(noPrefixLocation);
String path = "repository/" + parser.getArtifactPath();
jos.putNextEntry(new JarEntry(path));
try (InputStream is = location.toURL().openStream()) {
StreamUtils.copy(is, jos);
}
locationMap.put(location, 1);
} catch (Exception e) {
LOGGER.error("Error adding " + location, e);
}
}
use of org.apache.karaf.util.maven.Parser in project karaf by apache.
the class ParserTest method unparserTest.
@Test
public void unparserTest() throws MalformedURLException {
Parser p1 = new Parser("org.apache/karaf/1/xml/features");
assertThat(p1.toMvnURI(), equalTo("org.apache/karaf/1/xml/features"));
Parser p2 = new Parser("org.apache/karaf/1/xml");
assertThat(p2.toMvnURI(), equalTo("org.apache/karaf/1/xml"));
Parser p3 = new Parser("org.apache/karaf/1/jar/uber");
assertThat(p3.toMvnURI(), equalTo("org.apache/karaf/1/jar/uber"));
Parser p4 = new Parser("org.apache/karaf/1//uber");
assertThat(p4.toMvnURI(), equalTo("org.apache/karaf/1/jar/uber"));
Parser p5 = new Parser("org.apache/karaf/1/jar");
assertThat(p5.toMvnURI(), equalTo("org.apache/karaf/1"));
Parser p6 = new Parser("org.apache/karaf/1");
assertThat(p6.toMvnURI(), equalTo("org.apache/karaf/1"));
}
use of org.apache.karaf.util.maven.Parser in project karaf by apache.
the class FeaturesProcessorTest method mavenURIs.
@Test
public void mavenURIs() throws Exception {
Parser p = new Parser("group/artifact/[1,2)/xml/features*");
assertThat(p.getVersion(), equalTo("[1,2)"));
assertThat(p.getClassifier(), equalTo("features*"));
p = new Parser("org.springframework*/*cloud*/*");
assertThat(p.getVersion(), equalTo("*"));
assertThat(p.getArtifact(), equalTo("*cloud*"));
assertThat(p.getGroup(), equalTo("org.springframework*"));
assertThat(p.getType(), equalTo("jar"));
assertThat(p.getClassifier(), nullValue());
p = new Parser("org.ops4j/org.ops4j*/*//uber");
assertThat(p.getVersion(), equalTo("*"));
assertThat(p.getArtifact(), equalTo("org.ops4j*"));
assertThat(p.getGroup(), equalTo("org.ops4j"));
assertThat(p.getType(), equalTo("jar"));
assertThat(p.getClassifier(), equalTo("uber"));
}
Aggregations