Example usage for org.eclipse.jdt.core IJavaModelMarker BUILDPATH_PROBLEM_MARKER

List of usage examples for org.eclipse.jdt.core IJavaModelMarker BUILDPATH_PROBLEM_MARKER

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IJavaModelMarker BUILDPATH_PROBLEM_MARKER.

Prototype

String BUILDPATH_PROBLEM_MARKER

To view the source code for org.eclipse.jdt.core IJavaModelMarker BUILDPATH_PROBLEM_MARKER.

Click Source Link

Document

Build path problem marker type (value "org.eclipse.jdt.core.buildpath_problem").

Usage

From source file:com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.java

License:Open Source License

@Override
protected void abortOnBadSetup(@NonNull IJavaProject javaProject, @Nullable ProjectState projectState)
        throws AbortBuildException, CoreException {
    super.abortOnBadSetup(javaProject, projectState);

    IProject iProject = getProject();//w w w  .jav a2 s .c  om

    // do a (hopefully quick) search for Precompiler type markers. Those are always only
    // errors.
    stopOnMarker(iProject, AdtConstants.MARKER_AAPT_COMPILE, IResource.DEPTH_INFINITE, false /*checkSeverity*/);
    stopOnMarker(iProject, AdtConstants.MARKER_AIDL, IResource.DEPTH_INFINITE, false /*checkSeverity*/);
    stopOnMarker(iProject, AdtConstants.MARKER_RENDERSCRIPT, IResource.DEPTH_INFINITE, false /*checkSeverity*/);
    stopOnMarker(iProject, AdtConstants.MARKER_ANDROID, IResource.DEPTH_ZERO, false /*checkSeverity*/);

    // do a search for JDT markers. Those can be errors or warnings
    stopOnMarker(iProject, IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, IResource.DEPTH_INFINITE,
            true /*checkSeverity*/);
    stopOnMarker(iProject, IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, IResource.DEPTH_INFINITE,
            true /*checkSeverity*/);
}

From source file:com.android.ide.eclipse.adt.internal.wizards.exportgradle.ProjectSelectionPage.java

License:Open Source License

/**
 * Check if given project has a cyclic dependency.
 * <p>//from www  . j  a va  2 s .  c  o  m
 * See {@link org.eclipse.jdt.core.tests.model.ClasspathTests.numberOfCycleMarkers}
 */
private static boolean hasCyclicDependency(IJavaProject javaProject) throws CoreException {
    IMarker[] markers = javaProject.getProject().findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false,
            IResource.DEPTH_ONE);
    for (IMarker marker : markers) {
        String cycleAttr = (String) marker.getAttribute(IJavaModelMarker.CYCLE_DETECTED);
        if (cycleAttr != null && cycleAttr.equals("true")) { //$NON-NLS-1$
            return true;
        }
    }
    return false;
}

From source file:com.android.ide.eclipse.auidt.internal.build.builders.PostCompilerBuilder.java

License:Open Source License

@Override
protected void abortOnBadSetup(IJavaProject javaProject) throws AbortBuildException {
    super.abortOnBadSetup(javaProject);

    IProject iProject = getProject();/* ww  w.  j av a  2  s.  co  m*/

    // do a (hopefully quick) search for Precompiler type markers. Those are always only
    // errors.
    stopOnMarker(iProject, AdtConstants.MARKER_AAPT_COMPILE, IResource.DEPTH_INFINITE, false /*checkSeverity*/);
    stopOnMarker(iProject, AdtConstants.MARKER_AIDL, IResource.DEPTH_INFINITE, false /*checkSeverity*/);
    stopOnMarker(iProject, AdtConstants.MARKER_RENDERSCRIPT, IResource.DEPTH_INFINITE, false /*checkSeverity*/);
    stopOnMarker(iProject, AdtConstants.MARKER_ANDROID, IResource.DEPTH_ZERO, false /*checkSeverity*/);

    // do a search for JDT markers. Those can be errors or warnings
    stopOnMarker(iProject, IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, IResource.DEPTH_INFINITE,
            true /*checkSeverity*/);
    stopOnMarker(iProject, IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, IResource.DEPTH_INFINITE,
            true /*checkSeverity*/);
}

From source file:com.redhat.ceylon.eclipse.core.classpath.CeylonClasspathContainer.java

License:Apache License

