Search in sources :

Example 46 with Project

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

the class ProjectTest method testRequireBnd.

/**
	 * Test require bnd
	 */
public void testRequireBnd() throws Exception {
    Workspace ws = getWorkspace(IO.getFile("testresources/ws"));
    Project top = ws.getProject("p1");
    top.setProperty("-resourceonly", "true");
    top.setProperty("-includeresource", "a;literal=''");
    top.setProperty("-require-bnd", "100000.0");
    top.build();
    assertTrue(top.check("-require-bnd fails for filter  values=\\{version="));
}
Also used : Project(aQute.bnd.build.Project) Workspace(aQute.bnd.build.Workspace)

Example 47 with Project

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

the class ProjectTest method testWildcardBuildPath.

public void testWildcardBuildPath() throws Exception {
    Workspace ws = getWorkspace(IO.getFile("testresources/ws"));
    Project project = ws.getProject("repofilter");
    assertNotNull(project);
    project.setProperty("-buildpath", "lib*");
    ArrayList<Container> buildpath = new ArrayList<Container>(project.getBuildpath());
    for (int i = 1; i < buildpath.size(); i++) {
        Container c = buildpath.get(i);
        assertEquals(Container.TYPE.REPO, c.getType());
    }
}
Also used : Project(aQute.bnd.build.Project) Container(aQute.bnd.build.Container) ArrayList(java.util.ArrayList) Workspace(aQute.bnd.build.Workspace)

Example 48 with Project

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

the class ProjectTest method testRepoMacro2.

/**
	 * https://github.com/bndtools/bnd/issues/395 Repo macro does not refer to
	 * anything
	 */
public void testRepoMacro2() throws Exception {
    Workspace ws = getWorkspace(IO.getFile("testresources/ws"));
    Project top = ws.getProject("p2");
    top.addClasspath(top.getOutput());
    top.setProperty("a", "${repo;org.apache.felix.configadmin;latest}");
    System.out.println("a= '" + top.getProperty("a") + "'");
    assertTrue(top.getProperty("a").endsWith("org.apache.felix.configadmin/org.apache.felix.configadmin-1.8.8.jar".replace('/', File.separatorChar)));
    top.setProperty("a", "${repo;IdoNotExist;latest}");
    top.getProperty("a");
    assertTrue(top.check("macro refers to an artifact IdoNotExist-latest.*that has an error"));
    assertEquals("", top.getProperty("a"));
}
Also used : Project(aQute.bnd.build.Project) Workspace(aQute.bnd.build.Workspace)

Example 49 with Project

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

the class ProjectTest method testHashVersionWithAlgorithmNotFound.

public void testHashVersionWithAlgorithmNotFound() throws Exception {
    Workspace ws = getWorkspace(IO.getFile("testresources/ws-versionhash"));
    Project project = ws.getProject("p1");
    assertNotNull(project);
    project.setProperty("-buildpath", "tmp; version=hash; hash=SHA-1:7fe83bfd5999fa4ef9cec40282d5d67dd0ff3303bac6b8c7b0e8be80a821441c");
    ArrayList<Container> buildpath = new ArrayList<Container>(project.getBuildpath());
    assertEquals(0, buildpath.size());
}
Also used : Project(aQute.bnd.build.Project) Container(aQute.bnd.build.Container) ArrayList(java.util.ArrayList) Workspace(aQute.bnd.build.Workspace)

Example 50 with Project

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

the class ProjectTest method testSetPackageVersion.

public void testSetPackageVersion() throws Exception {
    Workspace ws = getWorkspace("testresources/ws");
    Project project = ws.getProject("p5");
    project.setTrace(true);
    Version newVersion = new Version(2, 0, 0);
    // Package with no package info
    project.setPackageInfo("pkg1", newVersion);
    Version version = project.getPackageInfo("pkg1");
    assertEquals(newVersion, version);
    checkPackageInfoFiles(project, "pkg1", true, false);
    // 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);
    // Package with package-info.java containing
    // @aQute.bnd.annotations.Version("1.0.0")
    project.setPackageInfo("pkg3", newVersion);
    version = project.getPackageInfo("pkg3");
    assertEquals(newVersion, version);
    checkPackageInfoFiles(project, "pkg3", false, true);
    // Package with package-info.java containing
    // @aQute.bnd.annotations.Version(value="1.0.0")
    project.setPackageInfo("pkg4", newVersion);
    version = project.getPackageInfo("pkg4");
    assertEquals(newVersion, version);
    checkPackageInfoFiles(project, "pkg4", false, true);
    // Package with package-info.java containing version + packageinfo
    project.setPackageInfo("pkg5", newVersion);
    version = project.getPackageInfo("pkg5");
    assertEquals(newVersion, version);
    checkPackageInfoFiles(project, "pkg5", true, true);
    // 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);
    // Package with package-info.java NOT containing version
    project.setPackageInfo("pkg7", newVersion);
    version = project.getPackageInfo("pkg7");
    assertEquals(newVersion, version);
    checkPackageInfoFiles(project, "pkg7", true, true);
    newVersion = new Version(2, 2, 0);
    // Update packageinfo file
    project.setPackageInfo("pkg1", newVersion);
    version = project.getPackageInfo("pkg1");
    assertEquals(newVersion, version);
    checkPackageInfoFiles(project, "pkg1", true, false);
}
Also used : Project(aQute.bnd.build.Project) Version(aQute.bnd.version.Version) 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