Search in sources :

Example 71 with Workspace

use of aQute.bnd.build.Workspace in project bnd by bndtools.

the class PomRepositoryTest method testNonStandardClassifierDependencies.

public void testNonStandardClassifierDependencies() throws Exception {
    BndPomRepository mcsr = new BndPomRepository();
    Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
    w.setBase(tmp);
    mcsr.setRegistry(w);
    File local = new File(tmp, "m2-repository");
    local.mkdirs();
    Map<String, String> config = new HashMap<>();
    config.put("name", "pmd");
    config.put("revision", "net.sourceforge.pmd:pmd-java:5.2.3");
    config.put("snapshotUrls", "https://repo1.maven.org/maven2/");
    config.put("releaseUrls", "https://repo1.maven.org/maven2/");
    config.put("local", local.getAbsolutePath());
    mcsr.setProperties(config);
    List<String> list = mcsr.list(null);
    assertNotNull(list);
    URL url = new URL(tmp.toURI().toURL(), "m2-repository/net/sourceforge/saxon/saxon/9.1.0.8/saxon-9.1.0.8-dom.jar");
    File dom = new File(url.getFile());
    assertTrue(dom.exists());
// I'm assuming because we don't have a way of currently "getting" such
// a classified artifact from the repo that we'd have to encode the
// classifier in the bsn of the classified jar if it's not a bundle.
// Something like:
// File file = mcsr.get("net.sourceforge.pmd:pmd-java:dom", new
// Version("5.2.3"), null);
// assertNotNull(file);
}
Also used : Processor(aQute.bnd.osgi.Processor) HashMap(java.util.HashMap) File(java.io.File) URL(java.net.URL) Workspace(aQute.bnd.build.Workspace)

Example 72 with Workspace

use of aQute.bnd.build.Workspace in project bnd by bndtools.

the class PomRepositoryTest method testSearchRepoFailNoName.

public void testSearchRepoFailNoName() throws Exception {
    BndPomRepository mcsr = new BndPomRepository();
    Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
    w.setBase(tmp);
    mcsr.setRegistry(w);
    Map<String, String> config = new HashMap<>();
    config.put("query", "q=g:biz.aQute.bnd+a:biz.aQute.bnd+AND+v:3.2.0");
    try {
        mcsr.setProperties(config);
        fail();
    } catch (Exception e) {
        assertEquals("Must get a name", e.getMessage());
    }
}
Also used : Processor(aQute.bnd.osgi.Processor) HashMap(java.util.HashMap) Workspace(aQute.bnd.build.Workspace)

Example 73 with Workspace

use of aQute.bnd.build.Workspace in project bnd by bndtools.

the class PomRepositoryTest method testSearchRepoNoUrls.

public void testSearchRepoNoUrls() throws Exception {
    BndPomRepository mcsr = new BndPomRepository();
    Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
    w.setBase(tmp);
    mcsr.setRegistry(w);
    Map<String, String> config = new HashMap<>();
    config.put("query", "q=g:biz.aQute.bnd+a:biz.aQute.bnd+AND+v:3.2.0");
    config.put("name", "test");
    mcsr.setProperties(config);
    List<String> list = mcsr.list(null);
    assertNotNull(list);
    assertEquals(1, list.size());
}
Also used : Processor(aQute.bnd.osgi.Processor) HashMap(java.util.HashMap) Workspace(aQute.bnd.build.Workspace)

Example 74 with Workspace

use of aQute.bnd.build.Workspace in project bnd by bndtools.

the class PomRepositoryTest method testSearchRepoMultipleConfigurationsDontBreak.

