Search in sources :

Example 56 with RepositoryPlugin

use of aQute.bnd.service.RepositoryPlugin in project bnd by bndtools.

the class RepoCommand method _versions.

@Description("Displays a list of versions for a given bsn that can be found in the current repositories.")
public void _versions(VersionsOptions opts) throws Exception {
    TreeSet<Version> versions = new TreeSet<Version>();
    String bsn = opts._arguments().remove(0);
    for (RepositoryPlugin repo : repos) {
        versions.addAll(repo.versions(bsn));
    }
    bnd.out.println(versions);
}
Also used : Version(aQute.bnd.version.Version) TreeSet(java.util.TreeSet) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) Description(aQute.lib.getopt.Description)

Example 57 with RepositoryPlugin

use of aQute.bnd.service.RepositoryPlugin in project bnd by bndtools.

the class BaselineTest method testRepository.

/**
	 * In repo:
	 *
	 * <pre>
	 *  p3-1.1.0.jar p3-1.2.0.jar
	 * </pre>
	 *
	 * @throws Exception
	 */
public void testRepository() throws Exception {
    Jar v1_2_0_a = mock(Jar.class);
    when(v1_2_0_a.getVersion()).thenReturn("1.2.0.b");
    when(v1_2_0_a.getBsn()).thenReturn("p3");
    RepositoryPlugin repo = mock(RepositoryPlugin.class);
    getWorkspace().addBasicPlugin(repo);
    @SuppressWarnings("unchecked") Map<String, String> map = any(Map.class);
    when(repo.get(anyString(), any(Version.class), map)).thenReturn(IO.getFile("testresources/ws/cnf/releaserepo/p3/p3-1.2.0.jar"));
    System.out.println(repo.get("p3", new Version("1.2.0.b"), new Attrs()));
    when(repo.canWrite()).thenReturn(true);
    when(repo.getName()).thenReturn("Baseline");
    when(repo.versions("p3")).thenReturn(new SortedList<Version>(new Version("1.1.0.a"), new Version("1.1.0.b"), new Version("1.2.0.a"), new Version("1.2.0.b")));
    Project p3 = getWorkspace().getProject("p3");
    p3.setBundleVersion("1.3.0");
    ProjectBuilder builder = (ProjectBuilder) p3.getBuilder(null).getSubBuilder();
    builder.setProperty(Constants.BASELINE, "*");
    builder.setProperty(Constants.BASELINEREPO, "Baseline");
    // Nothing specified
    Jar jar = builder.getBaselineJar();
    assertEquals("1.2.0", new Version(jar.getVersion()).getWithoutQualifier().toString());
    if (!builder.check())
        fail(builder.getErrors().toString());
    {
        // check for error when repository contains later versions
        builder = (ProjectBuilder) p3.getBuilder(null).getSubBuilder();
        builder.setBundleVersion("1.1.3");
        builder.setTrace(true);
        builder.setProperty(Constants.BASELINE, "*");
        builder.setProperty(Constants.BASELINEREPO, "Baseline");
        jar = builder.getBaselineJar();
        assertNull(jar);
        if (!builder.check("The baseline version 1.2.0.b is higher than the current version 1.1.3 for p3"))
            fail(builder.getErrors().toString());
    }
    {
        // check for no error when repository has the same version
        builder = (ProjectBuilder) p3.getBuilder(null).getSubBuilder();
        builder.setBundleVersion("1.2.0.b");
        builder.setTrace(true);
        builder.setProperty(Constants.BASELINE, "*");
        builder.setProperty(Constants.BASELINEREPO, "Baseline");
        jar = builder.getBaselineJar();
        assertNotNull(jar);
        if (!builder.check())
            fail(builder.getErrors().toString());
    }
    {
        // check for no error when repository has the same version
        builder = (ProjectBuilder) p3.getBuilder(null).getSubBuilder();
        builder.setBundleVersion("1.2.0.b");
        builder.setTrace(true);
        builder.setProperty(Constants.BASELINE, "*");
        builder.setProperty(Constants.BASELINEREPO, "Baseline");
        builder.build();
        if (!builder.check("The bundle version \\(1.2.0/1.2.0\\) is too low, must be at least 1.3.0"))
            fail(builder.getErrors().toString());
    }
}
Also used : Project(aQute.bnd.build.Project) ProjectBuilder(aQute.bnd.build.ProjectBuilder) Version(aQute.bnd.version.Version) Attrs(aQute.bnd.header.Attrs) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) Jar(aQute.bnd.osgi.Jar) Matchers.anyString(org.mockito.Matchers.anyString)

