You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by ff...@apache.org on 2010/10/14 14:36:44 UTC
svn commit: r1022490 - in /karaf/trunk/tooling/features-maven-plugin: ./
src/main/java/org/apache/karaf/tooling/features/
Author: ffang
Date: Thu Oct 14 12:36:44 2010
New Revision: 1022490
URL: http://svn.apache.org/viewvc?rev=1022490&view=rev
Log:
[KARAF-234]validate goal of features-maven-plugin should support spring/blueprint/feature protocol prefix
Added:
karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/BlueprintURLHandler.java
karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/CustomBundleURLStreamHandlerFactory.java
karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/FeatureURLHandler.java
karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/SpringURLHandler.java
Modified:
karaf/trunk/tooling/features-maven-plugin/pom.xml
karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ValidateFeaturesMojo.java
Modified: karaf/trunk/tooling/features-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/tooling/features-maven-plugin/pom.xml?rev=1022490&r1=1022489&r2=1022490&view=diff
==============================================================================
--- karaf/trunk/tooling/features-maven-plugin/pom.xml (original)
+++ karaf/trunk/tooling/features-maven-plugin/pom.xml Thu Oct 14 12:36:44 2010
@@ -61,6 +61,22 @@
<artifactId>pax-url-wrap</artifactId>
</dependency>
<dependency>
+ <groupId>org.ops4j.pax.url</groupId>
+ <artifactId>pax-url-mvn</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.deployer</groupId>
+ <artifactId>org.apache.karaf.deployer.spring</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.deployer</groupId>
+ <artifactId>org.apache.karaf.deployer.blueprint</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.deployer</groupId>
+ <artifactId>org.apache.karaf.deployer.features</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<scope>test</scope>
Added: karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/BlueprintURLHandler.java
URL: http://svn.apache.org/viewvc/karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/BlueprintURLHandler.java?rev=1022490&view=auto
==============================================================================
--- karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/BlueprintURLHandler.java (added)
+++ karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/BlueprintURLHandler.java Thu Oct 14 12:36:44 2010
@@ -0,0 +1,91 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.tooling.features;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.karaf.deployer.blueprint.BlueprintTransformer;
+
+/**
+ * As org.apache.karaf.deployer.blueprint.BlueprintURLHandler need run with OSGi container
+ * so create this class only used for features-maven-plugin
+ */
+public class BlueprintURLHandler extends URLStreamHandler {
+
+ private static Log logger = LogFactory.getLog(BlueprintURLHandler.class);
+
+ private static String SYNTAX = "blueprint: bp-xml-uri";
+
+ private URL blueprintXmlURL;
+
+ /**
+ * Open the connection for the given URL.
+ *
+ * @param url the url from which to open a connection.
+ * @return a connection on the specified URL.
+ * @throws IOException if an error occurs or if the URL is malformed.
+ */
+ @Override
+ public URLConnection openConnection(URL url) throws IOException {
+ if (url.getPath() == null || url.getPath().trim().length() == 0) {
+ throw new MalformedURLException ("Path can not be null or empty. Syntax: " + SYNTAX );
+ }
+ blueprintXmlURL = new URL(url.getPath());
+
+ logger.debug("Blueprint xml URL is: [" + blueprintXmlURL + "]");
+ return new Connection(url);
+ }
+
+ public URL getBlueprintXmlURL() {
+ return blueprintXmlURL;
+ }
+
+ public class Connection extends URLConnection {
+
+ public Connection(URL url) {
+ super(url);
+ }
+
+ @Override
+ public void connect() throws IOException {
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ try {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ BlueprintTransformer.transform(blueprintXmlURL, os);
+ os.close();
+ return new ByteArrayInputStream(os.toByteArray());
+ } catch (Exception e) {
+ logger.error("Error opening blueprint xml url", e);
+ throw (IOException) new IOException("Error opening blueprint xml url").initCause(e);
+ }
+ }
+ }
+
+}
Added: karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/CustomBundleURLStreamHandlerFactory.java
URL: http://svn.apache.org/viewvc/karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/CustomBundleURLStreamHandlerFactory.java?rev=1022490&view=auto
==============================================================================
--- karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/CustomBundleURLStreamHandlerFactory.java (added)
+++ karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/CustomBundleURLStreamHandlerFactory.java Thu Oct 14 12:36:44 2010
@@ -0,0 +1,47 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.tooling.features;
+
+import java.net.URLStreamHandler;
+import java.net.URLStreamHandlerFactory;
+
+public class CustomBundleURLStreamHandlerFactory implements
+ URLStreamHandlerFactory {
+ private static final String MVN_URI_PREFIX = "mvn";
+ private static final String WRAP_URI_PREFIX = "wrap";
+ private static final String FEATURE_URI_PREFIX = "feature";
+ private static final String SPRING_URI_PREFIX = "spring";
+ private static final String BLUEPRINT_URI_PREFIX = "blueprint";
+
+ public URLStreamHandler createURLStreamHandler(String protocol) {
+ if (protocol.equals(MVN_URI_PREFIX)) {
+ return new org.ops4j.pax.url.mvn.Handler();
+ } else if (protocol.equals(WRAP_URI_PREFIX)){
+ return new org.ops4j.pax.url.wrap.Handler();
+ } else if (protocol.equals(FEATURE_URI_PREFIX)){
+ return new FeatureURLHandler();
+ } else if (protocol.equals(SPRING_URI_PREFIX)){
+ return new SpringURLHandler();
+ } else if (protocol.equals(BLUEPRINT_URI_PREFIX)){
+ return new BlueprintURLHandler();
+ } else {
+ return null;
+ }
+ }
+
+}
Added: karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/FeatureURLHandler.java
URL: http://svn.apache.org/viewvc/karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/FeatureURLHandler.java?rev=1022490&view=auto
==============================================================================
--- karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/FeatureURLHandler.java (added)
+++ karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/FeatureURLHandler.java Thu Oct 14 12:36:44 2010
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.tooling.features;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.karaf.deployer.features.FeatureTransformer;
+
+
+/**
+ * As org.apache.karaf.deployer.features.FeatureURLHandler need run with OSGi container
+ * so create this class only used for features-maven-plugin
+ */
+public class FeatureURLHandler extends URLStreamHandler {
+
+ private static Log logger = LogFactory.getLog(FeatureURLHandler.class);
+
+ private static String SYNTAX = "feature: xml-uri";
+
+ private URL featureXmlURL;
+
+ /**
+ * Open the connection for the given URL.
+ *
+ * @param url the url from which to open a connection.
+ * @return a connection on the specified URL.
+ * @throws java.io.IOException if an error occurs or if the URL is malformed.
+ */
+ @Override
+ public URLConnection openConnection(URL url) throws IOException {
+ if (url.getPath() == null || url.getPath().trim().length() == 0) {
+ throw new MalformedURLException("Path can not be null or empty. Syntax: " + SYNTAX );
+ }
+ featureXmlURL = new URL(url.getPath());
+
+ logger.debug("Blueprint xml URL is: [" + featureXmlURL + "]");
+ return new Connection(url);
+ }
+
+ public URL getFeatureXmlURL() {
+ return featureXmlURL;
+ }
+
+ public class Connection extends URLConnection {
+
+ public Connection(URL url) {
+ super(url);
+ }
+
+ @Override
+ public void connect() throws IOException {
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ try {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ FeatureTransformer.transform(featureXmlURL, os);
+ os.close();
+ return new ByteArrayInputStream(os.toByteArray());
+ } catch (Exception e) {
+ logger.error("Error opening blueprint xml url", e);
+ throw (IOException) new IOException("Error opening blueprint xml url").initCause(e);
+ }
+ }
+ }
+
+
+}
Added: karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/SpringURLHandler.java
URL: http://svn.apache.org/viewvc/karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/SpringURLHandler.java?rev=1022490&view=auto
==============================================================================
--- karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/SpringURLHandler.java (added)
+++ karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/SpringURLHandler.java Thu Oct 14 12:36:44 2010
@@ -0,0 +1,91 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.tooling.features;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.karaf.deployer.spring.SpringTransformer;
+
+/**
+ * As org.apache.karaf.deployer.spring.SpringURLHandler need run with OSGi container
+ * so create this class only used for features-maven-plugin
+ */
+public class SpringURLHandler extends URLStreamHandler {
+
+ private static Log logger = LogFactory.getLog(SpringURLHandler.class);
+
+ private static String SYNTAX = "spring: spring-xml-uri";
+
+ private URL springXmlURL;
+
+ /**
+ * Open the connection for the given URL.
+ *
+ * @param url the url from which to open a connection.
+ * @return a connection on the specified URL.
+ * @throws IOException if an error occurs or if the URL is malformed.
+ */
+ @Override
+ public URLConnection openConnection(URL url) throws IOException {
+ if (url.getPath() == null || url.getPath().trim().length() == 0) {
+ throw new MalformedURLException ("Path can not be null or empty. Syntax: " + SYNTAX );
+ }
+ springXmlURL = new URL(url.getPath());
+
+ logger.debug("Spring xml URL is: [" + springXmlURL + "]");
+ return new Connection(url);
+ }
+
+ public URL getSpringXmlURL() {
+ return springXmlURL;
+ }
+
+ public class Connection extends URLConnection {
+
+ public Connection(URL url) {
+ super(url);
+ }
+
+ @Override
+ public void connect() throws IOException {
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ try {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ SpringTransformer.transform(springXmlURL, os);
+ os.close();
+ return new ByteArrayInputStream(os.toByteArray());
+ } catch (Exception e) {
+ logger.error("Error opening spring xml url", e);
+ throw (IOException) new IOException("Error opening spring xml url").initCause(e);
+ }
+ }
+ }
+
+}
Modified: karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ValidateFeaturesMojo.java
URL: http://svn.apache.org/viewvc/karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ValidateFeaturesMojo.java?rev=1022490&r1=1022489&r2=1022490&view=diff
==============================================================================
--- karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ValidateFeaturesMojo.java (original)
+++ karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ValidateFeaturesMojo.java Thu Oct 14 12:36:44 2010
@@ -48,7 +48,6 @@ import org.apache.maven.plugin.MojoFailu
import org.apache.maven.shared.dependency.tree.DependencyNode;
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;
-import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
/**
@@ -65,7 +64,6 @@ import org.osgi.framework.Constants;
public class ValidateFeaturesMojo extends MojoSupport {
private static final String MVN_URI_PREFIX = "mvn:";
- private static final String WRAP_URI_PREFIX = "wrap:";
private static final String MVN_REPO_SEPARATOR = "!";
/**
@@ -103,16 +101,23 @@ public class ValidateFeaturesMojo extend
* @parameter
*/
private List<String> repositories;
+
+ /**
+ * skip non maven protocols or not skip
+ * @parameter default-value="false"
+ */
+ private boolean skipNonMavenProtocols = false;
/*
- * A map to cache the mvn: uris and the artifacts that correspond with them
+ * A map to cache the mvn: uris and the artifacts that correspond with them if it's mvn protocol
+ * or just uris itself if it's non mvn protocol
*/
- private Map<String, Artifact> bundles = new HashMap<String, Artifact>();
+ private Map<String, Object> bundles = new HashMap<String, Object>();
/*
* A map to cache manifests that have been extracted from the bundles
*/
- private Map<Artifact, Manifest> manifests = new HashMap<Artifact, Manifest>();
+ private Map<Object, Manifest> manifests = new HashMap<Object, Manifest>();
/*
* The list of features, includes both the features to be validated and the features from included <repository>s
@@ -150,6 +155,7 @@ public class ValidateFeaturesMojo extend
*/
private void prepare() throws Exception {
info("== Preparing for validation ==");
+ URL.setURLStreamHandlerFactory(new CustomBundleURLStreamHandlerFactory());
info(" - getting list of system bundle exports");
readSystemPackages();
info(" - getting list of provided bundle exports");
@@ -177,7 +183,7 @@ public class ValidateFeaturesMojo extend
}
for (URI uri : repository.getRepositories()) {
- Artifact artifact = resolve(uri.toString());
+ Artifact artifact = (Artifact) resolve(uri.toString());
Repository dependency = new RepositoryImpl(new File(localRepo.getBasedir(), localRepo.pathOf(artifact)).toURI());
getLog().info(String.format(" - adding %d known features from %s", dependency.getFeatures().length, uri));
features.add(dependency.getFeatures());
@@ -275,7 +281,7 @@ public class ValidateFeaturesMojo extend
for (Feature feature : repository.getFeatures()) {
Set<Clause> exports = new HashSet<Clause>();
for (String bundle : getBundleLocations(feature)) {
- exports.addAll(getExports(getManifest(bundle, bundles.get(bundle))));
+ exports.addAll(getExports(getManifest(bundle, bundles.get(bundle))));
}
info(" scanning feature %s for exports", feature.getName());
featureExports.put(feature.getName(), exports);
@@ -288,8 +294,11 @@ public class ValidateFeaturesMojo extend
private void validateBundlesAvailable(Repository repository) throws Exception {
for (Feature feature : repository.getFeatures()) {
for (String bundle : getBundleLocations(feature)) {
+ if (!isMavenProtocol(bundle) && skipNonMavenProtocols) {
+ continue;
+ }
// this will throw an exception if the artifact can not be resolved
- final Artifact artifact = resolve(bundle);
+ final Object artifact = resolve(bundle);
bundles.put(bundle, artifact);
if (isBundle(bundle, artifact)) {
manifests.put(artifact, getManifest(bundle, artifact));
@@ -384,8 +393,8 @@ public class ValidateFeaturesMojo extend
/*
* Check if the artifact is an OSGi bundle
*/
- private boolean isBundle(String bundle, Artifact artifact) {
- if ("bundle".equals(artifact.getArtifactHandler().getPackaging())) {
+ private boolean isBundle(String bundle, Object artifact) {
+ if (artifact instanceof Artifact && "bundle".equals(((Artifact) artifact).getArtifactHandler().getPackaging())) {
return true;
} else {
try {
@@ -404,24 +413,22 @@ public class ValidateFeaturesMojo extend
/*
* Extract the META-INF/MANIFEST.MF file from an artifact
*/
- private Manifest getManifest(String bundle, Artifact artifact) throws ArtifactResolutionException, ArtifactNotFoundException,
+ private Manifest getManifest(String bundle, Object artifact) throws ArtifactResolutionException, ArtifactNotFoundException,
ZipException, IOException {
ZipFile file = null;
- if (bundle.startsWith(WRAP_URI_PREFIX)) {
- //use ops4j wrap handler directly to create the file
- File localFile = new File(localRepo.pathOf(artifact));
- if (!localFile.exists()) {
- resolver.resolve(artifact, remoteRepos, localRepo);
- localFile = artifact.getFile();
- }
- InputStream is = null;
- is = new BufferedInputStream(new URL(null, WRAP_URI_PREFIX + localFile.toURL(), new org.ops4j.pax.url.wrap.Handler()).openStream());
+ if (!(artifact instanceof Artifact)) {
+ //not resolved as mvn artifact, so it's non-mvn protocol, just use the CustomBundleURLStreamHandlerFactory
+ // to open stream
+ InputStream is = null;
+ try {
+ is = new BufferedInputStream(new URL(bundle).openStream());
+ } catch (Exception e){
+ e.printStackTrace();
+ }
try {
is.mark(256 * 1024);
JarInputStream jar = new JarInputStream(is);
Manifest m = jar.getManifest();
- System.out.println("export package is " + m.getMainAttributes().getValue(Constants.EXPORT_PACKAGE));
- System.out.println("import package is " + m.getMainAttributes().getValue(Constants.IMPORT_PACKAGE));
if(m == null) {
throw new IOException("Manifest not present in the first entry of the zip");
}
@@ -431,14 +438,15 @@ public class ValidateFeaturesMojo extend
is.close();
}
} else {
- File localFile = new File(localRepo.pathOf(artifact));
+ Artifact mvnArtifact = (Artifact) artifact;
+ File localFile = new File(localRepo.pathOf(mvnArtifact));
if (localFile.exists()) {
// avoid going over to the repository if the file is already on
// the disk
file = new ZipFile(localFile);
} else {
- resolver.resolve(artifact, remoteRepos, localRepo);
- file = new ZipFile(artifact.getFile());
+ resolver.resolve(mvnArtifact, remoteRepos, localRepo);
+ file = new ZipFile(mvnArtifact.getFile());
}
// let's replace syserr for now to hide warnings being issues by the Manifest reading process
PrintStream original = System.err;
@@ -455,7 +463,10 @@ public class ValidateFeaturesMojo extend
/*
* Resolve an artifact, downloading it from remote repositories when necessary
*/
- private Artifact resolve(String bundle) throws Exception, ArtifactNotFoundException {
+ private Object resolve(String bundle) throws Exception, ArtifactNotFoundException {
+ if (!isMavenProtocol(bundle)) {
+ return bundle;
+ }
Artifact artifact = getArtifact(bundle);
if (bundle.indexOf(MVN_REPO_SEPARATOR) >= 0) {
if (bundle.startsWith(MVN_URI_PREFIX)) {
@@ -471,7 +482,7 @@ public class ValidateFeaturesMojo extend
resolver.resolve(artifact, remoteRepos, localRepo);
}
if (artifact == null) {
- throw new Exception("Unable to resolve artifact for uri " + bundle);
+ throw new Exception("Unable to resolve artifact for uri " + bundle);
} else {
return artifact;
}
@@ -482,10 +493,7 @@ public class ValidateFeaturesMojo extend
*/
private Artifact getArtifact(String uri) {
// remove the mvn: prefix when necessary
- if (uri.startsWith(WRAP_URI_PREFIX)) {
- uri = uri.substring(WRAP_URI_PREFIX.length());
- }
- if (uri.startsWith(MVN_URI_PREFIX)) {
+ if (uri.startsWith(MVN_URI_PREFIX)) {
uri = uri.substring(MVN_URI_PREFIX.length());
}
// remove the repository url when specified
@@ -493,6 +501,7 @@ public class ValidateFeaturesMojo extend
uri = uri.split(MVN_REPO_SEPARATOR)[1];
}
String[] elements = uri.split("/");
+
switch (elements.length) {
case 5:
return factory.createArtifactWithClassifier(elements[0], elements[1], elements[2], elements[3], elements[4]);
@@ -503,6 +512,13 @@ public class ValidateFeaturesMojo extend
}
}
+
+ /*
+ * see if bundle url is start with mvn protocol
+ */
+ private boolean isMavenProtocol(String bundle) {
+ return bundle.startsWith(MVN_URI_PREFIX);
+ }
/*
* Helper method for debug logging