private static Collection<IClasspathEntry> findModuleArchivePaths(IJavaProject javaProject, IProject project,
        TypeChecker typeChecker) throws JavaModelException, CoreException {
    final Collection<IClasspathEntry> paths = new LinkedHashSet<IClasspathEntry>();

    Context context = typeChecker.getContext();
    RepositoryManager provider = context.getRepositoryManager();
    Set<Module> modulesToAdd = context.getModules().getListOfModules();
    //modulesToAdd.add(projectModules.getLanguageModule());        
    for (Module module : modulesToAdd) {
        String name = module.getNameAsString();
        if (name.equals(Module.DEFAULT_MODULE_NAME) || JDKUtils.isJDKModule(name)
                || JDKUtils.isOracleJDKModule(name) || isProjectModule(javaProject, module)) {
            continue;
        }// w ww. ja  v a2  s. c om
        IPath modulePath = getModuleArchive(provider, module);
        if (modulePath != null) {
            //if (!project.getLocation().isPrefixOf(modulePath)) {
            IPath srcPath = null;
            for (IProject p : project.getReferencedProjects()) {
                if (p.isAccessible() && p.getLocation().isPrefixOf(modulePath)) {
                    //the module belongs to a referenced
                    //project, so use the project source
                    srcPath = p.getLocation();
                    break;
                }
            }
            if (srcPath == null) {
                //otherwise, use the src archive
                srcPath = getSourceArchive(provider, module);
            }
            paths.add(newLibraryEntry(modulePath, srcPath, null));
            //}

        } else {
            // FIXME: ideally we should find the module.java file and put the marker there, but
            // I've no idea how to find it and which import is the cause of the import problem
            // as it could be transitive
            IMarker marker = project.createMarker(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER);
            marker.setAttribute(IMarker.MESSAGE, "no module archive found for classpath container: "
                    + module.getNameAsString() + "/" + module.getVersion());
            marker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
            marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
        }
    }

    if (isExplodeModulesEnabled(project)) {
        paths.add(newLibraryEntry(getCeylonClassesOutputFolder(project).getFullPath(), project.getFullPath(),
                null, true));
    }

    return paths;
}

From source file:com.redhat.ceylon.eclipse.core.classpath.CeylonProjectModulesContainer.java

License:Apache License

private Collection<IClasspathEntry> findModuleArchivePaths(IJavaProject javaProject, IProject project,
        TypeChecker typeChecker) throws JavaModelException, CoreException {
    final Map<String, IClasspathEntry> paths = new TreeMap<String, IClasspathEntry>();

    Context context = typeChecker.getContext();
    RepositoryManager provider = context.getRepositoryManager();
    Set<Module> modulesToAdd = context.getModules().getListOfModules();
    //modulesToAdd.add(projectModules.getLanguageModule());        
    for (Module module : modulesToAdd) {
        JDTModule jdtModule = (JDTModule) module;
        String name = module.getNameAsString();
        if (name.equals(Module.DEFAULT_MODULE_NAME) || JDKUtils.isJDKModule(name)
                || JDKUtils.isOracleJDKModule(name) || module.equals(module.getLanguageModule())
                || isProjectModule(javaProject, module) || !module.isAvailable()) {
            continue;
        }//from   ww w  . j a  v a2 s. co m
        IPath modulePath = getModuleArchive(provider, jdtModule);
        if (modulePath != null) {
            IPath srcPath = null;

            for (IProject p : project.getReferencedProjects()) {
                if (p.isAccessible() && p.getLocation().isPrefixOf(modulePath)) {
                    //the module belongs to a referenced
                    //project, so use the project source
                    srcPath = p.getLocation();
                    break;
                }
            }

            if (srcPath == null) {
                for (IClasspathEntry entry : classpathEntries) {
                    if (entry.getPath().equals(modulePath)) {
                        srcPath = entry.getSourceAttachmentPath();
                        break;
                    }
                }
            }

            if (srcPath == null && !modulesWithSourcesAlreadySearched.contains(module.toString())) {
                //otherwise, use the src archive
                srcPath = getSourceArchive(provider, jdtModule);
            }
            modulesWithSourcesAlreadySearched.add(module.toString());
            IClasspathEntry newEntry = newLibraryEntry(modulePath, srcPath, null);
            paths.put(newEntry.toString(), newEntry);

        } else {
            // FIXME: ideally we should find the module.java file and put the marker there, but
            // I've no idea how to find it and which import is the cause of the import problem
            // as it could be transitive
            IMarker marker = project.createMarker(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER);
            marker.setAttribute(IMarker.MESSAGE, "no module archive found for classpath container: "
                    + module.getNameAsString() + "/" + module.getVersion());
            marker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
            marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
        }
    }

    if (isExplodeModulesEnabled(project)) {
        IClasspathEntry newEntry = newLibraryEntry(getCeylonClassesOutputFolder(project).getFullPath(),
                project.getFullPath(), null, false);
        paths.put(newEntry.toString(), newEntry);
    }

    return asList(paths.values().toArray(new IClasspathEntry[paths.size()]));
}

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