public void testSearchRepoMultipleConfigurationsDontBreak() throws Exception {
    Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
    w.setBase(tmp);
    BndPomRepository mcsrBnd320 = new BndPomRepository();
    mcsrBnd320.setRegistry(w);
    Map<String, String> config = new HashMap<>();
    config.put("query", "q=g:biz.aQute.bnd+a:biz.aQute.bnd+AND+v:3.2.0");
    config.put("name", "bnd320");
    mcsrBnd320.setProperties(config);
    BndPomRepository mcsrBnd330 = new BndPomRepository();
    mcsrBnd330.setRegistry(w);
    config = new HashMap<>();
    config.put("query", "q=g:biz.aQute.bnd+a:biz.aQute.bnd+AND+v:3.3.0");
    config.put("name", "bnd330");
    mcsrBnd330.setProperties(config);
    List<String> list320 = mcsrBnd320.list(null);
    assertNotNull(list320);
    assertEquals(1, list320.size());
    List<String> list330 = mcsrBnd330.list(null);
    assertNotNull(list330);
    assertEquals(1, list330.size());
    // check the first repo to make sure it's there.
    RequirementBuilder builder = mcsrBnd320.newRequirementBuilder("osgi.identity");
    builder.addDirective("filter", "(&(osgi.identity=biz.aQute.bnd)(version>=3.2.0)(!(version>=3.3.0)))");
    Promise<Collection<Resource>> providers = mcsrBnd320.findProviders(builder.buildExpression());
    Collection<Resource> resources = providers.getValue();
    assertFalse(resources.isEmpty());
    assertEquals(1, resources.size());
    // make sure it's not in the second repo, otherwise the caches are
    // messed up.
    providers = mcsrBnd330.findProviders(builder.buildExpression());
    resources = providers.getValue();
    assertTrue(resources.isEmpty());
    assertEquals(0, resources.size());
}
Also used : Processor(aQute.bnd.osgi.Processor) HashMap(java.util.HashMap) Resource(org.osgi.resource.Resource) RequirementBuilder(org.osgi.service.repository.RequirementBuilder) Collection(java.util.Collection) Workspace(aQute.bnd.build.Workspace)

Example 75 with Workspace

use of aQute.bnd.build.Workspace in project bnd by bndtools.

the class PomRepositoryTest method testDependenciesWithVersionRanges.

public void testDependenciesWithVersionRanges() throws Exception {
    BndPomRepository bpr = new BndPomRepository();
    Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
    w.setBase(tmp);
    bpr.setRegistry(w);
    Map<String, String> config = new HashMap<>();
    config.put("revision", "com.mchange:mchange-commons-java:0.2.10");
    config.put("snapshotUrls", "https://repo1.maven.org/maven2/");
    config.put("releaseUrls", "https://repo1.maven.org/maven2/");
    config.put("name", "test");
    bpr.setProperties(config);
    List<String> list = bpr.list(null);
    for (String bsn : list) {
        SortedSet<Version> versions = bpr.versions(bsn);
        assertEquals(1, versions.size());
        Version v = versions.first();
        switch(bsn) {
            case "log4j:log4j":
                assertEquals("1.2.14", v.toString());
                break;
            case "com.typesafe.config":
                assertEquals("1.2.1", v.toString());
                break;
            case "com.mchange:mchange-commons-java":
                assertEquals("0.2.10", v.toString());
                break;
            case "slf4j.api":
                assertEquals("1.7.5", v.toString());
                break;
            default:
                fail(bsn);
        }
    }
    assertNotNull(list);
    assertEquals(4, list.size());
}
Also used : Processor(aQute.bnd.osgi.Processor) HashMap(java.util.HashMap) Version(aQute.bnd.version.Version) Workspace(aQute.bnd.build.Workspace)

Aggregations

Workspace (aQute.bnd.build.Workspace)164 Project (aQute.bnd.build.Project)69 File (java.io.File)62 Processor (aQute.bnd.osgi.Processor)26 IOException (java.io.IOException)20 HashMap (java.util.HashMap)20 Container (aQute.bnd.build.Container)15 ArrayList (java.util.ArrayList)15 Version (aQute.bnd.version.Version)13 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)12 IProject (org.eclipse.core.resources.IProject)10 Run (aQute.bnd.build.Run)9 CoreException (org.eclipse.core.runtime.CoreException)9 Description (aQute.lib.getopt.Description)7 Collection (java.util.Collection)6 BndEditModel (aQute.bnd.build.model.BndEditModel)5 Jar (aQute.bnd.osgi.Jar)5 HttpTestServer (aQute.http.testservers.HttpTestServer)5 BuildException (org.apache.tools.ant.BuildException)5 IResource (org.eclipse.core.resources.IResource)5