View | Details | Raw Unified | Return to bug 245566 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/ajdt/core/tests/ajde/CoreCompilerConfigurationTests2.java (+35 lines)
Lines 1-6 Link Here
1
package org.eclipse.ajdt.core.tests.ajde;
1
package org.eclipse.ajdt.core.tests.ajde;
2
2
3
import java.io.StringReader;
3
import java.io.StringReader;
4
import java.util.List;
4
5
5
import org.eclipse.ajdt.core.AspectJCorePreferences;
6
import org.eclipse.ajdt.core.AspectJCorePreferences;
6
import org.eclipse.ajdt.core.AspectJPlugin;
7
import org.eclipse.ajdt.core.AspectJPlugin;
Lines 8-15 Link Here
8
import org.eclipse.ajdt.core.tests.testutils.ReaderInputStream;
9
import org.eclipse.ajdt.core.tests.testutils.ReaderInputStream;
9
import org.eclipse.ajdt.core.tests.testutils.TestLogger;
10
import org.eclipse.ajdt.core.tests.testutils.TestLogger;
10
import org.eclipse.ajdt.core.tests.testutils.Utils;
11
import org.eclipse.ajdt.core.tests.testutils.Utils;
12
import org.eclipse.core.resources.IMarker;
11
import org.eclipse.core.resources.IProject;
13
import org.eclipse.core.resources.IProject;
14
import org.eclipse.core.resources.IResource;
12
import org.eclipse.core.resources.IncrementalProjectBuilder;
15
import org.eclipse.core.resources.IncrementalProjectBuilder;
16
import org.eclipse.jdt.core.IJavaModelMarker;
13
17
14
/**
18
/**
15
 * this set of tests ensures that the CoreCompilerConfiguration.getClasspathElementsWithModifiedContents() method 
19
 * this set of tests ensures that the CoreCompilerConfiguration.getClasspathElementsWithModifiedContents() method 
Lines 207-210 Link Here
207
        // ensure that this is the only time the list has been set
211
        // ensure that this is the only time the list has been set
208
        assertEquals(2, testLog.numberOfEntriesForMessage("Setting list of classpath elements with modified contents:"));
212
        assertEquals(2, testLog.numberOfEntriesForMessage("Setting list of classpath elements with modified contents:"));
209
    }
213
    }
214
    
215
    /**
216
     * Test that when a jar on the classpath resides in a closed project
217
     * there is an error and the build is aborted.
218
     */
219
    public void testInvalidClasspath() throws Exception {
220
        // incremental build
221
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
222
        waitForAutoBuild();
223
224
        testLog.clearLog();
225
226
        ap3.close(null);
227
        
228
        // incremental build
229
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
230
        waitForAutoBuild();
231
232
        IMarker[] markers = myProj.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, 
233
                false, IResource.DEPTH_ZERO);
234
235
        assertEquals("Should have a single marker on the project", 1, markers.length);
236
        assertEquals("Marker on project should be an error", IMarker.SEVERITY_ERROR, markers[0].getAttribute(IMarker.SEVERITY, -1));
237
        
238
        // now check the log for an aborted message
239
        // the last 3 messages should be about aborting the build
240
        List entries = testLog.getMostRecentEntries(3);
241
        assertEquals("build: Abort due to missing inpath/aspectpath/classpath entries", entries.get(0));
242
        assertEquals("Removed problems and tasks for project AspectProjWeCareAbout", entries.get(2));
243
    }
244
    
