/** * Returns a Java model status describing the problem related to this classpath entry if any, a * status object with code <code>IStatus.OK</code> if the entry is fine (that is, if the given * classpath entry denotes a valid element to be referenced onto a classpath). * * @param project the given java project * @param entry the given classpath entry * @param checkSourceAttachment a flag to determine if source attachment should be checked * @return a java model status describing the problem related to this classpath entry if any, a * status object with code <code>IStatus.OK</code> if the entry is fine * @since 2.0 */ public static IJavaModelStatus validateClasspathEntry( IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment) { return ClasspathEntry.validateClasspathEntry( project, entry, checkSourceAttachment, false /*not referred by container*/); }
/** * Validate a given classpath and output location for a project, using the following rules: * * <ul> * <li>Classpath entries cannot collide with each other; that is, all entry paths must be * unique. * <li>The project output location path cannot be null, must be absolute and located inside the * project. * <li>Specific output locations (specified on source entries) can be null, if not they must be * located inside the project, * <li>A project entry cannot refer to itself directly (that is, a project cannot prerequisite * itself). * <li>Classpath entries or output locations cannot coincide or be nested in each other, except * for the following scenarios listed below: * <ul> * <li>A source folder can coincide with its own output location, in which case this * output can then contain library archives. However, a specific output location * cannot coincide with any library or a distinct source folder than the one referring * to it.<br> * Note: Since 3.8, this behavior can be overridden by configuring {@link * JavaCore#CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE} * <li>A source/library folder can be nested in any source folder as long as the nested * folder is excluded from the enclosing one. * <li>An output location can be nested in a source folder, if the source folder coincides * with the project itself, or if the output location is excluded from the source * folder. * </ul> * </ul> * * Note that the classpath entries are not validated automatically. Only bound variables or * containers are considered in the checking process (this allows to perform a consistency check * on a classpath which has references to yet non existing projects, folders, ...). * * <p>This validation is intended to anticipate classpath issues prior to assigning it to a * project. In particular, it will automatically be performed during the classpath setting * operation (if validation fails, the classpath setting will not complete). * * <p> * * @param javaProject the given java project * @param rawClasspath the given classpath * @param projectOutputLocation the given output location * @return a status object with code <code>IStatus.OK</code> if the given classpath and output * location are compatible, otherwise a status object indicating what is wrong with the * classpath or output location * @since 2.0 */ public static IJavaModelStatus validateClasspath( IJavaProject javaProject, IClasspathEntry[] rawClasspath, IPath projectOutputLocation) { return ClasspathEntry.validateClasspath(javaProject, rawClasspath, projectOutputLocation); }