@@ -119,8 +119,9 @@ protected static void setStaticAntProperties(Properties properties) {
119
119
if (properties == null ) {
120
120
immutableAntProperties = new Properties ();
121
121
BuildDirector .p2Gathering = false ;
122
- } else
122
+ } else {
123
123
immutableAntProperties = properties ;
124
+ }
124
125
if (getImmutableAntProperty (IBuildPropertiesConstants .PROPERTY_PACKAGER_MODE ) == null ) {
125
126
immutableAntProperties .setProperty (IBuildPropertiesConstants .PROPERTY_PACKAGER_MODE , "false" ); //$NON-NLS-1$
126
127
}
@@ -129,8 +130,9 @@ protected static void setStaticAntProperties(Properties properties) {
129
130
immutableAntProperties .setProperty (IBuildPropertiesConstants .PROPERTY_PACKAGER_AS_NORMALIZER , "true" ); //$NON-NLS-1$
130
131
}
131
132
132
- if (getPropertyAsBoolean (IBuildPropertiesConstants .PROPERTY_P2_GATHERING ))
133
+ if (getPropertyAsBoolean (IBuildPropertiesConstants .PROPERTY_P2_GATHERING )) {
133
134
BuildDirector .p2Gathering = true ;
135
+ }
134
136
}
135
137
136
138
public static String getImmutableAntProperty (String key ) {
@@ -139,14 +141,16 @@ public static String getImmutableAntProperty(String key) {
139
141
140
142
public static boolean getPropertyAsBoolean (String key ) {
141
143
String booleanValue = getImmutableAntProperty (key , null );
142
- if ("true" .equalsIgnoreCase (booleanValue )) //$NON-NLS-1$
144
+ if ("true" .equalsIgnoreCase (booleanValue )) { //$NON-NLS-1$
143
145
return true ;
146
+ }
144
147
return false ;
145
148
}
146
149
147
150
public static String getImmutableAntProperty (String key , String defaultValue ) {
148
- if (immutableAntProperties == null || !immutableAntProperties .containsKey (key ))
151
+ if (immutableAntProperties == null || !immutableAntProperties .containsKey (key )) {
149
152
return defaultValue ;
153
+ }
150
154
Object obj = immutableAntProperties .get (key );
151
155
return (obj instanceof String ) ? (String ) obj : null ;
152
156
}
@@ -214,8 +218,9 @@ public synchronized Object put(Object key, Object value) {
214
218
}
215
219
216
220
public static MissingProperties getInstance () {
217
- if (singleton == null )
221
+ if (singleton == null ) {
218
222
singleton = new MissingProperties ();
223
+ }
219
224
return singleton ;
220
225
}
221
226
}
@@ -247,8 +252,9 @@ public static Properties readProperties(String location, String fileName, int er
247
252
}
248
253
249
254
public void openScript (String scriptLocation , String scriptName ) throws CoreException {
250
- if (script != null )
255
+ if (script != null ) {
251
256
return ;
257
+ }
252
258
script = newAntScript (scriptLocation , scriptName );
253
259
}
254
260
@@ -309,8 +315,9 @@ protected static boolean loadP2Class() {
309
315
* @return BuildTimeSite
310
316
*/
311
317
public BuildTimeSite getSite (boolean refresh ) throws CoreException {
312
- if (siteFactory != null && refresh == false )
318
+ if (siteFactory != null && refresh == false ) {
313
319
return siteFactory .createSite ();
320
+ }
314
321
315
322
//If there is an exception from createSite(), we will discard the factory
316
323
BuildTimeSiteFactory factory = new BuildTimeSiteFactory ();
@@ -325,8 +332,9 @@ public BuildTimeSite getSite(boolean refresh) throws CoreException {
325
332
BuildTimeSite result = factory .createSite ();
326
333
siteFactory = factory ;
327
334
328
- if (platformProperties != null )
335
+ if (platformProperties != null ) {
329
336
result .setPlatformPropeties (platformProperties );
337
+ }
330
338
331
339
File baseProfile = result .getSiteContentProvider ().getBaseProfile ();
332
340
if (baseProfile != null ) {
@@ -401,8 +409,9 @@ protected void flushState() {
401
409
}
402
410
403
411
private void ensurePDEUIStateNotNull () {
404
- if (pdeUIState == null )
412
+ if (pdeUIState == null ) {
405
413
pdeUIState = new PDEUIStateWrapper ();
414
+ }
406
415
}
407
416
408
417
protected boolean havePDEUIState () {
@@ -443,12 +452,14 @@ public ProductFile loadProduct(String product, String os) throws CoreException {
443
452
//Find a file in a bundle or a feature.
444
453
//location is assumed to be structured like : /<featureId | pluginId>/path.to.the.file
445
454
protected String findFile (String location , boolean makeRelative ) {
446
- if (location == null || location .length () == 0 )
455
+ if (location == null || location .length () == 0 ) {
447
456
return null ;
457
+ }
448
458
449
459
//shortcut building the site if we don't need to
450
- if (new File (location ).exists ())
460
+ if (new File (location ).exists ()) {
451
461
return location ;
462
+ }
452
463
453
464
PDEState state ;
454
465
try {
@@ -464,8 +475,9 @@ protected String findFile(String location, boolean makeRelative) {
464
475
BundleDescription bundle = matches [0 ];
465
476
if (bundle != null ) {
466
477
String result = checkFile (IPath .fromOSString (bundle .getLocation ()), path , makeRelative );
467
- if (result != null )
478
+ if (result != null ) {
468
479
return result ;
480
+ }
469
481
}
470
482
}
471
483
// Couldn't find the file in any of the plugins, try in a feature.
@@ -475,54 +487,64 @@ protected String findFile(String location, boolean makeRelative) {
475
487
} catch (CoreException e ) {
476
488
BundleHelper .getDefault ().getLog ().log (e .getStatus ());
477
489
}
478
- if (feature == null )
490
+ if (feature == null ) {
479
491
return null ;
492
+ }
480
493
481
494
String featureRoot = feature .getRootLocation ();
482
- if (featureRoot != null )
495
+ if (featureRoot != null ) {
483
496
return checkFile (IPath .fromOSString (featureRoot ), path , makeRelative );
497
+ }
484
498
return null ;
485
499
}
486
500
487
501
protected String findConfigFile (ProductFile productFile , String os ) {
488
502
String path = productFile .getConfigIniPath (os );
489
- if (path == null )
503
+ if (path == null ) {
490
504
return null ;
505
+ }
491
506
492
507
String result = findFile (path , false );
493
- if (result != null )
508
+ if (result != null ) {
494
509
return result ;
510
+ }
495
511
496
512
// couldn't find productFile, try it as a path directly
497
513
File f = new File (path );
498
- if (f .exists () && f .isFile ())
514
+ if (f .exists () && f .isFile ()) {
499
515
return f .getAbsolutePath ();
516
+ }
500
517
501
518
// relative to the working directory
502
519
f = new File (getWorkingDirectory (), path );
503
- if (f .exists () && f .isFile ())
520
+ if (f .exists () && f .isFile ()) {
504
521
return f .getAbsolutePath ();
522
+ }
505
523
506
524
// relative to the working directory/plugins
507
525
f = new File (getWorkingDirectory () + "/" + DEFAULT_PLUGIN_LOCATION , path ); //$NON-NLS-1$
508
- if (f .exists () && f .isFile ())
526
+ if (f .exists () && f .isFile ()) {
509
527
return f .getAbsolutePath ();
528
+ }
510
529
511
530
//relative to .product file
512
531
f = new File (productFile .getLocation ().getParent (), path );
513
- if (f .exists () && f .isFile ())
532
+ if (f .exists () && f .isFile ()) {
514
533
return f .getAbsolutePath ();
534
+ }
515
535
516
536
return null ;
517
537
}
518
538
519
539
private String checkFile (IPath base , IPath target , boolean makeRelative ) {
520
540
IPath path = base .append (target .removeFirstSegments (1 ));
521
541
String result = path .toOSString ();
522
- if (!new File (result ).exists ())
542
+ if (!new File (result ).exists ()) {
523
543
return null ;
524
- if (makeRelative )
544
+ }
545
+ if (makeRelative ) {
525
546
return Utils .makeRelative (path , IPath .fromOSString (workingDirectory )).toOSString ();
547
+ }
526
548
return result ;
527
549
}
528
550
@@ -536,8 +558,9 @@ public void setFilterP2Base(boolean filter) {
536
558
537
559
static private URI getDownloadCacheLocation (IProvisioningAgent agent ) {
538
560
IAgentLocation location = (IAgentLocation ) agent .getService (IAgentLocation .SERVICE_NAME );
539
- if (location == null )
561
+ if (location == null ) {
540
562
return null ;
563
+ }
541
564
return URIUtil .append (location .getDataArea ("org.eclipse.equinox.p2.core" ), "cache/" ); //$NON-NLS-1$ //$NON-NLS-2$
542
565
}
543
566
@@ -587,8 +610,9 @@ protected void addContextRepos(URI[] repos) {
587
610
588
611
//return only the metadata repos, and also the ones we aren't sure about
589
612
private List <URI > filterRepos (URI [] contexts , FilenameFilter repoFilter ) {
590
- if (contexts == null )
613
+ if (contexts == null ) {
591
614
return null ;
615
+ }
592
616
ArrayList <URI > result = new ArrayList <>();
593
617
for (URI context : contexts ) {
594
618
File repo = URIUtil .toFile (context );
@@ -597,24 +621,27 @@ private List<URI> filterRepos(URI[] contexts, FilenameFilter repoFilter) {
597
621
result .add (context );
598
622
} else {
599
623
String [] list = repo .list (repoFilter );
600
- if (list != null && list .length > 0 )
624
+ if (list != null && list .length > 0 ) {
601
625
result .add (context );
626
+ }
602
627
}
603
628
}
604
629
return result ;
605
630
}
606
631
607
632
private List <URI > getAssociatedRepositories (File profileFile ) {
608
- if (profileFile == null || !profileFile .exists () || !profileFile .getName ().endsWith (".profile" )) //$NON-NLS-1$
633
+ if (profileFile == null || !profileFile .exists () || !profileFile .getName ().endsWith (".profile" )) { //$NON-NLS-1$
609
634
return Collections .emptyList ();
635
+ }
610
636
611
637
ArrayList <URI > result = new ArrayList <>();
612
638
URI profileURI = profileFile .toURI ();
613
639
result .add (profileURI );
614
640
615
641
Map <String , Object > profileInfo = extractProfileInformation (profileFile );
616
- if (profileInfo == null )
642
+ if (profileInfo == null ) {
617
643
return result ;
644
+ }
618
645
619
646
File areaFile = new File ((String ) profileInfo .get (PROFILE_DATA_AREA ));
620
647
if (areaFile .exists ()) {
@@ -626,8 +653,9 @@ private List<URI> getAssociatedRepositories(File profileFile) {
626
653
String profileId = (String ) profileInfo .get (PROFILE_ID );
627
654
if (timestamp == -1L ) {
628
655
long [] timestamps = registry .listProfileTimestamps (profileId );
629
- if (timestamps .length > 0 )
656
+ if (timestamps .length > 0 ) {
630
657
timestamp = timestamps [timestamps .length - 1 ];
658
+ }
631
659
}
632
660
633
661
//specifying the timestamp avoids attempting to lock the profile registry
@@ -647,8 +675,9 @@ private List<URI> getAssociatedRepositories(File profileFile) {
647
675
}
648
676
}
649
677
String sharedCache = profile .getProperty (IProfile .PROP_SHARED_CACHE );
650
- if (sharedCache != null )
678
+ if (sharedCache != null ) {
651
679
result .add (new File (cache ).toURI ());
680
+ }
652
681
String dropinRepositories = profile .getProperty ("org.eclipse.equinox.p2.cache.extensions" ); //$NON-NLS-1$
653
682
if (dropinRepositories != null ) {
654
683
// #filterRepos will remove any dropin folders that require synchronization
@@ -670,8 +699,9 @@ private List<URI> getAssociatedRepositories(File profileFile) {
670
699
671
700
//download cache
672
701
URI download = getDownloadCacheLocation (agent );
673
- if (URIUtil .toFile (download ).exists ())
702
+ if (URIUtil .toFile (download ).exists ()) {
674
703
result .add (download );
704
+ }
675
705
}
676
706
}
677
707
return result ;
@@ -683,25 +713,29 @@ private List<URI> getAssociatedRepositories(File profileFile) {
683
713
private static String PROFILE_REGISTRY = "registry" ; //$NON-NLS-1$
684
714
685
715
private static Map <String , Object > extractProfileInformation (File target ) {
686
- if (target == null || !target .exists ())
716
+ if (target == null || !target .exists ()) {
687
717
return null ;
718
+ }
688
719
689
720
IPath path = IPath .fromOSString (target .getAbsolutePath ());
690
- if (!path .lastSegment ().endsWith (PROFILE ) && !path .lastSegment ().endsWith (PROFILE_GZ ))
721
+ if (!path .lastSegment ().endsWith (PROFILE ) && !path .lastSegment ().endsWith (PROFILE_GZ )) {
691
722
return null ;
723
+ }
692
724
693
725
//expect at least "p2/org.eclipse.equinox.p2.engine/profileRegistry/Profile.profile"
694
- if (path .segmentCount () < 4 )
726
+ if (path .segmentCount () < 4 ) {
695
727
return null ;
728
+ }
696
729
697
730
Map <String , Object > results = new HashMap <>();
698
731
results .put (PROFILE_TIMESTAMP , Long .valueOf (-1 ));
699
732
700
733
String profileId = null ;
701
734
if (target .isFile ()) {
702
735
//p2/org.eclipse.equinox.p2.engine/profileRegistry/Profile.profile/123456.profile.gz
703
- if (path .segmentCount () < 5 )
736
+ if (path .segmentCount () < 5 ) {
704
737
return null ;
738
+ }
705
739
706
740
String timestamp = path .lastSegment ();
707
741
int idx = timestamp .indexOf ('.' );
@@ -751,11 +785,13 @@ public void setProductQualifier(String value) {
751
785
* If the user has specified a platform properties then load it.
752
786
*/
753
787
public void setPlatformProperties (String filename ) {
754
- if (filename == null || filename .trim ().length () == 0 )
788
+ if (filename == null || filename .trim ().length () == 0 ) {
755
789
return ;
790
+ }
756
791
File file = new File (filename );
757
- if (!file .exists ())
792
+ if (!file .exists ()) {
758
793
return ;
794
+ }
759
795
platformProperties = new Properties ();
760
796
try (InputStream input = new BufferedInputStream (new FileInputStream (file ))) {
761
797
platformProperties .load (input );
@@ -768,8 +804,9 @@ public void setPlatformProperties(String filename) {
768
804
}
769
805
770
806
protected void generateProductReplaceTask (ProductFile product , String productFilePath , AssemblyInformation assemblyInfo ) {
771
- if (product == null )
807
+ if (product == null ) {
772
808
return ;
809
+ }
773
810
774
811
BuildTimeSite site = null ;
775
812
try {
@@ -789,10 +826,11 @@ protected void generateProductReplaceTask(ProductFile product, String productFil
789
826
790
827
script .println ("<eclipse.idReplacer productFilePath=\" " + AntScript .getEscaped (productFilePath ) + "\" " ); //$NON-NLS-1$ //$NON-NLS-2$
791
828
script .println (" selfVersion=\" " + version + "\" " ); //$NON-NLS-1$ //$NON-NLS-2$
792
- if (product .useFeatures ())
829
+ if (product .useFeatures ()) {
793
830
script .println (" featureIds=\" " + mappings + "\" />" ); //$NON-NLS-1$ //$NON-NLS-2$
794
- else
831
+ } else {
795
832
script .println (" pluginIds=\" " + mappings + "\" />" ); //$NON-NLS-1$ //$NON-NLS-2$
833
+ }
796
834
797
835
return ;
798
836
}
0 commit comments