Search in sources :

Example 1 with N4JSEclipseProject

use of org.eclipse.n4js.ui.internal.N4JSEclipseProject in project n4js by eclipse.

the class ExternalLibraryBuilder method doPerformOperation.

private List<IProject> doPerformOperation(N4JSExternalProject[] projects, BuildOperation operation, IProgressMonitor monitor) {
    if (projects == null || projects.length == 0) {
        return Collections.emptyList();
    }
    ISchedulingRule rule = getRule();
    try {
        Job.getJobManager().beginRule(rule, monitor);
        VertexOrder<IN4JSProject> buildOrder = builtOrderComputer.getBuildOrder(projects);
        // wrap as Arrays.asList returns immutable list
        List<IN4JSProject> buildOrderList = new ArrayList<>(Arrays.asList(buildOrder.vertexes));
        if (BuildOperation.CLEAN.equals(operation)) {
            Collections.reverse(buildOrderList);
        }
        // Remove external projects that have the workspace counterpart if it is a build operation.
        if (BuildOperation.BUILD.equals(operation)) {
            for (Iterator<IN4JSProject> itr = buildOrderList.iterator(); itr.hasNext(); ) {
                if (hasWorkspaceCounterpart(itr.next())) {
                    itr.remove();
                }
            }
        }
        ensureDynamicDependenciesSetForWorkspaceProjects();
        String prefix = Strings.toFirstUpper(operation.toString().toLowerCase());
        String projectNames = getProjectNames(buildOrderList);
        LOGGER.info(prefix + "ing external libraries: " + projectNames);
        SubMonitor subMonitor = SubMonitor.convert(monitor, buildOrderList.size());
        List<IProject> actualBuildOrderList = new LinkedList<>();
        for (IN4JSProject project : buildOrderList) {
            LOGGER.info(prefix + "ing external library: " + project.getProjectId());
            // bold cast
            N4JSEclipseProject n4EclPrj = (N4JSEclipseProject) project;
            operation.run(this, n4EclPrj, subMonitor.newChild(1));
            IProject iProject = n4EclPrj.getProject();
            actualBuildOrderList.add(iProject);
        }
        return actualBuildOrderList;
    } finally {
        Job.getJobManager().endRule(rule);
    }
}
Also used : N4JSEclipseProject(org.eclipse.n4js.ui.internal.N4JSEclipseProject) IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) ArrayList(java.util.ArrayList) SubMonitor(org.eclipse.core.runtime.SubMonitor) IProject(org.eclipse.core.resources.IProject) LinkedList(java.util.LinkedList) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule)

Example 2 with N4JSEclipseProject

use of org.eclipse.n4js.ui.internal.N4JSEclipseProject in project n4js by eclipse.

the class BuildOrderComputer method getDependencies.

private Set<N4JSProject> getDependencies(IN4JSProject project) {
    Set<N4JSProject> prjDependencies = new HashSet<>();
    ImmutableList<? extends IN4JSSourceContainerAware> deps = project.getAllDirectDependencies();
    for (IN4JSSourceContainerAware dep : deps) {
        IN4JSProject pDep = core.findProject(dep.getLocation()).orNull();
        boolean isValidDep = true;
        isValidDep &= pDep != null && pDep.exists();
        isValidDep &= !(pDep instanceof N4JSEclipseProject) || ((N4JSEclipseProject) pDep).getProject().isOpen();
        if (isValidDep) {
            prjDependencies.add((N4JSProject) pDep);
        }
    }
    return prjDependencies;
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) N4JSProject(org.eclipse.n4js.internal.N4JSProject) N4JSEclipseProject(org.eclipse.n4js.ui.internal.N4JSEclipseProject) IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) IN4JSSourceContainerAware(org.eclipse.n4js.projectModel.IN4JSSourceContainerAware) HashSet(java.util.HashSet)

Aggregations

IN4JSProject (org.eclipse.n4js.projectModel.IN4JSProject)2 N4JSEclipseProject (org.eclipse.n4js.ui.internal.N4JSEclipseProject)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 IProject (org.eclipse.core.resources.IProject)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 ISchedulingRule (org.eclipse.core.runtime.jobs.ISchedulingRule)1 N4JSProject (org.eclipse.n4js.internal.N4JSProject)1 IN4JSSourceContainerAware (org.eclipse.n4js.projectModel.IN4JSSourceContainerAware)1