private void validateBuildProperties(IProgressMonitor monitor) { if (monitor.isCanceled()) return; IProject project = getProject(); IFile file = PDEProject.getBuildProperties(project); if (file.exists()) { monitor.subTask(PDECoreMessages.ManifestConsistencyChecker_buildPropertiesSubtask); BuildErrorReporter ber = new BuildErrorReporter(file); ber.validateContent(monitor); } }
private void reportErrors(BuildModel bm) { if (bm == null) return; for (int i = 0; i < fProblemList.size(); i++) { BuildProblem bp = (BuildProblem)fProblemList.get(i); int lineNum; IBuildEntry buildEntry = bm.getBuild().getEntry(bp.fEntryName); if (buildEntry == null || bp.fEntryName == null) // general file case (eg. missing source.* entry) lineNum = 1; else // issue with a particular entry lineNum = getLineNumber(buildEntry, bp.fEntryToken); if (lineNum > 0) report(bp.fMessage, lineNum, bp.fFixId, bp.fEntryName, bp.fEntryToken, bp.fSeverity, bp.fCategory); } }
String name = entries[i].getName(); if (entries[i].getTokens().length == 0) prepareError(name, null, PDECoreMessages.BuildErrorReporter_emptyEntry, PDEMarkerFactory.B_REMOVAL, validateJarsExtraClasspath(jarsExtra); if (bundleList != null) validateDependencyManagement(bundleList); return; validateIncludes(binIncludes, sourceEntryKeys); validateIncludes(srcIncludes, sourceEntryKeys); IJavaProject jp = JavaCore.create(fProject); IClasspathEntry[] cpes = jp.getRawClasspath(); validateMissingLibraries(sourceEntryKeys, cpes); validateSourceEntries(sourceEntries, cpes); validateSourceEntries(sourceEntries); validateMissingSourceInBinIncludes(binIncludes, sourceEntryKeys, build); validateBinIncludes(binIncludes);
@Override public void validate(IProgressMonitor monitor) { /*if (fBuildSeverity == CompilerFlags.IGNORE && fClasspathSeverity == CompilerFlags.IGNORE) return;*/ WorkspaceBuildModel wbm = new WorkspaceBuildModel(fFile); wbm.load(); if (!wbm.isLoaded()) return; // check build and store all found errors validateBuild(wbm.getBuild(true)); // if there are any errors report using the text model if (fProblemList.size() > 0) reportErrors(prepareTextBuildModel(monitor)); }
private void validateSourceEntries(ArrayList sourceEntries, IClasspathEntry[] cpes) { String[] unlisted = getUnlistedClasspaths(sourceEntries, fProject, cpes); StringBuffer sb = new StringBuffer(); for (int i = 0; i < unlisted.length; i++) { if (unlisted[i] == null) break; if (sb.length() > 0) sb.append(", "); //$NON-NLS-1$ sb.append(unlisted[i]); } String unlistedEntries = sb.toString(); if (sb.length() == 0) return; if (sourceEntries.size() == 1) { String name = ((IBuildEntry)sourceEntries.get(0)).getName(); prepareError(name, null, NLS.bind(PDECoreMessages.BuildErrorReporter_classpathEntryMissing1, unlistedEntries, name), PDEMarkerFactory.B_SOURCE_ADDITION, PDEMarkerFactory.CAT_OTHER); } else prepareError(DEF_SOURCE_ENTRY, null, NLS.bind(PDECoreMessages.BuildErrorReporter_classpathEntryMissing, unlistedEntries), PDEMarkerFactory.B_SOURCE_ADDITION, PDEMarkerFactory.CAT_OTHER); }
String name = entries[i].getName(); if (entries[i].getTokens().length == 0) prepareError(name, null, PDECoreMessages.BuildErrorReporter_emptyEntry, PDEMarkerFactory.B_REMOVAL, PDEMarkerFactory.CAT_FATAL); else if (name.equals(PROPERTY_BIN_INCLUDES)) binIncludes = entries[i]; validateDependencyManagement(bundleList); validateJarsExtraClasspath(jarsExtra); validateIncludes(binIncludes, sourceEntryKeys, fBinInclSeverity); validateIncludes(binExcludes, sourceEntryKeys, fBinInclSeverity); validateIncludes(srcIncludes, sourceEntryKeys, fSrcInclSeverity); validateIncludes(srcExcludes, sourceEntryKeys, fSrcInclSeverity); validateSourceFoldersInSrcIncludes(srcIncludes); if (jp.exists()) { IClasspathEntry[] cpes = jp.getRawClasspath(); validateMissingLibraries(sourceEntryKeys, cpes); validateSourceEntries(sourceEntries, srcExcludes, cpes); SourceEntryErrorReporter srcEntryErrReporter = new SourceEntryErrorReporter(fFile, build); srcEntryErrReporter.initialize(sourceEntries, outputEntries, cpes, fProject); validateMissingSourceInBinIncludes(binIncludes, sourceEntryKeys, build); validateBinIncludes(binIncludes); validateExecutionEnvironment(javacSource, javacTarget, jreCompilationProfile, javacWarnings, javacErrors, getSourceLibraries(sourceEntries)); validateJavaCompilerSettings(javaProjectWarnings);
private void prepareError(String name, String token, String message, int fixId, String category) { prepareError(name, token, message, fixId, fBuildSeverity, category); }
if ((mh == null || mh.getValue() == null)) { if (!sourceEntryKeys.contains(DEF_SOURCE_ENTRY)) { prepareError(DEF_SOURCE_ENTRY, null, PDECoreMessages.BuildErrorReporter_sourceMissing, PDEMarkerFactory.NO_RESOLUTION, fSrcLibSeverity, PDEMarkerFactory.CAT_OTHER); if (libname.equals(".")) { //$NON-NLS-1$ if (!sourceEntryKeys.contains(DEF_SOURCE_ENTRY)) { prepareError(DEF_SOURCE_ENTRY, null, PDECoreMessages.BuildErrorReporter_sourceMissing, PDEMarkerFactory.NO_RESOLUTION, fSrcLibSeverity, PDEMarkerFactory.CAT_OTHER); continue; if (!sourceEntryKeys.contains(sourceEntryKey) && !containedInFragment(model.getBundleDescription(), libname)) prepareError(sourceEntryKey, null, NLS.bind(PDECoreMessages.BuildErrorReporter_missingEntry, sourceEntryKey), PDEMarkerFactory.B_ADDITION, PDEMarkerFactory.CAT_OTHER);
if (projectComplianceLevel.equals(findMatchingEE(projectSourceCompatibility, projectClassCompatibility, false)) && execEnv.equals(findMatchingEE(projectSourceCompatibility, projectClassCompatibility, true))) { return; //The project compliance settings matches the BREE String projectJavaCompatibility = findMatchingEE(projectSourceCompatibility, projectClassCompatibility, true); String message = null; if (projectJavaCompatibility != null) { if (jreCompilationProfileEntry == null) { message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry, PROPERTY_JRE_COMPILATION_PROFILE, PDECoreMessages.BuildErrorReporter_CompilercomplianceLevel); prepareError(PROPERTY_JRE_COMPILATION_PROFILE, projectJavaCompatibility, message, PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE); } else { if (!projectJavaCompatibility.equalsIgnoreCase(jreCompilationProfileEntry.getTokens()[0])) { message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JRE_COMPILATION_PROFILE, PDECoreMessages.BuildErrorReporter_CompilercomplianceLevel); prepareError(PROPERTY_JRE_COMPILATION_PROFILE, projectJavaCompatibility, message, PDEMarkerFactory.B_REPLACE, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE); if (javacSourceEntry != null) { message = NLS.bind(PDECoreMessages.BuildErrorReporter_BuildEntryNotRequiredMatchesDefault, PROPERTY_JAVAC_SOURCE, PDECoreMessages.BuildErrorReporter_SourceCompatibility); prepareError(PROPERTY_JAVAC_SOURCE, null, message, PDEMarkerFactory.B_REMOVAL, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE); prepareError(PROPERTY_JAVAC_SOURCE, projectSourceCompatibility, message, PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE); } else { if (!projectSourceCompatibility.equalsIgnoreCase(javacSourceEntry.getTokens()[0])) { message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JAVAC_SOURCE, PDECoreMessages.BuildErrorReporter_SourceCompatibility); prepareError(PROPERTY_JAVAC_SOURCE, projectSourceCompatibility, message, PDEMarkerFactory.B_REPLACE, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE); if (javacTargetEntry != null) { message = NLS.bind(PDECoreMessages.BuildErrorReporter_BuildEntryNotRequiredMatchesDefault, PROPERTY_JAVAC_TARGET, PDECoreMessages.BuildErrorReporter_GeneratedClassFilesCompatibility); prepareError(PROPERTY_JAVAC_TARGET, null, message, PDEMarkerFactory.B_REMOVAL, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE); prepareError(PROPERTY_JAVAC_TARGET, projectClassCompatibility, message, PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE);
private void validateBinIncludes(IBuildEntry binIncludes) { validateBinIncludes(binIncludes, ICoreConstants.MANIFEST_FOLDER_NAME); try { if (OSGinf.members().length > 0) { // only validate if we have something in it validateBinIncludes(binIncludes, ICoreConstants.OSGI_INF_FOLDER_NAME); validateBinIncludes(binIncludes, ICoreConstants.FRAGMENT_FILENAME_DESCRIPTOR); validateBinIncludes(binIncludes, ICoreConstants.PLUGIN_FILENAME_DESCRIPTOR); validateFragmentContributions(binIncludes); validateApplicationContributions(binIncludes); validateBinIncludes(binIncludes, entry);
BuildErrorReporter buildErrorReporter = new BuildErrorReporter(fManifestFile); IResource buildXML = project.findMember("build.xml"); //$NON-NLS-1$ if (buildXML != null && buildXML.exists() == true && buildErrorReporter.isCustomBuild() == true) { IStatus warnFail = new Status(IStatus.WARNING, model.getPluginBase().getId(), PDEUIMessages.BuildPluginAction_WarningCustomBuildExists); throw new CoreException(warnFail);
if (startsWithAntVariable(token)) prepareError(includes.getName(), token, message, fixId, severity, PDEMarkerFactory.CAT_OTHER);
for (Iterator<String> iterator2 = complianceWarnSettings.iterator(); iterator2.hasNext();) { String currentIdentifier = iterator2.next(); missingTokens = join(missingTokens, '-' + currentIdentifier); prepareError(PROPERTY_JAVAC_WARNINGS_PREFIX + libName, missingTokens, message, PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE); } else { String missingTokens = ""; //$NON-NLS-1$ String currentIdentifier = iterator2.next(); if (!matchingEntry.contains(currentIdentifier) && !matchingEntry.contains('+' + currentIdentifier) && !matchingEntry.contains('-' + currentIdentifier)) { join(missingTokens, '-' + currentIdentifier); prepareError(PROPERTY_JAVAC_WARNINGS_PREFIX + libName, missingTokens, message, PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE); for (Iterator<String> iterator2 = complianceErrorSettings.iterator(); iterator2.hasNext();) { String currentIdentifier = iterator2.next(); missingTokens = join(missingTokens, '-' + currentIdentifier); prepareError(PROPERTY_JAVAC_ERRORS_PREFIX + libName, missingTokens, message, PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE); } else { String missingTokens = ""; //$NON-NLS-1$ String currentIdentifier = iterator2.next(); if (!matchingEntry.contains(currentIdentifier) && !matchingEntry.contains('+' + currentIdentifier) && !matchingEntry.contains('-' + currentIdentifier)) { missingTokens = join(missingTokens, '-' + currentIdentifier); prepareError(PROPERTY_JAVAC_ERRORS_PREFIX + libName, missingTokens, message, PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE);
private void validateFragmentContributions(IBuildEntry binIncludes) { try { Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(PDEProject.getPluginXml(fProject).getContents()); XPath xpath = XPathFactory.newInstance().newXPath(); NodeList list = (NodeList) xpath.evaluate("/plugin/extension[@point='org.eclipse.e4.workbench.model']/fragment/@uri", doc, XPathConstants.NODESET); //$NON-NLS-1$ for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); validateBinIncludes(binIncludes, node.getNodeValue()); } } catch (Exception e) { e.printStackTrace(); } }
private void report(String message, int line, int problemID, String buildEntry, String buildToken, int severity, String category) { IMarker marker = report(message, line, severity, problemID, category); if (marker == null) return; try { marker.setAttribute(PDEMarkerFactory.BK_BUILD_ENTRY, buildEntry); marker.setAttribute(PDEMarkerFactory.BK_BUILD_TOKEN, buildToken); } catch (CoreException e) { } }
private BuildModel prepareTextBuildModel(IProgressMonitor monitor) { try { IDocument doc = createDocument(fFile); if (doc == null) return null; BuildModel bm = new BuildModel(doc, true); bm.load(); if (!bm.isLoaded()) return null; return bm; } catch (CoreException e) { PDECore.log(e); return null; } }
public void validate(IProgressMonitor monitor) { fBuildSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD); fClasspathSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_UNRESOLVED_IMPORTS); if (fBuildSeverity == CompilerFlags.IGNORE && fClasspathSeverity == CompilerFlags.IGNORE) return; WorkspaceBuildModel wbm = new WorkspaceBuildModel(fFile); wbm.load(); if (!wbm.isLoaded()) return; // check build and store all found errors validateBuild(wbm.getBuild(true)); // if there are any errors report using the text model if (fProblemList.size() > 0) reportErrors(prepareTextBuildModel(monitor)); }
protected BuildProblem prepareError(String name, String token, String message, int fixId, String category) { return prepareError(name, token, message, fixId, fBuildSeverity, category); }
if (cpes[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) { if (!sourceEntryKeys.contains(DEF_SOURCE_ENTRY)) prepareError(DEF_SOURCE_ENTRY, null, PDECoreMessages.BuildErrorReporter_sourceMissing, PDEMarkerFactory.NO_RESOLUTION, if (cpes[j].getEntryKind() == IClasspathEntry.CPE_SOURCE) { if (!sourceEntryKeys.contains(DEF_SOURCE_ENTRY)) prepareError(DEF_SOURCE_ENTRY, null, PDECoreMessages.BuildErrorReporter_sourceMissing, PDEMarkerFactory.NO_RESOLUTION, && !containedInFragment(model.getBundleDescription(), libname)) prepareError(sourceEntryKey, null, NLS.bind(PDECoreMessages.BuildErrorReporter_missingEntry, sourceEntryKey), PDEMarkerFactory.B_SOURCE_ADDITION,
exists = projectPath.append(tokens[i]).toFile().exists(); if (!exists && !startsWithAntVariable(tokens[i])) { prepareError(PROPERTY_JAR_EXTRA_CLASSPATH, tokens[i], NLS.bind(PDECoreMessages.BuildErrorReporter_cannotFindJar, tokens[i]), PDEMarkerFactory.NO_RESOLUTION, fBuildSeverity, PDEMarkerFactory.CAT_OTHER);