210
}
245
}
(-)workspace/JavaProj3-ClassFolder/src/Nothing3.java (+1 lines)
Added Link Here
1
class Nothing3 { }
(-)workspace/JavaProj2-On (+1 lines)
Added Link Here
1
class Nothing2 { }
(-)workspace/AspectProj1/src/Nothing.java (+1 lines)
Added Link Here
1
class Nothing { }
(-)src/org/eclipse/ajdt/core/builder/AJBuilder.java (-8 / +43 lines)
Lines 69-78 Link Here
69
import org.eclipse.jdt.core.IJavaProject;
69
import org.eclipse.jdt.core.IJavaProject;
70
import org.eclipse.jdt.core.JavaCore;
70
import org.eclipse.jdt.core.JavaCore;
71
import org.eclipse.jdt.core.JavaModelException;
71
import org.eclipse.jdt.core.JavaModelException;
72
import org.eclipse.jdt.core.compiler.CategorizedProblem;
72
import org.eclipse.jdt.internal.core.ClasspathEntry;
73
import org.eclipse.jdt.internal.core.ClasspathEntry;
73
import org.eclipse.jdt.internal.core.JavaModelManager;
74
import org.eclipse.jdt.internal.core.JavaModelManager;
74
import org.eclipse.jdt.internal.core.JavaProject;
75
import org.eclipse.jdt.internal.core.JavaProject;
75
import org.eclipse.jdt.internal.core.builder.State;
76
import org.eclipse.jdt.internal.core.builder.State;
77
import org.eclipse.jdt.internal.core.util.Messages;
76
import org.eclipse.jdt.internal.core.util.Util;
78
import org.eclipse.jdt.internal.core.util.Util;
77
import org.eclipse.osgi.util.NLS;
79
import org.eclipse.osgi.util.NLS;
78
import org.osgi.service.prefs.BackingStoreException;
80
import org.osgi.service.prefs.BackingStoreException;
Lines 132-145 Link Here
132
		AJLog.log(AJLog.BUILDER,"Project=" //$NON-NLS-1$
134
		AJLog.log(AJLog.BUILDER,"Project=" //$NON-NLS-1$
133
				+ project.getName() + ", kind of build requested=" + mode); //$NON-NLS-1$
135
				+ project.getName() + ", kind of build requested=" + mode); //$NON-NLS-1$
134
		
136
		
135
		// bug 159197: check inpath and aspectpath
137
		if (!isWorthBuilding(project, requiredProjects)) {
136
		if (!validateInpathAspectPath(project)) {
138
		    postCallListeners(true);
137
			postCallListeners(true);
139
		    progressMonitor.done();
138
			AJLog.log(AJLog.BUILDER,
140
		    return requiredProjects;
139
					"build: Abort due to missing inpath/aspectpath entries"); //$NON-NLS-1$
140
			AJLog.logEnd(AJLog.BUILDER, TimerLogEvent.TIME_IN_BUILD);
141
			progressMonitor.done();
142
			return requiredProjects;
143
		}
141
		}
144
		
142
		
145
		// workaround for bug 73435
143
		// workaround for bug 73435
Lines 257-262 Link Here
257
		return requiredProjects;
255
		return requiredProjects;
258
	}
256
	}
259
257
258
	/**
259
	 * Check to see if the class paths are valid
260
	 * @param progressMonitor
261
	 * @param project
262
	 * @param requiredProjects
263
	 * @return true if aspect, in, and class paths are valid.  False if there is a problem
264
	 * @throws CoreException
265
	 */
266
    private boolean isWorthBuilding(IProject project, IProject[] requiredProjects) throws CoreException {
267
        // bug 159197: check inpath and aspectpath
268
        // and classpath
269
		if (!validateInpathAspectPath(project) ||
270
		        isClasspathBroken(JavaCore.create(project).getRawClasspath(), project)) {
271
			AJLog.log(AJLog.BUILDER,
272
					"build: Abort due to missing inpath/aspectpath/classpath entries"); //$NON-NLS-1$
273
			AJLog.logEnd(AJLog.BUILDER, TimerLogEvent.TIME_IN_BUILD);
274
            removeProblemsAndTasksFor(project); // make this the only problem for this project
275
			return false;
276
		}
277
		return true;
278
    }
279
260
	// check to see if the .classpath has changed.
280
	// check to see if the .classpath has changed.
261
	// we know exactly where it is located, so no need for a visitor
281
	// we know exactly where it is located, so no need for a visitor
262
    private boolean classpathChanged(IResourceDelta dta, IProject project) {
282
    private boolean classpathChanged(IResourceDelta dta, IProject project) {
Lines 504-509 Link Here
504
		return success;
524
		return success;
505
	}
525
	}
506
	
526
	
527
528
	private boolean isClasspathBroken(IClasspathEntry[] classpath, IProject p) throws CoreException {
529
	    IMarker[] markers = p.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, 
530
	            false, IResource.DEPTH_ZERO);
531
	    for (int i = 0, l = markers.length; i < l; i++) {
532
	        if (markers[i].getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR) {
533
	            markProject(p, Messages.bind(Messages.build_prereqProjectHasClasspathProblems, 
534
	                    p.getName()));
535
	            return true;
536
	        }
537
	    }
538
	    return false;
539
	}
540
541
	
507
	private void markProject(IProject project, String errorMessage) {
542
	private void markProject(IProject project, String errorMessage) {
508
		try {
543
		try {
509
			IMarker errorMarker = project.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
544
			IMarker errorMarker = project.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);

Return to bug 245566