11/*******************************************************************************
2- * Copyright (c) 2000, 2013 IBM Corporation and others.
2+ * Copyright (c) 2000, 2011 IBM Corporation and others.
33 * All rights reserved. This program and the accompanying materials
44 * are made available under the terms of the Eclipse Public License v1.0
55 * which accompanies this distribution, and is available at
1212
1313import org .eclipse .core .resources .*;
1414import org .eclipse .core .runtime .*;
15+
1516import org .eclipse .jdt .core .*;
1617import org .eclipse .jdt .core .compiler .*;
1718import org .eclipse .jdt .internal .compiler .util .SimpleLookupTable ;
2021import org .eclipse .jdt .internal .core .util .Util ;
2122
2223import java .io .*;
23- import java .lang .reflect .InvocationTargetException ;
24- import java .lang .reflect .Method ;
2524import java .util .*;
2625
2726public class JavaBuilder extends IncrementalProjectBuilder {
@@ -158,7 +157,7 @@ protected IProject[] build(int kind, Map ignored, IProgressMonitor monitor) thro
158157 if (this .currentProject == null || !this .currentProject .isAccessible ()) return new IProject [0 ];
159158
160159 if (DEBUG )
161- System .out .println ("\n JavaBuilder: Starting build of " + this .currentProject .getName () //$NON-NLS-1$
160+ System .out .println ("\n Starting build of " + this .currentProject .getName () //$NON-NLS-1$
162161 + " @ " + new Date (System .currentTimeMillis ())); //$NON-NLS-1$
163162 this .notifier = new BuildNotifier (monitor , this .currentProject );
164163 this .notifier .begin ();
@@ -170,39 +169,39 @@ protected IProject[] build(int kind, Map ignored, IProgressMonitor monitor) thro
170169 if (isWorthBuilding ()) {
171170 if (kind == FULL_BUILD ) {
172171 if (DEBUG )
173- System .out .println ("JavaBuilder: Performing full build as requested" ); //$NON-NLS-1$
172+ System .out .println ("Performing full build as requested by user " ); //$NON-NLS-1$
174173 buildAll ();
175174 } else {
176175 if ((this .lastState = getLastState (this .currentProject )) == null ) {
177176 if (DEBUG )
178- System .out .println ("JavaBuilder: Performing full build since last saved state was not found" ); //$NON-NLS-1$
177+ System .out .println ("Performing full build since last saved state was not found" ); //$NON-NLS-1$
179178 buildAll ();
180179 } else if (hasClasspathChanged ()) {
181180 // if the output location changes, do not delete the binary files from old location
182181 // the user may be trying something
183182 if (DEBUG )
184- System .out .println ("JavaBuilder: Performing full build since classpath has changed" ); //$NON-NLS-1$
183+ System .out .println ("Performing full build since classpath has changed" ); //$NON-NLS-1$
185184 buildAll ();
186185 } else if (this .nameEnvironment .sourceLocations .length > 0 ) {
187186 // if there is no source to compile & no classpath changes then we are done
188187 SimpleLookupTable deltas = findDeltas ();
189188 if (deltas == null ) {
190189 if (DEBUG )
191- System .out .println ("JavaBuilder: Performing full build since deltas are missing after incremental request" ); //$NON-NLS-1$
190+ System .out .println ("Performing full build since deltas are missing after incremental request" ); //$NON-NLS-1$
192191 buildAll ();
193192 } else if (deltas .elementSize > 0 ) {
194193 buildDeltas (deltas );
195194 } else if (DEBUG ) {
196- System .out .println ("JavaBuilder: Nothing to build since deltas were empty" ); //$NON-NLS-1$
195+ System .out .println ("Nothing to build since deltas were empty" ); //$NON-NLS-1$
197196 }
198197 } else {
199198 if (hasStructuralDelta ()) { // double check that a jar file didn't get replaced in a binary project
200199 if (DEBUG )
201- System .out .println ("JavaBuilder: Performing full build since there are structural deltas" ); //$NON-NLS-1$
200+ System .out .println ("Performing full build since there are structural deltas" ); //$NON-NLS-1$
202201 buildAll ();
203202 } else {
204203 if (DEBUG )
205- System .out .println ("JavaBuilder: Nothing to build since there are no source folders and no deltas" ); //$NON-NLS-1$
204+ System .out .println ("Nothing to build since there are no source folders and no deltas" ); //$NON-NLS-1$
206205 this .lastState .tagAsNoopBuild ();
207206 }
208207 }
@@ -240,16 +239,16 @@ protected IProject[] build(int kind, Map ignored, IProgressMonitor monitor) thro
240239 }
241240 IProject [] requiredProjects = getRequiredProjects (true );
242241 if (DEBUG )
243- System .out .println ("JavaBuilder: Finished build of " + this .currentProject .getName () //$NON-NLS-1$
244- + " @ " + new Date (System .currentTimeMillis ()) + " \n " ); //$NON-NLS-1$ //$NON-NLS-2 $
242+ System .out .println ("Finished build of " + this .currentProject .getName () //$NON-NLS-1$
243+ + " @ " + new Date (System .currentTimeMillis ())); //$NON-NLS-1$
245244 return requiredProjects ;
246245}
247246
248247private void buildAll () {
249248 this .notifier .checkCancel ();
250249 this .notifier .subTask (Messages .bind (Messages .build_preparingBuild , this .currentProject .getName ()));
251250 if (DEBUG && this .lastState != null )
252- System .out .println ("JavaBuilder: Clearing last state : " + this .lastState ); //$NON-NLS-1$
251+ System .out .println ("Clearing last state : " + this .lastState ); //$NON-NLS-1$
253252 clearLastState ();
254253 BatchImageBuilder imageBuilder = new Java2ScriptBatchImageBuilder (this , true );
255254 imageBuilder .build ();
@@ -260,14 +259,14 @@ private void buildDeltas(SimpleLookupTable deltas) {
260259 this .notifier .checkCancel ();
261260 this .notifier .subTask (Messages .bind (Messages .build_preparingBuild , this .currentProject .getName ()));
262261 if (DEBUG && this .lastState != null )
263- System .out .println ("JavaBuilder: Clearing last state : " + this .lastState ); //$NON-NLS-1$
262+ System .out .println ("Clearing last state : " + this .lastState ); //$NON-NLS-1$
264263 clearLastState (); // clear the previously built state so if the build fails, a full build will occur next time
265264 IncrementalImageBuilder imageBuilder = new Java2ScriptIncrementalImageBuilder (this );
266265 if (imageBuilder .build (deltas )) {
267266 recordNewState (imageBuilder .newState );
268267 } else {
269268 if (DEBUG )
270- System .out .println ("JavaBuilder: Performing full build since incremental build failed" ); //$NON-NLS-1$
269+ System .out .println ("Performing full build since incremental build failed" ); //$NON-NLS-1$
271270 buildAll ();
272271 }
273272}
@@ -277,7 +276,7 @@ protected void clean(IProgressMonitor monitor) throws CoreException {
277276 if (this .currentProject == null || !this .currentProject .isAccessible ()) return ;
278277
279278 if (DEBUG )
280- System .out .println ("\n JavaBuilder: Cleaning " + this .currentProject .getName () //$NON-NLS-1$
279+ System .out .println ("\n Cleaning " + this .currentProject .getName () //$NON-NLS-1$
281280 + " @ " + new Date (System .currentTimeMillis ())); //$NON-NLS-1$
282281 this .notifier = new BuildNotifier (monitor , this .currentProject );
283282 this .notifier .begin ();
@@ -286,7 +285,7 @@ protected void clean(IProgressMonitor monitor) throws CoreException {
286285
287286 initializeBuilder (CLEAN_BUILD , true );
288287 if (DEBUG )
289- System .out .println ("JavaBuilder: Clearing last state as part of clean : " + this .lastState ); //$NON-NLS-1$
288+ System .out .println ("Clearing last state as part of clean : " + this .lastState ); //$NON-NLS-1$
290289 clearLastState ();
291290 removeProblemsAndTasksFor (this .currentProject );
292291 new BatchImageBuilder (this , false ).cleanOutputFolders (false );
@@ -298,7 +297,7 @@ protected void clean(IProgressMonitor monitor) throws CoreException {
298297 cleanup ();
299298 }
300299 if (DEBUG )
301- System .out .println ("JavaBuilder: Finished cleaning " + this .currentProject .getName () //$NON-NLS-1$
300+ System .out .println ("Finished cleaning " + this .currentProject .getName () //$NON-NLS-1$
302301 + " @ " + new Date (System .currentTimeMillis ())); //$NON-NLS-1$
303302}
304303
@@ -367,12 +366,12 @@ private SimpleLookupTable findDeltas() {
367366 if (delta != null ) {
368367 if (delta .getKind () != IResourceDelta .NO_CHANGE ) {
369368 if (DEBUG )
370- System .out .println ("JavaBuilder: Found source delta for: " + this .currentProject .getName ()); //$NON-NLS-1$
369+ System .out .println ("Found source delta for: " + this .currentProject .getName ()); //$NON-NLS-1$
371370 deltas .put (this .currentProject , delta );
372371 }
373372 } else {
374373 if (DEBUG )
375- System .out .println ("JavaBuilder: Missing delta for: " + this .currentProject .getName ()); //$NON-NLS-1$
374+ System .out .println ("Missing delta for: " + this .currentProject .getName ()); //$NON-NLS-1$
376375 this .notifier .subTask ("" ); //$NON-NLS-1$
377376 return null ;
378377 }
@@ -402,12 +401,12 @@ private SimpleLookupTable findDeltas() {
402401 if (delta != null ) {
403402 if (delta .getKind () != IResourceDelta .NO_CHANGE ) {
404403 if (DEBUG )
405- System .out .println ("JavaBuilder: Found binary delta for: " + p .getName ()); //$NON-NLS-1$
404+ System .out .println ("Found binary delta for: " + p .getName ()); //$NON-NLS-1$
406405 deltas .put (p , delta );
407406 }
408407 } else {
409408 if (DEBUG )
410- System .out .println ("JavaBuilder: Missing delta for: " + p .getName ()); //$NON-NLS-1$
409+ System .out .println ("Missing delta for: " + p .getName ()); //$NON-NLS-1$
411410 this .notifier .subTask ("" ); //$NON-NLS-1$
412411 return null ;
413412 }
@@ -515,7 +514,7 @@ private boolean hasClasspathChanged() {
515514 } catch (CoreException ignore ) { // skip it
516515 }
517516 if (DEBUG ) {
518- System .out .println ("JavaBuilder: New location: " + newSourceLocations [n ] + "\n != old location: " + oldSourceLocations [o ]); //$NON-NLS-1$ //$NON-NLS-2$
517+ System .out .println ("New location: " + newSourceLocations [n ] + "\n != old location: " + oldSourceLocations [o ]); //$NON-NLS-1$ //$NON-NLS-2$
519518 printLocations (newSourceLocations , oldSourceLocations );
520519 }
521520 return true ;
@@ -529,7 +528,7 @@ private boolean hasClasspathChanged() {
529528 } catch (CoreException ignore ) { // skip it
530529 }
531530 if (DEBUG ) {
532- System .out .println ("JavaBuilder: Added non-empty source folder" ); //$NON-NLS-1$
531+ System .out .println ("Added non-empty source folder" ); //$NON-NLS-1$
533532 printLocations (newSourceLocations , oldSourceLocations );
534533 }
535534 return true ;
@@ -540,7 +539,7 @@ private boolean hasClasspathChanged() {
540539 continue ;
541540 }
542541 if (DEBUG ) {
543- System .out .println ("JavaBuilder: Removed non-empty source folder" ); //$NON-NLS-1$
542+ System .out .println ("Removed non-empty source folder" ); //$NON-NLS-1$
544543 printLocations (newSourceLocations , oldSourceLocations );
545544 }
546545 return true ;
@@ -553,14 +552,14 @@ private boolean hasClasspathChanged() {
553552 for (n = o = 0 ; n < newLength && o < oldLength ; n ++, o ++) {
554553 if (newBinaryLocations [n ].equals (oldBinaryLocations [o ])) continue ;
555554 if (DEBUG ) {
556- System .out .println ("JavaBuilder: New location: " + newBinaryLocations [n ] + "\n != old location: " + oldBinaryLocations [o ]); //$NON-NLS-1$ //$NON-NLS-2$
555+ System .out .println ("New location: " + newBinaryLocations [n ] + "\n != old location: " + oldBinaryLocations [o ]); //$NON-NLS-1$ //$NON-NLS-2$
557556 printLocations (newBinaryLocations , oldBinaryLocations );
558557 }
559558 return true ;
560559 }
561560 if (n < newLength || o < oldLength ) {
562561 if (DEBUG ) {
563- System .out .println ("JavaBuilder: Number of binary folders/jar files has changed:" ); //$NON-NLS-1$
562+ System .out .println ("Number of binary folders/jar files has changed:" ); //$NON-NLS-1$
564563 printLocations (newBinaryLocations , oldBinaryLocations );
565564 }
566565 return true ;
@@ -614,15 +613,7 @@ private int initializeBuilder(int kind, boolean forBuild) throws CoreException {
614613 // Flush the existing external files cache if this is the beginning of a build cycle
615614 String projectName = this .currentProject .getName ();
616615 if (builtProjects == null || builtProjects .contains (projectName )) {
617- try {
618- Method method = JavaModel .class .getMethod ("flushExternalFileCache" , new Class [] { Void .class });
619- if (method != null ) {
620- method .invoke (JavaModel .class , new Object [0 ]);
621- }
622- } catch (Throwable e ) {
623- e .printStackTrace ();
624- }
625- //JavaModel.flushExternalFileCache();
616+ JavaModel .flushExternalFileCache ();
626617 builtProjects = new ArrayList ();
627618 }
628619 builtProjects .add (projectName );
@@ -677,7 +668,7 @@ private boolean isWorthBuilding() throws CoreException {
677668 // Abort build only if there are classpath errors
678669 if (isClasspathBroken (this .javaProject .getRawClasspath (), this .currentProject )) {
679670 if (DEBUG )
680- System .out .println ("JavaBuilder: Aborted build because project has classpath errors (incomplete or involved in cycle)" ); //$NON-NLS-1$
671+ System .out .println ("Aborted build because project has classpath errors (incomplete or involved in cycle)" ); //$NON-NLS-1$
681672
682673 removeProblemsAndTasksFor (this .currentProject ); // remove all compilation problems
683674
@@ -707,18 +698,18 @@ private boolean isWorthBuilding() throws CoreException {
707698 JavaProject prereq = (JavaProject ) JavaCore .create (p );
708699 if (prereq .hasCycleMarker () && JavaCore .WARNING .equals (this .javaProject .getOption (JavaCore .CORE_CIRCULAR_CLASSPATH , true ))) {
709700 if (DEBUG )
710- System .out .println ("JavaBuilder: Continued to build even though prereq project " + p .getName () //$NON-NLS-1$
701+ System .out .println ("Continued to build even though prereq project " + p .getName () //$NON-NLS-1$
711702 + " was not built since its part of a cycle" ); //$NON-NLS-1$
712703 continue ;
713704 }
714705 if (!hasJavaBuilder (p )) {
715706 if (DEBUG )
716- System .out .println ("JavaBuilder: Continued to build even though prereq project " + p .getName () //$NON-NLS-1$
707+ System .out .println ("Continued to build even though prereq project " + p .getName () //$NON-NLS-1$
717708 + " is not built by JavaBuilder" ); //$NON-NLS-1$
718709 continue ;
719710 }
720711 if (DEBUG )
721- System .out .println ("JavaBuilder: Aborted build because prereq project " + p .getName () //$NON-NLS-1$
712+ System .out .println ("Aborted build because prereq project " + p .getName () //$NON-NLS-1$
722713 + " was not built" ); //$NON-NLS-1$
723714
724715 removeProblemsAndTasksFor (this .currentProject ); // make this the only problem for this project
@@ -755,7 +746,7 @@ void mustPropagateStructuralChanges() {
755746 IProject project = this .workspaceRoot .getProject (participantPath .segment (0 ));
756747 if (hasBeenBuilt (project )) {
757748 if (DEBUG )
758- System .out .println ("JavaBuilder: Requesting another build iteration since cycle participant " + project .getName () //$NON-NLS-1$
749+ System .out .println ("Requesting another build iteration since cycle participant " + project .getName () //$NON-NLS-1$
759750 + " has not yet seen some structural changes" ); //$NON-NLS-1$
760751 needRebuild ();
761752 return ;
@@ -765,10 +756,10 @@ void mustPropagateStructuralChanges() {
765756}
766757
767758private void printLocations (ClasspathLocation [] newLocations , ClasspathLocation [] oldLocations ) {
768- System .out .println ("JavaBuilder: New locations:" ); //$NON-NLS-1$
759+ System .out .println ("New locations:" ); //$NON-NLS-1$
769760 for (int i = 0 , length = newLocations .length ; i < length ; i ++)
770761 System .out .println (" " + newLocations [i ].debugPathString ()); //$NON-NLS-1$
771- System .out .println ("JavaBuilder: Old locations:" ); //$NON-NLS-1$
762+ System .out .println ("Old locations:" ); //$NON-NLS-1$
772763 for (int i = 0 , length = oldLocations .length ; i < length ; i ++)
773764 System .out .println (" " + oldLocations [i ].debugPathString ()); //$NON-NLS-1$
774765}
@@ -799,7 +790,7 @@ private void recordNewState(State state) {
799790 }
800791
801792 if (DEBUG )
802- System .out .println ("JavaBuilder: Recording new state : " + state ); //$NON-NLS-1$
793+ System .out .println ("Recording new state : " + state ); //$NON-NLS-1$
803794 // state.dump();
804795 JavaModelManager .getJavaModelManager ().setLastBuiltState (currentProject , newState );
805796}
0 commit comments