Search in sources :

Example 6 with ProjectLauncher

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

the class LauncherTest method testShaPackager.

/**
	 * Test the sha packager
	 * 
	 * @throws Exception
	 */
public static void testShaPackager() throws Exception {
    Project project = getProject();
    project.clear();
    project.setProperty("-package", "jpm");
    ProjectLauncher l = project.getProjectLauncher();
    l.setTrace(true);
    Jar executable = l.executable();
    assertNotNull(executable);
    Manifest m = executable.getManifest();
    m.write(System.out);
    System.out.flush();
    assertNotNull(m.getMainAttributes().getValue("JPM-Classpath"));
    assertNotNull(m.getMainAttributes().getValue("JPM-Runbundles"));
    Resource r = executable.getResource("launcher.properties");
    assertNotNull(r);
    Properties p = new Properties();
    try (InputStream in = r.openInputStream()) {
        p.load(in);
    }
    System.out.println(p);
    String s = p.getProperty("launch.bundles");
    assertTrue(s.contains("${JPMREPO}/"));
    assertEquals("false", p.getProperty("launch.embedded"));
}
Also used : Project(aQute.bnd.build.Project) InputStream(java.io.InputStream) Resource(aQute.bnd.osgi.Resource) ProjectLauncher(aQute.bnd.build.ProjectLauncher) Jar(aQute.bnd.osgi.Jar) Manifest(java.util.jar.Manifest) Properties(java.util.Properties)

Example 7 with ProjectLauncher

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

the class LauncherTest method testPackager.

/**
	 * Test the packager
	 * 
	 * @throws Exception
	 */
public static void testPackager() throws Exception {
    Project project = getProject();
    project.clear();
    project.setProperty("[debug]testprop", "debug");
    project.setProperty("[exec]testprop", "exec");
    project.setProperty("Header", "${testprop}");
    project.setProperty(Constants.PROFILE, "exec");
    ProjectLauncher l = project.getProjectLauncher();
    l.setTrace(true);
    Jar executable = l.executable();
    assertNotNull(executable);
    assertEquals("exec", project.getProperty("testprop"));
    assertEquals("exec", project.getProperty("Header"));
}
Also used : Project(aQute.bnd.build.Project) ProjectLauncher(aQute.bnd.build.ProjectLauncher) Jar(aQute.bnd.osgi.Jar)

Example 8 with ProjectLauncher

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

the class LauncherTest method testRunKeep.

// public static void testLocalLaunch() throws Exception {
// Project project = getProject();
// ProjectLauncher l = project.getProjectLauncher();
// l.setTrace(true);
// l.getRunProperties().put("test.cmd", "exit");
// //assertTrue(project.check());
// assertEquals(42, l.start(null));
// }
/**
	 * Test if we can keep the framework state.
	 */
public static void testRunKeep() throws Exception {
    //
    // First set persistence after clearing the storage
    //
    Project project = getProject();
    project.setProperty("-runkeep", "false");
    ProjectLauncher l = project.getProjectLauncher();
    l.setTrace(true);
    l.getRunProperties().put("test.cmd", "setpersistence");
    assertEquals(55, l.launch());
    //
    // Check that we really clear by clearing and checking state
    // this must fail with -2
    //
    project = getProject();
    project.setProperty("-runkeep", "false");
    l = project.getProjectLauncher();
    l.setTrace(true);
    l.getRunProperties().put("test.cmd", "getpersistence");
    assertEquals(-2, l.launch());
    //
    // We now try to set the state again with a cleared framework
    //
    project = getProject();
    project.setProperty("-runkeep", "false");
    l = project.getProjectLauncher();
    l.setTrace(true);
    l.getRunProperties().put("test.cmd", "setpersistence");
    assertEquals(55, l.launch());
    //
    // And now it should have been saved if we do not clear
    // the framework
    //
    project = getProject();
    project.setProperty("-runkeep", "true");
    l = project.getProjectLauncher();
    l.setTrace(true);
    l.getRunProperties().put("test.cmd", "getpersistence");
    assertEquals(65, l.launch());
}
Also used : Project(aQute.bnd.build.Project) ProjectLauncher(aQute.bnd.build.ProjectLauncher)

Example 9 with ProjectLauncher

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

the class LauncherTest method testSimple.

public static void testSimple() throws Exception {
    Project project = getProject();
    ProjectLauncher l = project.getProjectLauncher();
    l.setTrace(true);
    l.getRunProperties().put("test.cmd", "exit");
    // assertTrue(project.check());
    assertEquals(42, l.launch());
}
Also used : Project(aQute.bnd.build.Project) ProjectLauncher(aQute.bnd.build.ProjectLauncher)

Example 10 with ProjectLauncher

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

the class ProjectTesterImpl method prepare.

@Override
public boolean prepare() throws Exception {
    if (!prepared) {
        prepared = true;
        super.prepare();
        ProjectLauncher launcher = getProjectLauncher();
        if (port > 0) {
            launcher.getRunProperties().put(TESTER_PORT, "" + port);
            if (host != null)
                launcher.getRunProperties().put(TESTER_HOST, "" + host);
        }
        launcher.getRunProperties().put(TESTER_UNRESOLVED, getProject().getProperty(Constants.TESTUNRESOLVED, "true"));
        launcher.getRunProperties().put(TESTER_DIR, getReportDir().getAbsolutePath());
        launcher.getRunProperties().put(TESTER_CONTINUOUS, "" + getContinuous());
        if (getProject().is(Constants.RUNTRACE))
            launcher.getRunProperties().put(TESTER_TRACE, "true");
        Collection<String> testnames = getTests();
        if (testnames.size() > 0) {
            launcher.getRunProperties().put(TESTER_NAMES, Processor.join(testnames));
        }
        // This is only necessary because we might be picked
        // as default and that implies we're not on the -testpath
        launcher.addDefault(Constants.DEFAULT_TESTER_BSN);
        launcher.prepare();
    }
    return true;
}
Also used : ProjectLauncher(aQute.bnd.build.ProjectLauncher)

Aggregations

ProjectLauncher (aQute.bnd.build.ProjectLauncher)18 Project (aQute.bnd.build.Project)15 Jar (aQute.bnd.osgi.Jar)3 File (java.io.File)3 ProjectTester (aQute.bnd.build.ProjectTester)1 Run (aQute.bnd.build.Run)1 RunSession (aQute.bnd.build.RunSession)1 Workspace (aQute.bnd.build.Workspace)1 Processor (aQute.bnd.osgi.Processor)1 Resource (aQute.bnd.osgi.Resource)1 LaunchStatusHandler (bndtools.launch.ui.internal.LaunchStatusHandler)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 Callable (java.util.concurrent.Callable)1 Manifest (java.util.jar.Manifest)1 IProject (org.eclipse.core.resources.IProject)1 IResource (org.eclipse.core.resources.IResource)1 CoreException (org.eclipse.core.runtime.CoreException)1