Search in sources :

Example 1 with CachedPom

use of aQute.bnd.maven.support.CachedPom in project bnd by bndtools.

the class MavenTest method testRemote.

/**
	 * A test against maven 2
	 * 
	 * @throws Exception
	 * @throws URISyntaxException
	 */
public void testRemote() throws URISyntaxException, Exception {
    URI repo = new URI("http://repo1.maven.org/maven2");
    MavenEntry entry = maven.getEntry("org.springframework", "spring-aspects", "3.0.5.RELEASE");
    entry.remove();
    CachedPom pom = maven.getPom("org.springframework", "spring-aspects", "3.0.5.RELEASE", repo);
    Set<Pom> dependencies = pom.getDependencies(Scope.compile, repo);
    for (Pom dep : dependencies) {
        System.err.printf("%20s %-20s %10s%n", dep.getGroupId(), dep.getArtifactId(), dep.getVersion());
    }
}
Also used : CachedPom(aQute.bnd.maven.support.CachedPom) URI(java.net.URI) MavenEntry(aQute.bnd.maven.support.MavenEntry) ProjectPom(aQute.bnd.maven.support.ProjectPom) CachedPom(aQute.bnd.maven.support.CachedPom) Pom(aQute.bnd.maven.support.Pom)

Example 2 with CachedPom

use of aQute.bnd.maven.support.CachedPom in project bnd by bndtools.

the class MavenTest method testMavenx.

public static void testMavenx() throws Exception {
    Maven maven = new Maven(null);
    CachedPom pom = maven.getPom("javax.xml.bind", "com.springsource.javax.xml.bind", "2.2.0", new URI("http://repository.springsource.com/maven/bundles/release"), new URI("http://repository.springsource.com/maven/bundles/external"));
    // Pom pom = maven.getPom("javax.xml.ws",
    // "com.springsource.javax.xml.ws", "2.1.1", new
    // URL("http://repository.springsource.com/maven/bundles/release"), new
    // URL("http://repository.springsource.com/maven/bundles/external"));
    System.err.println(pom.getGroupId() + " + " + pom.getArtifactId() + "-" + pom.getVersion());
    System.err.println(pom.getDependencies(Pom.Scope.compile));
    File artifact = pom.getArtifact();
    System.err.println(artifact);
}
Also used : Maven(aQute.bnd.maven.support.Maven) CachedPom(aQute.bnd.maven.support.CachedPom) URI(java.net.URI) File(java.io.File)

Example 3 with CachedPom

use of aQute.bnd.maven.support.CachedPom in project bnd by bndtools.

the class MavenCommand method view.

void view(String[] args, int i) throws Exception {
    Maven maven = new Maven(executor);
    OutputStream out = System.err;
    List<URI> urls = new ArrayList<URI>();
    while (i < args.length && args[i].startsWith("-")) {
        if ("-r".equals(args[i])) {
            URI uri = new URI(args[++i]);
            urls.add(uri);
            System.err.println("URI for repo " + uri);
        } else if ("-o".equals(args[i])) {
            out = IO.outputStream(Paths.get(args[++i]));
        } else
            throw new IllegalArgumentException("Unknown option: " + args[i]);
        i++;
    }
    URI[] urls2 = urls.toArray(new URI[0]);
    PrintWriter pw = IO.writer(out);
    while (i < args.length) {
        String ref = args[i++];
        pw.println("Ref " + ref);
        Matcher matcher = GROUP_ARTIFACT_VERSION.matcher(ref);
        if (matcher.matches()) {
            String group = matcher.group(1);
            String artifact = matcher.group(2);
            String version = matcher.group(3);
            CachedPom pom = maven.getPom(group, artifact, version, urls2);
            Builder a = new Builder();
            a.setProperty(Constants.PRIVATEPACKAGE, "*");
            Set<Pom> dependencies = pom.getDependencies(Scope.compile, urls2);
            for (Pom dep : dependencies) {
                System.err.printf("%20s %-20s %10s%n", dep.getGroupId(), dep.getArtifactId(), dep.getVersion());
                a.addClasspath(dep.getArtifact());
            }
            pw.println(a.getClasspath());
            a.build();
            TreeSet<PackageRef> sorted = new TreeSet<PackageRef>(a.getImports().keySet());
            for (PackageRef p : sorted) {
                pw.printf("%-40s\n", p);
            }
            // for ( Map.Entry<String, Set<String>> entry :
            // a.getUses().entrySet()) {
            // String from = entry.getKey();
            // for ( String uses : entry.getValue()) {
            // System.err.printf("%40s %s\n", from, uses);
            // from = "";
            // }
            // }
            a.close();
        } else
            System.err.println("Wrong, must look like group+artifact+version, is " + ref);
    }
}
Also used : Maven(aQute.bnd.maven.support.Maven) Matcher(java.util.regex.Matcher) OutputStream(java.io.OutputStream) Builder(aQute.bnd.osgi.Builder) ArrayList(java.util.ArrayList) URI(java.net.URI) CachedPom(aQute.bnd.maven.support.CachedPom) Pom(aQute.bnd.maven.support.Pom) CachedPom(aQute.bnd.maven.support.CachedPom) TreeSet(java.util.TreeSet) PackageRef(aQute.bnd.osgi.Descriptors.PackageRef) PrintWriter(java.io.PrintWriter)

Aggregations

CachedPom (aQute.bnd.maven.support.CachedPom)3 URI (java.net.URI)3 Maven (aQute.bnd.maven.support.Maven)2 Pom (aQute.bnd.maven.support.Pom)2 MavenEntry (aQute.bnd.maven.support.MavenEntry)1 ProjectPom (aQute.bnd.maven.support.ProjectPom)1 Builder (aQute.bnd.osgi.Builder)1 PackageRef (aQute.bnd.osgi.Descriptors.PackageRef)1 File (java.io.File)1 OutputStream (java.io.OutputStream)1 PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1 TreeSet (java.util.TreeSet)1 Matcher (java.util.regex.Matcher)1