Search in sources :

Example 41 with Project

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);
}
Also used : Project(aQute.bnd.build.Project) Version(aQute.bnd.version.Version) Workspace(aQute.bnd.build.Workspace)

Example 42 with Project

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());
}
Also used : Project(aQute.bnd.build.Project) Container(aQute.bnd.build.Container) Workspace(aQute.bnd.build.Workspace)

Example 43 with Project

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());
}
Also used : Project(aQute.bnd.build.Project) Workspace(aQute.bnd.build.Workspace)

Example 44 with Project

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

the class ProjectTest method testRepoFilterBuildPath.

public void testRepoFilterBuildPath() throws Exception {
    Workspace ws = getWorkspace(IO.getFile("testresources/ws"));
    Project project = ws.getProject("repofilter");
    assertNotNull(project);
    project.setProperty("-buildpath", "p3; version='[1,2)'; repo=Relea*");
    ArrayList<Container> buildpath = new ArrayList<Container>(project.getBuildpath());
    assertEquals(1, buildpath.size());
    // Without repos filter we would get lowest version, i.e. 1.0.0 from the
    // repo named "Repo".
    assertEquals("1.1.0", buildpath.get(0).getVersion());
}
Also used : Project(aQute.bnd.build.Project) Container(aQute.bnd.build.Container) ArrayList(java.util.ArrayList) Workspace(aQute.bnd.build.Workspace)

Example 45 with Project

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

the class ProjectTest method testCopyRepo.

public void testCopyRepo() throws Exception {
    Workspace ws = getWorkspace(IO.getFile("testresources/ws-repo-test"));
    Project project = ws.getProject("p1");
    assertNotNull(ws);
    assertNotNull(project);
    RepositoryPlugin repo = ws.getRepository("Repo");
    assertNotNull(repo);
    RepositoryPlugin release = ws.getRepository("Release");
    assertNotNull(release);
    project.copy(repo, (String) null, release);
    assertTrue(project.check());
    assertTrue(ws.check());
}
Also used : Project(aQute.bnd.build.Project) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) Workspace(aQute.bnd.build.Workspace)

Aggregations

Project (aQute.bnd.build.Project)140 Workspace (aQute.bnd.build.Workspace)70 File (java.io.File)45 ArrayList (java.util.ArrayList)22 IProject (org.eclipse.core.resources.IProject)21 Container (aQute.bnd.build.Container)19 IOException (java.io.IOException)17 ProjectLauncher (aQute.bnd.build.ProjectLauncher)15 Version (aQute.bnd.version.Version)12 Description (aQute.lib.getopt.Description)12 Jar (aQute.bnd.osgi.Jar)11 Builder (aQute.bnd.osgi.Builder)10 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)10 IJavaProject (org.eclipse.jdt.core.IJavaProject)9 Run (aQute.bnd.build.Run)8 BuildException (org.apache.tools.ant.BuildException)8 CoreException (org.eclipse.core.runtime.CoreException)8 IFile (org.eclipse.core.resources.IFile)7 ProjectBuilder (aQute.bnd.build.ProjectBuilder)6 ProjectTester (aQute.bnd.build.ProjectTester)5