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

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

Introduction

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

Prototype

String build_abortDueToClasspathProblems

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

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  a 2 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;
}