Example 58 with RepositoryPlugin

use of aQute.bnd.service.RepositoryPlugin in project bnd by bndtools.

the class BaselineTest method testNothingInRepo.

/**
	 * Check what happens when there is nothing in the repo ... We do not
	 * generate an error when version <=1.0.0, otherwise we generate an error.
	 *
	 * @throws Exception
	 */
public void testNothingInRepo() throws Exception {
    File tmp = new File("tmp");
    tmp.mkdirs();
    try {
        RepositoryPlugin repo = mock(RepositoryPlugin.class);
        when(repo.canWrite()).thenReturn(true);
        when(repo.getName()).thenReturn("Baseline");
        when(repo.versions("p3")).thenReturn(new TreeSet<Version>());
        getWorkspace().addBasicPlugin(repo);
        Project p3 = getWorkspace().getProject("p3");
        p3.setProperty(Constants.BASELINE, "*");
        p3.setProperty(Constants.BASELINEREPO, "Baseline");
        p3.setBundleVersion("0");
        p3.build();
        assertTrue(p3.check());
        p3.setBundleVersion("1.0.0.XXXXXX");
        p3.build();
        assertTrue(p3.check());
        p3.setBundleVersion("5");
        p3.build();
        assertTrue(p3.check("There is no baseline for p3 in the baseline repo"));
    } finally {
        IO.delete(tmp);
    }
}
Also used : Project(aQute.bnd.build.Project) Version(aQute.bnd.version.Version) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) File(java.io.File)

Example 59 with RepositoryPlugin

use of aQute.bnd.service.RepositoryPlugin in project bnd by bndtools.

the class Project method _repos.

public String _repos(@SuppressWarnings("unused") String[] args) throws Exception {
    List<RepositoryPlugin> repos = getPlugins(RepositoryPlugin.class);
    List<String> names = new ArrayList<String>();
    for (RepositoryPlugin rp : repos) names.add(rp.getName());
    return join(names, ", ");
}
Also used : ArrayList(java.util.ArrayList) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin)

Example 60 with RepositoryPlugin

use of aQute.bnd.service.RepositoryPlugin in project bnd by bndtools.

the class Project method release.

/**
	 * Release
	 *
	 * @param name The respository name
	 * @param test Run testcases
	 * @throws Exception
	 */
public void release(String name, boolean test) throws Exception {
    List<RepositoryPlugin> releaseRepos = getReleaseRepos(name);
    if (releaseRepos.isEmpty()) {
        return;
    }
    logger.debug("release");
    File[] jars = getBuildFiles(false);
    if (jars == null) {
        jars = build(test);
        // If build fails jars will be null
        if (jars == null) {
            logger.debug("no jars built");
            return;
        }
    }
    logger.debug("releasing {} - {}", jars, releaseRepos);
    for (RepositoryPlugin releaseRepo : releaseRepos) {
        for (File jar : jars) {
            releaseRepo(releaseRepo, jar.getName(), new BufferedInputStream(IO.stream(jar)));
        }
    }
}
Also used : BufferedInputStream(java.io.BufferedInputStream) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) File(java.io.File)

Aggregations

RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)62 Version (aQute.bnd.version.Version)25 File (java.io.File)24 Workspace (aQute.bnd.build.Workspace)12 IOException (java.io.IOException)10 Project (aQute.bnd.build.Project)9 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)9 Jar (aQute.bnd.osgi.Jar)7 CoreException (org.eclipse.core.runtime.CoreException)7 RemoteRepositoryPlugin (aQute.bnd.service.RemoteRepositoryPlugin)5 VersionRange (aQute.bnd.version.VersionRange)5 Description (aQute.lib.getopt.Description)5 Parameters (aQute.bnd.header.Parameters)4 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IStatus (org.eclipse.core.runtime.IStatus)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 PartInitException (org.eclipse.ui.PartInitException)4 Attrs (aQute.bnd.header.Attrs)3