Search in sources :

Example 31 with Project

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

the class ProjectTest method testProjectReferringToItself.

/**
	 * #194 StackOverflowError when -runbundles in bnd.bnd refers to itself
	 */
public void testProjectReferringToItself() throws Exception {
    Workspace ws = getWorkspace(IO.getFile("testresources/ws"));
    Project top = ws.getProject("bug194");
    top.setDelayRunDependencies(false);
    top.addClasspath(top.getOutput());
    assertTrue(top.check("Circular dependency context"));
}
Also used : Project(aQute.bnd.build.Project) Workspace(aQute.bnd.build.Workspace)

Example 32 with Project

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

the class ProjectTest method testBuildAll.

private Project testBuildAll(String dependsOn, int count) throws Exception {
    Workspace ws = new Workspace(IO.getFile("testresources/ws"));
    Project all = ws.getProject("build-all");
    all.setProperty("-dependson", dependsOn);
    all.prepare();
    Collection<Project> dependson = all.getDependson();
    assertEquals(count, dependson.size());
    return all;
}
Also used : Project(aQute.bnd.build.Project) Workspace(aQute.bnd.build.Workspace)

Example 33 with Project

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

the class ProjectTest method testBump.

public void testBump() throws Exception {
    Workspace ws = getWorkspace("testresources/ws");
    Project project = ws.getProject("p1");
    int size = project.getProperties().size();
    Version old = new Version(project.getProperty("Bundle-Version"));
    System.err.println("Old version " + old);
    project.bump("=+0");
    Version newv = new Version(project.getProperty("Bundle-Version"));
    System.err.println("New version " + newv);
    assertEquals(old.getMajor(), newv.getMajor());
    assertEquals(old.getMinor() + 1, newv.getMinor());
    assertEquals(0, newv.getMicro());
    assertEquals(size, project.getProperties().size());
    assertEquals("sometime", newv.getQualifier());
}
Also used : Project(aQute.bnd.build.Project) Version(aQute.bnd.version.Version) Workspace(aQute.bnd.build.Workspace)

Example 34 with Project

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

the class ProjectTest method testHashVersionWithAlgorithm.

public void testHashVersionWithAlgorithm() 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-256:7fe83bfd5999fa4ef9cec40282d5d67dd0ff3303bac6b8c7b0e8be80a821441c");
    ArrayList<Container> buildpath = new ArrayList<Container>(project.getBuildpath());
    assertEquals(1, buildpath.size());
    assertEquals("bar", buildpath.get(0).getManifest().getMainAttributes().getValue("Prints"));
}
Also used : Project(aQute.bnd.build.Project) Container(aQute.bnd.build.Container) ArrayList(java.util.ArrayList) Workspace(aQute.bnd.build.Workspace)

Example 35 with Project

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

the class ProjectTest method testLastModified.

/**
	 * Two subsequent builds should not change the last modified if none of the
	 * source inputs have been modified.
	 *
	 * @throws Exception
	 */
public void testLastModified() throws Exception {
    Workspace ws = getWorkspace("testresources/ws");
    Project project = ws.getProject("p6");
    File bnd = IO.getFile("testresources/ws/p6/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();
        assertTrue(project.check());
        assertNotNull(files);
        assertEquals(1, files.length);
        byte[] olderDigest;
        try (Jar older = new Jar(files[0])) {
            olderDigest = older.getTimelessDigest();
        }
        System.out.println();
        // Ensure system time granularity is < than
        Thread.sleep(3000);
        // wait
        files[0].delete();
        project.build();
        assertTrue(project.check());
        assertNotNull(files);
        assertEquals(1, files.length);
        byte[] newerDigest;
        try (Jar newer = new Jar(files[0])) {
            newerDigest = newer.getTimelessDigest();
        }
        assertTrue(Arrays.equals(olderDigest, newerDigest));
    } finally {
        project.clean();
    }
}
Also used : Project(aQute.bnd.build.Project) Jar(aQute.bnd.osgi.Jar) IOException(java.io.IOException) File(java.io.File) 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