License:Open Source License

private boolean isClasspathBroken(IClasspathEntry[] classpath, IProject p) throws CoreException {
    IMarker[] markers = p.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
    for (int i = 0, l = markers.length; i < l; i++)
        if (markers[i].getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR)
            return true;
    return false;
}

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  ww  w . j a v a2 s  .  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;
}

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

License:Open Source License

private boolean isClasspathBroken(IClasspathEntry[] classpath, IProject p) throws CoreException {
    IMarker[] markers = p.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
    for (int i = 0, l = markers.length; i < l; i++) {
        if (markers[i].getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR) {
            return true;
        }//from w  ww  . j  av  a  2 s . c o  m
    }
    return false;
}

From source file:org.eclipse.ajdt.core.tests.builder.Bug268609Test.java

License:Open Source License

public void testOldStyleSettingsNotReapplied() throws Exception {
    hasAspectPath.build(IncrementalProjectBuilder.CLEAN_BUILD, null);
    hasAspectPath.build(IncrementalProjectBuilder.FULL_BUILD, null);

    IFile settingsFile = hasAspectPath.getFile(settingsFilePath);
    assertTrue(".settings folder should exist", settingsFile.exists());
    String contents = getContents(settingsFile);
    assertTrue("The settings file should contain \"org.eclipse.ajdt.ui.aspectPath=visited\"",
            contents.indexOf("org.eclipse.ajdt.ui.aspectPath=visited") != -1);
    assertTrue("Aspect path line should still exist \"org.eclipse.ajdt.ui.aspectPath1=/MyAspectLibrary/bin\"",
            contents.indexOf("org.eclipse.ajdt.ui.aspectPath1=/MyAspectLibrary/bin") != -1);

    // no in path, so this line should not appear
    assertTrue("The settings file should contain \"org.eclipse.ajdt.ui.inPath=visited\"",
            contents.indexOf("org.eclipse.ajdt.ui.inPath=visited") == -1);

    // now check that build did not produce any errors, indicating that
    // the classpath is stil valid
    assertEquals("Project should not have any errors on it", 0, hasAspectPath
            .findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE).length);
    assertEquals("Project should not have any errors on it", 0, hasAspectPath
            .findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE).length);

}

From source file:org.eclipse.andmore.internal.build.builders.PostCompilerBuilder.java

License:Open Source License

@Override
protected void abortOnBadSetup(@NonNull IJavaProject javaProject, @Nullable ProjectState projectState)
        throws AbortBuildException, CoreException {
    super.abortOnBadSetup(javaProject, projectState);

    IProject iProject = getProject();/*w  w  w.  jav a  2s. c o  m*/

    // do a (hopefully quick) search for Precompiler type markers. Those are always only
    // errors.
    stopOnMarker(iProject, AndmoreAndroidConstants.MARKER_AAPT_COMPILE, IResource.DEPTH_INFINITE,
            false /*checkSeverity*/);
    stopOnMarker(iProject, AndmoreAndroidConstants.MARKER_AIDL, IResource.DEPTH_INFINITE,
            false /*checkSeverity*/);
    stopOnMarker(iProject, AndmoreAndroidConstants.MARKER_RENDERSCRIPT, IResource.DEPTH_INFINITE,
            false /*checkSeverity*/);
    stopOnMarker(iProject, AndmoreAndroidConstants.MARKER_ANDROID, IResource.DEPTH_ZERO,
            false /*checkSeverity*/);

    // do a search for JDT markers. Those can be errors or warnings
    stopOnMarker(iProject, IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, IResource.DEPTH_INFINITE,
            true /*checkSeverity*/);
    stopOnMarker(iProject, IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, IResource.DEPTH_INFINITE,
            true /*checkSeverity*/);
}