Example usage for org.eclipse.jdt.internal.core.util Messages build_prereqProjectHasClasspathProblems

List of usage examples for org.eclipse.jdt.internal.core.util Messages build_prereqProjectHasClasspathProblems

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.util Messages build_prereqProjectHasClasspathProblems.

Prototype

String build_prereqProjectHasClasspathProblems

To view the source code for org.eclipse.jdt.internal.core.util Messages build_prereqProjectHasClasspathProblems.

Click Source Link

Usage

From source file:net.sf.j2s.core.builder.JavaBuilder.java

License:Open Source License

private boolean isWorthBuilding() throws CoreException {
    boolean abortBuilds = JavaCore.ABORT
            .equals(this.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, true));
    if (!abortBuilds)
        return true;

    // Abort build only if there are classpath errors
    if (isClasspathBroken(this.javaProject.getRawClasspath(), this.currentProject)) {
        if (DEBUG)
            System.out.println(//ww  w. ja  v  a2 s .c  o m
                    "JavaBuilder: Aborted build because project has classpath errors (incomplete or involved in cycle)"); //$NON-NLS-1$

        removeProblemsAndTasksFor(this.currentProject); // remove all compilation problems

        IMarker marker = this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
        marker.setAttributes(
                new String[] { IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID,
                        IMarker.SOURCE_ID },
                new Object[] { Messages.build_abortDueToClasspathProblems, new Integer(IMarker.SEVERITY_ERROR),
                        new Integer(CategorizedProblem.CAT_BUILDPATH), JavaBuilder.SOURCE_ID });
        return false;
    }

    if (JavaCore.WARNING.equals(this.javaProject.getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true)))
        return true;

    // make sure all prereq projects have valid build states... only when aborting builds since projects in cycles do not have build states
    // except for projects involved in a 'warning' cycle (see below)
    IProject[] requiredProjects = getRequiredProjects(false);
    for (int i = 0, l = requiredProjects.length; i < l; i++) {
        IProject p = requiredProjects[i];
        if (getLastState(p) == null) {
            // The prereq project has no build state: if this prereq project has a 'warning' cycle marker then allow build (see bug id 23357)
            JavaProject prereq = (JavaProject) JavaCore.create(p);
            if (prereq.hasCycleMarker() && JavaCore.WARNING
                    .equals(this.javaProject.getOption(JavaCore.CORE_CIRCULAR_CLASSPATH, true))) {
                if (DEBUG)
                    System.out
                            .println("JavaBuilder: Continued to build even though prereq project " + p.getName() //$NON-NLS-1$
                                    + " was not built since its part of a cycle"); //$NON-NLS-1$
                continue;
            }
            if (!hasJavaBuilder(p)) {
                if (DEBUG)
                    System.out
                            .println("JavaBuilder: Continued to build even though prereq project " + p.getName() //$NON-NLS-1$
                                    + " is not built by JavaBuilder"); //$NON-NLS-1$
                continue;
            }
            if (DEBUG)
                System.out.println("JavaBuilder: Aborted build because prereq project " + p.getName() //$NON-NLS-1$
                        + " was not built"); //$NON-NLS-1$

            removeProblemsAndTasksFor(this.currentProject); // make this the only problem for this project
            IMarker marker = this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
            marker.setAttributes(
                    new String[] { IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID,
                            IMarker.SOURCE_ID },
                    new Object[] {
                            isClasspathBroken(prereq.getRawClasspath(), p)
                                    ? Messages.bind(Messages.build_prereqProjectHasClasspathProblems,
                                            p.getName())
                                    : Messages.bind(Messages.build_prereqProjectMustBeRebuilt, p.getName()),
                            new Integer(IMarker.SEVERITY_ERROR), new Integer(CategorizedProblem.CAT_BUILDPATH),
                            JavaBuilder.SOURCE_ID });
            return false;
        }
    }
    return true;
}

From source file:org.eclipse.ajdt.core.builder.AJBuilder.java

License:Open Source License

/**
 * Check to see if the class paths are valid
 * @param progressMonitor//from w  ww  .j a  v a  2s.c  o  m
 * @param project
 * @param requiredProjects
 * @return true if aspect, in, and class paths are valid.  False if there is a problem
 * @throws CoreException
 */
private boolean isWorthBuilding(IProject project) throws CoreException {
    // bug 159197: check inpath and aspectpath
    // and classpath
    if (!validateInpathAspectPath(project)
            || isClasspathBroken(JavaCore.create(project).getRawClasspath(), project)) {
        AJLog.log(AJLog.BUILDER, "build: Abort due to missing inpath/aspectpath/classpath entries"); //$NON-NLS-1$
        AJLog.logEnd(AJLog.BUILDER, TimerLogEvent.TIME_IN_BUILD);
        removeProblemsAndTasksFor(project);
        // make this the only problem for this project
        markProject(project,
                Messages.bind(Messages.build_prereqProjectHasClasspathProblems, project.getName()));

        // Bug 288395---log all problem markers to the AJDT Event log
        IMarker[] markers = ResourcesPlugin.getWorkspace().getRoot()
                .findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
        if (markers.length > 0) {
            AJLog.log("Bug 288395---logging build path problems, found " + markers.length);
            for (int i = 0; i < markers.length; i++) {
                AJLog.log("  " + markers[i].getResource().getFullPath() + " : "
                        + markers[i].getAttribute(IMarker.MESSAGE, "<no message>"));
            }
        }

        markers = ResourcesPlugin.getWorkspace().getRoot().findMarkers(IJavaModelMarker.CYCLE_DETECTED, false,
                IResource.DEPTH_INFINITE);
        if (markers.length > 0) {
            AJLog.log("Bug 288395---logging build path cycles, found " + markers.length);
            for (int i = 0; i < markers.length; i++) {
                AJLog.log("  " + markers[i].getResource().getFullPath() + " : "
                        + markers[i].getAttribute(IMarker.MESSAGE, "<no message>"));
            }
        }

        markers = ResourcesPlugin.getWorkspace().getRoot()
                .findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
        if (markers.length > 0) {
            AJLog.log("Bug 288395---logging build path problems, found " + markers.length);
            for (int i = 0; i < markers.length; i++) {
                AJLog.log("  " + markers[i].getResource().getFullPath() + " : "
                        + markers[i].getAttribute(IMarker.MESSAGE, "<no message>"));
            }
        }

        return false;
    }
    return true;
}