I am attempting to use pax-url-mvn-0.2.1.jar to download maven
artifiacts from a non-OSGi Java program.  I was successful in getting
it download the jar artifact when the artifact is something like:

mvn:http://repository.ops4j.org/maven2!org.ops4j.pax.web.bundles/service/0.2.0

Any idea how to get the javadoc and source files too from the maven repos?

cheers,
Cameron
package org.ops4j.pax.url.mvn.internal;

import static java.lang.System.out;

import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
import java.net.URLStreamHandlerFactory;

import org.ops4j.util.property.PropertiesPropertyResolver;
import org.springframework.util.FileCopyUtils;

// http://wiki.ops4j.org/confluence/display/ops4j/Pax+URL+-+mvn
// http://scm.ops4j.org/browse/OPS4J/projects/pax/url/pax-url-commons/
public class DownloadArtifact {

    public static void main(String[] args) throws Exception {
        String artifact = "mvn:http://repository.ops4j.org/maven2!org.ops4j.pax.web.bundles/service/0.2.0";;
//        String artifact = "mvn:org.ops4j.pax.web.bundles/service/0.2.1";
        
        URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory(){
            @Override
            public URLStreamHandler createURLStreamHandler(String protocol) {
                if(!"mvn".equals(protocol)){
                    return null;
                }
                return new URLStreamHandler(){
                    @Override
                    protected URLConnection openConnection(URL url) throws IOException {
                        return new Connection(url, new ConfigurationImpl(new PropertiesPropertyResolver(System.getProperties())));
                    }
                };
            }
        });
        
        Parser p = new Parser(artifact);
        out.printf("artifact path: %s%n", p.getArtifactPath());
        
        URL url = new URL(artifact);
        URLConnection conn = url.openConnection();
        out.printf("connection type: %s%n", conn.getClass().getName());
        FileCopyUtils.copy(conn.getInputStream(), new FileOutputStream("D:/tmp/service-0.2.0.jar"));

    }

}
_______________________________________________
general mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/general

Reply via email to