use of aQute.bnd.build.Project in project bnd by bndtools.
the class ProjectTest method testOutofDate.
public void testOutofDate() throws Exception {
Workspace ws = getWorkspace(IO.getFile("testresources/ws"));
Project project = ws.getProject("p3");
File bnd = IO.getFile("testresources/ws/p3/bnd.bnd");
assertTrue(bnd.exists());
project.clean();
File pt = project.getTarget();
if (!pt.exists() && !pt.mkdirs()) {
throw new IOException("Could not create directory " + pt);
}
try {
// Now we build it.
File[] files = project.build();
System.err.println(project.getErrors());
System.err.println(project.getWarnings());
assertTrue(project.isOk());
assertNotNull(files);
assertEquals(1, files.length);
// Now we should not rebuild it
long lastTime = files[0].lastModified();
files = project.build();
assertEquals(1, files.length);
assertTrue(files[0].lastModified() == lastTime);
Thread.sleep(2000);
project.updateModified(System.currentTimeMillis(), "Testing");
files = project.build();
assertEquals(1, files.length);
assertTrue("Must have newer files now", files[0].lastModified() > lastTime);
} finally {
project.clean();
}
}
use of aQute.bnd.build.Project in project bnd by bndtools.
the class ProjectTest method testErrorOnVersionIsProjectInRunbundles.
/**
* Check if a project=version, which is illegal on -runbundles, is actually
* reported as an error.
*
* @throws Exception
*/
public void testErrorOnVersionIsProjectInRunbundles() throws Exception {
Workspace ws = getWorkspace(IO.getFile("testresources/ws"));
Project top = ws.getProject("p1");
top.setProperty("-runbundles", "p2;version=project,p3;version=latest");
top.getRunbundles();
assertTrue(top.check("p2 is specified with version=project on -runbundles"));
}
use of aQute.bnd.build.Project in project bnd by bndtools.
the class ProjectTest method testPackageInfoType.
/*
* Verify that that -versionannotations works. We can be osgi, bnd,
* packageinfo, or an annotation. When not set, we are packageinfo
*/
public void testPackageInfoType() throws Exception {
Workspace ws = getWorkspace("testresources/ws");
Project project = ws.getProject("p5");
project.setTrace(true);
Version newVersion = new Version(2, 0, 0);
project.setProperty(Constants.PACKAGEINFOTYPE, "bnd");
// Package with no package info
project.setPackageInfo("pkg1", newVersion);
Version version = project.getPackageInfo("pkg1");
assertEquals(newVersion, version);
checkPackageInfoFiles(project, "pkg1", false, true);
String content = IO.collect(project.getFile("src/pkg1/package-info.java"));
assertTrue(content.contains("import aQute.bnd.annotation.Version"));
// Package with package-info.java containing @Version("1.0.0")
project.setPackageInfo("pkg2", newVersion);
version = project.getPackageInfo("pkg2");
assertEquals(newVersion, version);
checkPackageInfoFiles(project, "pkg2", false, true);
// new packageinfo must now contain osgi ann.
project.setProperty(Constants.PACKAGEINFOTYPE, "osgi");
// Package with package-info.java containing version + packageinfo
project.setPackageInfo("pkg5", newVersion);
version = project.getPackageInfo("pkg5");
assertEquals(newVersion, version);
checkPackageInfoFiles(project, "pkg5", true, true);
content = IO.collect(project.getFile("src/pkg5/package-info.java"));
assertTrue(content.contains("import aQute.bnd.annotation.Version"));
// Package with package-info.java NOT containing version +
// packageinfo
project.setPackageInfo("pkg6", newVersion);
version = project.getPackageInfo("pkg6");
assertEquals(newVersion, version);
checkPackageInfoFiles(project, "pkg6", true, true);
content = IO.collect(project.getFile("src/pkg6/package-info.java"));
assertTrue(content.contains("import org.osgi.annotation.versioning.Version"));
// Package with package-info.java NOT containing version
project.setPackageInfo("pkg7", newVersion);
version = project.getPackageInfo("pkg7");
assertEquals(newVersion, version);
checkPackageInfoFiles(project, "pkg7", false, true);
newVersion = new Version(2, 2, 0);
// Update packageinfo file
project.setPackageInfo("pkg1", newVersion);
version = project.getPackageInfo("pkg1");
assertEquals(newVersion, version);
checkPackageInfoFiles(project, "pkg1", false, true);
}
use of aQute.bnd.build.Project in project bnd by bndtools.
the class ProjectTest method testMultipleRepos.
/**
* Check multiple repos
*
* @throws Exception
*/
public void testMultipleRepos() throws Exception {
Workspace ws = getWorkspace(IO.getFile("testresources/ws"));
Project project = ws.getProject("p1");
project.setPedantic(true);
System.err.println(project.getBundle("org.apache.felix.configadmin", "1.1.0", Strategy.EXACT, null));
System.err.println(project.getBundle("org.apache.felix.configadmin", "1.1.0", Strategy.HIGHEST, null));
System.err.println(project.getBundle("org.apache.felix.configadmin", "1.1.0", Strategy.LOWEST, null));
List<Container> bundles = project.getBundles(Strategy.LOWEST, "org.apache.felix.configadmin;version=1.1.0,org.apache.felix.configadmin;version=1.1.0", "test");
assertTrue(project.check("Multiple bundles with the same final URL", "Duplicate name"));
assertEquals(1, bundles.size());
}
use of aQute.bnd.build.Project in project bnd by bndtools.
the class ProjectTest method testAddDirToClasspath.
/**
* Test if you can add directories and files to the classpath. Originally
* checked only for files
*/
public void testAddDirToClasspath() throws Exception {
Workspace ws = getWorkspace(IO.getFile("testresources/ws"));
Project top = ws.getProject("p1");
top.addClasspath(top.getOutput());
assertTrue(top.check());
}
Aggregations