Search in sources :

Example 6 with Project

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

the class WorkspaceRepositoryTest method reallyClean.

private static void reallyClean(Workspace ws) throws Exception {
    String wsName = ws.getBase().getName();
    for (Project project : ws.getAllProjects()) {
        if (("p1".equals(project.getName()) && "ws-repo-test".equals(wsName)) || ("p2".equals(project.getName()) && "ws-repo-test".equals(wsName)) || ("p3".equals(project.getName()) && "ws-repo-test".equals(wsName))) {
            File output = project.getSrcOutput().getAbsoluteFile();
            if (output.isDirectory() && output.getParentFile() != null) {
                IO.delete(output);
            }
        } else {
            project.clean();
            File target = project.getTargetDir();
            if (target.isDirectory() && target.getParentFile() != null) {
                IO.delete(target);
            }
            File output = project.getSrcOutput().getAbsoluteFile();
            if (output.isDirectory() && output.getParentFile() != null) {
                IO.delete(output);
            }
        }
    }
    IO.delete(ws.getFile("cnf/cache"));
}
Also used : Project(aQute.bnd.build.Project) File(java.io.File)

Example 7 with Project

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

the class LauncherTest method testMain.

/**
	 * Launches against main
	 */
/*
	 * Launches against the agent& main
	 */
public void testMain() throws Exception {
    Project project = workspace.getProject("p1");
    Run bndrun = new Run(workspace, project.getBase(), project.getFile("one.bndrun"));
    bndrun.setProperty("-runpath", "biz.aQute.remote.launcher");
    bndrun.setProperty("-runbundles", "bsn-1,bsn-2");
    bndrun.setProperty("-runremote", "main;agent=1090");
    final RemoteProjectLauncherPlugin pl = (RemoteProjectLauncherPlugin) bndrun.getProjectLauncher();
    pl.prepare();
    List<? extends RunSession> sessions = pl.getRunSessions();
    assertEquals(1, sessions.size());
    RunSessionImpl main = (RunSessionImpl) sessions.get(0);
    CountDownLatch mainLatch = launch(main);
    main.waitTillStarted(1000);
    assertEquals(0, main.started.getCount());
    Thread.sleep(500);
    main.cancel();
    mainLatch.await();
    assertEquals(-3, main.getExitCode());
    bndrun.close();
}
Also used : Project(aQute.bnd.build.Project) RunSessionImpl(aQute.remote.plugin.RunSessionImpl) RemoteProjectLauncherPlugin(aQute.remote.plugin.RemoteProjectLauncherPlugin) Run(aQute.bnd.build.Run) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 8 with Project

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

the class AdjustClasspathsForNewProjectJob method runInWorkspace.

@Override
public IStatus runInWorkspace(IProgressMonitor monitor) {
    List<Project> projects;
    SubMonitor progress;
    try {
        projects = new ArrayList<Project>(Central.getWorkspace().getAllProjects());
        progress = SubMonitor.convert(monitor, projects.size());
    } catch (Exception e) {
        return Status.CANCEL_STATUS;
    }
    IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot();
    while (!projects.isEmpty()) {
        Project project = projects.remove(0);
        IProject eclipseProject = WorkspaceUtils.findOpenProject(wsroot, project);
        if (eclipseProject != null && !eclipseProject.equals(addedProject)) {
            try {
                project.propertiesChanged();
                IJavaProject javaProject = JavaCore.create(eclipseProject);
                if (javaProject != null) {
                    BndContainerInitializer.requestClasspathContainerUpdate(javaProject);
                }
            } catch (CoreException e) {
                logger.logStatus(e.getStatus());
                return Status.CANCEL_STATUS;
            }
            progress.worked(1);
        }
        if (progress.isCanceled())
            return Status.CANCEL_STATUS;
    }
    return Status.OK_STATUS;
}
Also used : Project(aQute.bnd.build.Project) IJavaProject(org.eclipse.jdt.core.IJavaProject) IProject(org.eclipse.core.resources.IProject) IJavaProject(org.eclipse.jdt.core.IJavaProject) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException) SubMonitor(org.eclipse.core.runtime.SubMonitor) CoreException(org.eclipse.core.runtime.CoreException) IProject(org.eclipse.core.resources.IProject)

Example 9 with Project

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

the class Central method refreshPlugins.

public static void refreshPlugins() throws Exception {
    List<File> refreshedFiles = new ArrayList<File>();
    List<Refreshable> rps = getWorkspace().getPlugins(Refreshable.class);
    boolean changed = false;
    boolean repoChanged = false;
    for (Refreshable rp : rps) {
        if (rp.refresh()) {
            changed = true;
            File root = rp.getRoot();
            if (root != null)
                refreshedFiles.add(root);
            if (rp instanceof RepositoryPlugin) {
                repoChanged = true;
            }
        }
    }
    if (changed) {
        try {
            for (File file : refreshedFiles) {
                refreshFile(file);
            }
            for (Project p : Central.getWorkspace().getAllProjects()) {
                p.setChanged();
                for (ModelListener l : getInstance().listeners) l.modelChanged(p);
            }
            if (repoChanged) {
                repositoriesViewRefresher.repositoriesRefreshed();
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) IProject(org.eclipse.core.resources.IProject) Project(aQute.bnd.build.Project) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) ModelListener(org.bndtools.api.ModelListener) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) Refreshable(aQute.bnd.service.Refreshable) IFile(org.eclipse.core.resources.IFile) File(java.io.File) TimeoutException(java.util.concurrent.TimeoutException) CoreException(org.eclipse.core.runtime.CoreException)

Example 10 with Project

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

the class BsnValidator method validate.

@Override
public IStatus validate(Builder builder) throws Exception {
    Project project;
    try {
        project = Central.getProject(builder.getBase());
    } catch (Exception e) {
        project = null;
    }
    if (project == null) {
        builder.error("Eclipse: Cannot find associated project for %s", builder);
        return null;
    }
    String bsn = builder.getBsn();
    if (bsn == null) {
        loc(bsn, builder, builder.warning("Eclipse: Bundle Symbolic Name not valid, get null"));
        return null;
    }
    if (!bsn.startsWith(project.getName())) {
        loc(bsn, builder, builder.warning("Eclipse: The Bundle Symbolic Name must %s start with the project name %s, " + "which must be the project's directory %s name", bsn, project, project.getBase()));
        return null;
    }
    File pf = builder.getPropertiesFile();
    String rover = bsn.substring(project.getName().length());
    if (rover.startsWith(".")) {
        rover = rover.substring(1);
        if (pf == null) {
            loc(bsn, builder, builder.warning("Eclipse: The Bundle Symbolic %s starts with the project name %s " + "but then continues while it is not a sub-bundle", bsn, project));
            return null;
        }
        String suffix = removeExtension(pf.getName());
        if (!suffix.equals(rover)) {
            loc(bsn, builder, builder.warning("Eclipse: The Bundle Symbolic %s starts with the project name %s but then does not end with the subbuilder name", bsn, project, pf.getName()));
        }
        return null;
    }
    if (rover.isEmpty()) {
        if (pf != null) {
            loc(bsn, builder, builder.warning("Eclipse: The Bundle Symbolic %s is a sub-bundle %s but uses the project name", bsn, pf.getName(), project));
        }
        return null;
    }
    loc(bsn, builder, builder.warning("Eclipse: The Bundle Symbolic %s starts with the project name %s " + "but then continues but lacks the separating '.'", bsn, project));
    return null;
}
Also used : Project(aQute.bnd.build.Project) File(java.io.File)

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