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);
}
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());
}
}
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);
}
}
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, ", ");
}
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)));
}
}
}
Aggregations