Search in sources :

Example 61 with Project

use of aQute.bnd.build.Project 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 62 with Project

use of aQute.bnd.build.Project 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 63 with Project

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

the class LauncherTest method testTester.

public static void testTester() throws Exception {
    Project project = getProject();
    project.clear();
    project.build();
    ProjectTester pt = project.getProjectTester();
    pt.addTest("test.TestCase1");
    pt.addTest("test.TestCase2:m1");
    assertEquals(2, pt.test());
}
Also used : Project(aQute.bnd.build.Project) ProjectTester(aQute.bnd.build.ProjectTester)

Example 64 with Project

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

the class BndtoolsBuilder method hasUpstreamChanges.

/*
     * Check if any of the projects of which we depend has changes.
     * We use the generated/buildfiles as the marker.
     */
private boolean hasUpstreamChanges() throws Exception {
    for (IProject upstream : dependsOn) {
        if (!upstream.exists())
            continue;
        Project up = Central.getProject(upstream);
        if (up == null)
            continue;
        IResourceDelta delta = getDelta(upstream);
        DeltaWrapper dw = new DeltaWrapper(up, delta, buildLog);
        if (dw.hasBuildfile()) {
            buildLog.full("Upstream project %s changed", up);
            return true;
        }
    }
    return false;
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(aQute.bnd.build.Project) IJavaProject(org.eclipse.jdt.core.IJavaProject) IProject(org.eclipse.core.resources.IProject) IResourceDelta(org.eclipse.core.resources.IResourceDelta)

Example 65 with Project

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

the class WorkspaceAnalyserJob method run.

@Override
protected IStatus run(IProgressMonitor monitor) {
    IProgressMonitor mon = monitor;
    if (mon == null) {
        mon = new NullProgressMonitor();
    }
    try {
        Collection<Project> projects = Activator.getWorkspace().getAllProjects();
        mon.beginTask(Messages.workspaceReleaseJob, projects.size() * 2);
        List<Project> orderedProjects = getBuildOrder(mon, Activator.getWorkspace());
        if (mon.isCanceled()) {
            return Status.CANCEL_STATUS;
        }
        final List<ProjectDiff> projectDiffs = new ArrayList<ProjectDiff>();
        mon.setTaskName(Messages.processingProjects);
        for (Project project : orderedProjects) {
            IProject eProject = ReleaseUtils.getProject(project);
            if (!isIncluded(eProject)) {
                mon.worked(1);
                continue;
            }
            if ("".equals(project.getProperty(Constants.RELEASEREPO, null))) {
                mon.worked(1);
                continue;
            }
            if (eProject == null || !eProject.isOpen() || !eProject.isAccessible()) {
                mon.worked(1);
                continue;
            }
            List<Builder> builders = project.getBuilder(null).getSubBuilders();
            List<Baseline> jarDiffs = null;
            for (Builder b : builders) {
                mon.subTask(String.format(Messages.processingProject, b.getBsn()));
                Baseline jarDiff = DiffHelper.createBaseline(project, b.getBsn());
                if (jarDiff != null) {
                    if (jarDiffs == null) {
                        jarDiffs = new ArrayList<Baseline>();
                    }
                    jarDiffs.add(jarDiff);
                }
            }
            if (jarDiffs != null && jarDiffs.size() > 0) {
                projectDiffs.add(new ProjectDiff(project, jarDiffs));
            }
            if (mon.isCanceled()) {
                return Status.CANCEL_STATUS;
            }
            mon.worked(1);
        }
        if (projectDiffs.size() == 0) {
            Runnable runnable = new Runnable() {

                @Override
                public void run() {
                    MessageDialog.openInformation(shell, Messages.releaseWorkspaceBundles, Messages.noBundlesRequireRelease);
                }
            };
            if (Display.getCurrent() == null) {
                Display.getDefault().syncExec(runnable);
            } else {
                runnable.run();
            }
            return Status.OK_STATUS;
        }
        ReleaseHelper.initializeProjectDiffs(projectDiffs);
        Runnable runnable = new Runnable() {

            @Override
            public void run() {
                WorkspaceReleaseDialog dialog = new WorkspaceReleaseDialog(shell, projectDiffs, false);
                int ret = dialog.open();
                if (ret == WorkspaceReleaseDialog.OK) {
                    boolean runJob = false;
                    for (ProjectDiff diff : projectDiffs) {
                        if (diff.isRelease()) {
                            runJob = true;
                            break;
                        }
                    }
                    if (!runJob) {
                        return;
                    }
                    WorkspaceReleaseJob releaseJob = new WorkspaceReleaseJob(projectDiffs, dialog.getReleaseOption(), dialog.isShowMessage());
                    releaseJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
                    releaseJob.schedule();
                }
            }
        };
        if (Display.getCurrent() == null) {
            Display.getDefault().asyncExec(runnable);
        } else {
            runnable.run();
        }
    } catch (Exception e) {
        return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
    }
    return Status.OK_STATUS;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Builder(aQute.bnd.osgi.Builder) ArrayList(java.util.ArrayList) WorkspaceReleaseDialog(bndtools.release.ui.WorkspaceReleaseDialog) Baseline(aQute.bnd.differ.Baseline) IProject(org.eclipse.core.resources.IProject) Project(aQute.bnd.build.Project) IProject(org.eclipse.core.resources.IProject) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)

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