@Test public void testMvnParser() throws Exception { Map<String, String> coordinates = parseMvnUrl("mvn:foo/bar/1.0"); Assert.assertEquals("foo", coordinates.get("groupId")); Assert.assertEquals("bar", coordinates.get("artifactId")); Assert.assertEquals("1.0", coordinates.get("version")); Assert.assertEquals("jar", coordinates.get("extension")); coordinates = parseMvnUrl("mvn:otherg/othera/2.0/xml"); Assert.assertEquals("otherg", coordinates.get("groupId")); Assert.assertEquals("othera", coordinates.get("artifactId")); Assert.assertEquals("2.0", coordinates.get("version")); Assert.assertEquals("xml", coordinates.get("extension")); coordinates = parseMvnUrl("mvn:thirdg/thirda/3.0/zip/myclassifier"); Assert.assertEquals("thirdg", coordinates.get("groupId")); Assert.assertEquals("thirda", coordinates.get("artifactId")); Assert.assertEquals("3.0", coordinates.get("version")); Assert.assertEquals("zip", coordinates.get("extension")); Assert.assertEquals("myclassifier", coordinates.get("classifier")); }
protected static Map<String, String> parseMvnUrl(String artifactUrl) { Matcher matcher = mvnPattern.matcher(artifactUrl); if (!matcher.matches()) { return null; } Map<String, String> result = new HashMap<>(); result.put("groupId", matcher.group(1)); result.put("artifactId", matcher.group(2)); result.put("version", matcher.group(3)); if (matcher.group(5) == null) { result.put("extension", "jar"); } else { result.put("extension", matcher.group(5)); } result.put("classifier", matcher.group(7)); return result; }
RepositoryServiceImpl implements RepositoryService { protected static Map<String, String> parseMvnUrl(String artifactUrl) { Matcher matcher = mvnPattern.matcher(artifactUrl); if (!matcher.matches()) { return null; } Map<String, String> result = new HashMap<>(); result.put("groupId", matcher.group(1)); result.put("artifactId", matcher.group(2)); result.put("version", matcher.group(3)); if (matcher.group(5) == null) { result.put("extension", "jar"); } else { result.put("extension", matcher.group(5)); } result.put("classifier", matcher.group(7)); return result; } }
RepositoryServiceImpl implements RepositoryService { protected static Map<String, String> parseMvnUrl(String artifactUrl) { Matcher matcher = mvnPattern.matcher(artifactUrl); if (!matcher.matches()) { return null; } Map<String, String> result = new HashMap<>(); result.put("groupId", matcher.group(1)); result.put("artifactId", matcher.group(2)); result.put("version", matcher.group(3)); if (matcher.group(5) == null) { result.put("extension", "jar"); } else { result.put("extension", matcher.group(5)); } result.put("classifier", matcher.group(7)); return result; }  }
RepositoryServiceImpl implements RepositoryService { protected static Map<String, String> parseMvnUrl(String artifactUrl) { Matcher matcher = mvnPattern.matcher(artifactUrl); if (!matcher.matches()) { return null; } Map<String, String> result = new HashMap<>(); result.put("groupId", matcher.group(1)); result.put("artifactId", matcher.group(2)); result.put("version", matcher.group(3)); if (matcher.group(5) == null) { result.put("extension", "jar"); } else { result.put("extension", matcher.group(5)); } result.put("classifier", matcher.group(7)); return result; }  @Activate void activate(ComponentContext componentContext); @Deactivate void deactivate(ComponentContext componentContext); @Override Repository create(String name); @Override Repository create(String name, String location); @Override Repository create(String name, String location, String proxy); @Override Repository create(String name, String location, String proxy, boolean mirror); @Override Repository create(String name, String location, String url, String proxy, boolean mirror, String realm, String downloadRole, String uploadRole, String scheduling, String schedulingAction, int poolSize); @Override void changeLocation(String name, String location); @Override void changeUrl(String name, String url); @Override void changeProxy(String name, String proxy, boolean mirror); @Override void changeSecurity(String name, String realm, String downloadRole, String uploadRole); @Override void changeScheduling(String name, String scheduling, String schedulingAction); @Override void copy(String sourceRepositoryName, String destinationRepositoryName); @Override void remove(String name); @Override void remove(String name, boolean storageCleanup); @Override void purge(String name); @Override synchronized Collection<Repository> repositories(); @Override synchronized Repository repository(String name); @Override void addArtifact(String artifactUrl, String name); @Override void addArtifact(String artifactUrl, String groupId, String artifactId, String version, String type, String classifier, String name); @Override void deleteArtifact(String artifactUrl, String name); @Override void deleteArtifact(String groupId, String artifactId, String version, String type, String classifier, String name); @Override void updateBundleRepositoryDescriptor(String name); }
RepositoryServiceImpl implements RepositoryService { protected static Map<String, String> parseMvnUrl(String artifactUrl) { Matcher matcher = mvnPattern.matcher(artifactUrl); if (!matcher.matches()) { return null; } Map<String, String> result = new HashMap<>(); result.put("groupId", matcher.group(1)); result.put("artifactId", matcher.group(2)); result.put("version", matcher.group(3)); if (matcher.group(5) == null) { result.put("extension", "jar"); } else { result.put("extension", matcher.group(5)); } result.put("classifier", matcher.group(7)); return result; }  @Activate void activate(ComponentContext componentContext); @Deactivate void deactivate(ComponentContext componentContext); @Override Repository create(String name); @Override Repository create(String name, String location); @Override Repository create(String name, String location, String proxy); @Override Repository create(String name, String location, String proxy, boolean mirror); @Override Repository create(String name, String location, String url, String proxy, boolean mirror, String realm, String downloadRole, String uploadRole, String scheduling, String schedulingAction, int poolSize); @Override void changeLocation(String name, String location); @Override void changeUrl(String name, String url); @Override void changeProxy(String name, String proxy, boolean mirror); @Override void changeSecurity(String name, String realm, String downloadRole, String uploadRole); @Override void changeScheduling(String name, String scheduling, String schedulingAction); @Override void copy(String sourceRepositoryName, String destinationRepositoryName); @Override void remove(String name); @Override void remove(String name, boolean storageCleanup); @Override void purge(String name); @Override synchronized Collection<Repository> repositories(); @Override synchronized Repository repository(String name); @Override void addArtifact(String artifactUrl, String name); @Override void addArtifact(String artifactUrl, String groupId, String artifactId, String version, String type, String classifier, String name); @Override void deleteArtifact(String artifactUrl, String name); @Override void deleteArtifact(String groupId, String artifactId, String version, String type, String classifier, String name); @Override void updateBundleRepositoryDescriptor(String name);  }