Search in sources :

Example 1 with ToDependencyPom

use of aQute.bnd.service.maven.ToDependencyPom in project bnd by bndtools.

the class RepoCommand method _topom.

/**
	 * Read a repository and turn all bundles that have a pom into a dependency
	 * POM
	 * 
	 * @throws Exception
	 */
public void _topom(PomOptions opts) throws Exception {
    List<String> args = opts._arguments();
    String repoName = args.remove(0);
    String name = args.remove(0);
    RepositoryPlugin source = workspace.getRepository(repoName);
    if (source == null) {
        bnd.error("No such source repository: %s, available repos %s", repoName, workspace.getRepositories());
        return;
    }
    if (!(source instanceof ToDependencyPom)) {
        bnd.error("The repository %s cannot generate a dependency pom", source);
        return;
    }
    String sout = opts.output();
    if (sout == null)
        sout = "console";
    OutputStream out;
    if ("console".equals(sout))
        out = System.out;
    else {
        File f = bnd.getFile(sout);
        out = IO.outputStream(f);
    }
    try {
        ToDependencyPom r = (ToDependencyPom) source;
        aQute.bnd.service.maven.PomOptions po = new aQute.bnd.service.maven.PomOptions();
        po.dependencyManagement = opts.dependencyManagement();
        po.parent = opts.parent();
        po.gav = name;
        r.toPom(out, po);
    } finally {
        out.close();
    }
}
Also used : ToDependencyPom(aQute.bnd.service.maven.ToDependencyPom) OutputStream(java.io.OutputStream) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) File(java.io.File)

Aggregations

RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)1 ToDependencyPom (aQute.bnd.service.maven.ToDependencyPom)1 File (java.io.File)1 OutputStream (java.io.OutputStream)1