1
1
/*******************************************************************************
2
- * Copyright (c) 2000, 2013 IBM Corporation and others.
2
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
3
3
* All rights reserved. This program and the accompanying materials
4
4
* are made available under the terms of the Eclipse Public License v1.0
5
5
* which accompanies this distribution, and is available at
12
12
13
13
import org .eclipse .core .resources .*;
14
14
import org .eclipse .core .runtime .*;
15
+
15
16
import org .eclipse .jdt .core .*;
16
17
import org .eclipse .jdt .core .compiler .*;
17
18
import org .eclipse .jdt .internal .compiler .util .SimpleLookupTable ;
20
21
import org .eclipse .jdt .internal .core .util .Util ;
21
22
22
23
import java .io .*;
23
- import java .lang .reflect .InvocationTargetException ;
24
- import java .lang .reflect .Method ;
25
24
import java .util .*;
26
25
27
26
public class JavaBuilder extends IncrementalProjectBuilder {
@@ -158,7 +157,7 @@ protected IProject[] build(int kind, Map ignored, IProgressMonitor monitor) thro
158
157
if (this .currentProject == null || !this .currentProject .isAccessible ()) return new IProject [0 ];
159
158
160
159
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$
162
161
+ " @ " + new Date (System .currentTimeMillis ())); //$NON-NLS-1$
163
162
this .notifier = new BuildNotifier (monitor , this .currentProject );
164
163
this .notifier .begin ();
@@ -170,39 +169,39 @@ protected IProject[] build(int kind, Map ignored, IProgressMonitor monitor) thro
170
169
if (isWorthBuilding ()) {
171
170
if (kind == FULL_BUILD ) {
172
171
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$
174
173
buildAll ();
175
174
} else {
176
175
if ((this .lastState = getLastState (this .currentProject )) == null ) {
177
176
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$
179
178
buildAll ();
180
179
} else if (hasClasspathChanged ()) {
181
180
// if the output location changes, do not delete the binary files from old location
182
181
// the user may be trying something
183
182
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$
185
184
buildAll ();
186
185
} else if (this .nameEnvironment .sourceLocations .length > 0 ) {
187
186
// if there is no source to compile & no classpath changes then we are done
188
187
SimpleLookupTable deltas = findDeltas ();
189
188
if (deltas == null ) {
190
189
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$
192
191
buildAll ();
193
192
} else if (deltas .elementSize > 0 ) {
194
193
buildDeltas (deltas );
195
194
} 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$
197
196
}
198
197
} else {
199
198
if (hasStructuralDelta ()) { // double check that a jar file didn't get replaced in a binary project
200
199
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$
202
201
buildAll ();
203
202
} else {
204
203
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$
206
205
this .lastState .tagAsNoopBuild ();
207
206
}
208
207
}
@@ -240,16 +239,16 @@ protected IProject[] build(int kind, Map ignored, IProgressMonitor monitor) thro
240
239
}
241
240
IProject [] requiredProjects = getRequiredProjects (true );
242
241
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$
245
244
return requiredProjects ;
246
245
}
247
246
248
247
private void buildAll () {
249
248
this .notifier .checkCancel ();
250
249
this .notifier .subTask (Messages .bind (Messages .build_preparingBuild , this .currentProject .getName ()));
251
250
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$
253
252
clearLastState ();
254
253
BatchImageBuilder imageBuilder = new Java2ScriptBatchImageBuilder (this , true );
255
254
imageBuilder .build ();
@@ -260,14 +259,14 @@ private void buildDeltas(SimpleLookupTable deltas) {
260
259
this .notifier .checkCancel ();
261
260
this .notifier .subTask (Messages .bind (Messages .build_preparingBuild , this .currentProject .getName ()));
262
261
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$
264
263
clearLastState (); // clear the previously built state so if the build fails, a full build will occur next time
265
264
IncrementalImageBuilder imageBuilder = new Java2ScriptIncrementalImageBuilder (this );
266
265
if (imageBuilder .build (deltas )) {
267
266
recordNewState (imageBuilder .newState );
268
267
} else {
269
268
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$
271
270
buildAll ();
272
271
}
273
272
}
@@ -277,7 +276,7 @@ protected void clean(IProgressMonitor monitor) throws CoreException {
277
276
if (this .currentProject == null || !this .currentProject .isAccessible ()) return ;
278
277
279
278
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$
281
280
+ " @ " + new Date (System .currentTimeMillis ())); //$NON-NLS-1$
282
281
this .notifier = new BuildNotifier (monitor , this .currentProject );
283
282
this .notifier .begin ();
@@ -286,7 +285,7 @@ protected void clean(IProgressMonitor monitor) throws CoreException {
286
285
287
286
initializeBuilder (CLEAN_BUILD , true );
288
287
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$
290
289
clearLastState ();
291
290
removeProblemsAndTasksFor (this .currentProject );
292
291
new BatchImageBuilder (this , false ).cleanOutputFolders (false );
@@ -298,7 +297,7 @@ protected void clean(IProgressMonitor monitor) throws CoreException {
298
297
cleanup ();
299
298
}
300
299
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$
302
301
+ " @ " + new Date (System .currentTimeMillis ())); //$NON-NLS-1$
303
302
}
304
303
@@ -367,12 +366,12 @@ private SimpleLookupTable findDeltas() {
367
366
if (delta != null ) {
368
367
if (delta .getKind () != IResourceDelta .NO_CHANGE ) {
369
368
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$
371
370
deltas .put (this .currentProject , delta );
372
371
}
373
372
} else {
374
373
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$
376
375
this .notifier .subTask ("" ); //$NON-NLS-1$
377
376
return null ;
378
377
}
@@ -402,12 +401,12 @@ private SimpleLookupTable findDeltas() {
402
401
if (delta != null ) {
403
402
if (delta .getKind () != IResourceDelta .NO_CHANGE ) {
404
403
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$
406
405
deltas .put (p , delta );
407
406
}
408
407
} else {
409
408
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$
411
410
this .notifier .subTask ("" ); //$NON-NLS-1$
412
411
return null ;
413
412
}
@@ -515,7 +514,7 @@ private boolean hasClasspathChanged() {
515
514
} catch (CoreException ignore ) { // skip it
516
515
}
517
516
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$
519
518
printLocations (newSourceLocations , oldSourceLocations );
520
519
}
521
520
return true ;
@@ -529,7 +528,7 @@ private boolean hasClasspathChanged() {
529
528
} catch (CoreException ignore ) { // skip it
530
529
}
531
530
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$
533
532
printLocations (newSourceLocations , oldSourceLocations );
534
533
}
535
534
return true ;
@@ -540,7 +539,7 @@ private boolean hasClasspathChanged() {
540
539
continue ;
541
540
}
542
541
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$
544
543
printLocations (newSourceLocations , oldSourceLocations );
545
544
}
546
545
return true ;
@@ -553,14 +552,14 @@ private boolean hasClasspathChanged() {
553
552
for (n = o = 0 ; n < newLength && o < oldLength ; n ++, o ++) {
554
553
if (newBinaryLocations [n ].equals (oldBinaryLocations [o ])) continue ;
555
554
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$
557
556
printLocations (newBinaryLocations , oldBinaryLocations );
558
557
}
559
558
return true ;
560
559
}
561
560
if (n < newLength || o < oldLength ) {
562
561
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$
564
563
printLocations (newBinaryLocations , oldBinaryLocations );
565
564
}
566
565
return true ;
@@ -614,15 +613,7 @@ private int initializeBuilder(int kind, boolean forBuild) throws CoreException {
614
613
// Flush the existing external files cache if this is the beginning of a build cycle
615
614
String projectName = this .currentProject .getName ();
616
615
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 ();
626
617
builtProjects = new ArrayList ();
627
618
}
628
619
builtProjects .add (projectName );
@@ -677,7 +668,7 @@ private boolean isWorthBuilding() throws CoreException {
677
668
// Abort build only if there are classpath errors
678
669
if (isClasspathBroken (this .javaProject .getRawClasspath (), this .currentProject )) {
679
670
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$
681
672
682
673
removeProblemsAndTasksFor (this .currentProject ); // remove all compilation problems
683
674
@@ -707,18 +698,18 @@ private boolean isWorthBuilding() throws CoreException {
707
698
JavaProject prereq = (JavaProject ) JavaCore .create (p );
708
699
if (prereq .hasCycleMarker () && JavaCore .WARNING .equals (this .javaProject .getOption (JavaCore .CORE_CIRCULAR_CLASSPATH , true ))) {
709
700
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$
711
702
+ " was not built since its part of a cycle" ); //$NON-NLS-1$
712
703
continue ;
713
704
}
714
705
if (!hasJavaBuilder (p )) {
715
706
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$
717
708
+ " is not built by JavaBuilder" ); //$NON-NLS-1$
718
709
continue ;
719
710
}
720
711
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$
722
713
+ " was not built" ); //$NON-NLS-1$
723
714
724
715
removeProblemsAndTasksFor (this .currentProject ); // make this the only problem for this project
@@ -755,7 +746,7 @@ void mustPropagateStructuralChanges() {
755
746
IProject project = this .workspaceRoot .getProject (participantPath .segment (0 ));
756
747
if (hasBeenBuilt (project )) {
757
748
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$
759
750
+ " has not yet seen some structural changes" ); //$NON-NLS-1$
760
751
needRebuild ();
761
752
return ;
@@ -765,10 +756,10 @@ void mustPropagateStructuralChanges() {
765
756
}
766
757
767
758
private 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$
769
760
for (int i = 0 , length = newLocations .length ; i < length ; i ++)
770
761
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$
772
763
for (int i = 0 , length = oldLocations .length ; i < length ; i ++)
773
764
System .out .println (" " + oldLocations [i ].debugPathString ()); //$NON-NLS-1$
774
765
}
@@ -799,7 +790,7 @@ private void recordNewState(State state) {
799
790
}
800
791
801
792
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$
803
794
// state.dump();
804
795
JavaModelManager .getJavaModelManager ().setLastBuiltState (currentProject , newState );
805
796
}
0 commit comments