14
14
import org .eclipse .cdt .core .settings .model .extension .CBuildData ;
15
15
import org .eclipse .cdt .core .settings .model .extension .CTargetPlatformData ;
16
16
import org .eclipse .cdt .core .settings .model .util .CDataUtil ;
17
- import org .eclipse .core .internal .registry .osgi .OSGIUtils ;
18
17
import org .eclipse .core .resources .IFile ;
19
18
import org .eclipse .core .resources .IFolder ;
20
19
import org .eclipse .core .resources .IProject ;
21
20
import org .eclipse .core .resources .IResource ;
22
- import org .eclipse .core .runtime .spi .RegistryContributor ;
23
- import org .eclipse .core .runtime .spi .RegistryStrategy ;
24
21
import org .osgi .framework .Bundle ;
25
-
26
22
import io .sloeber .autoBuild .api .AutoBuildConfigurationExtensionDescription ;
27
23
import io .sloeber .autoBuild .api .IAutoBuildConfigurationDescription ;
28
24
import io .sloeber .autoBuild .api .IBuildRunner ;
38
34
import io .sloeber .schema .api .IToolChain ;
39
35
import io .sloeber .schema .internal .Configuration ;
40
36
import io .sloeber .schema .internal .Tool ;
37
+ //The following lines give warning. See TOFIX below on why
38
+ import org .osgi .framework .BundleContext ;
39
+ import org .osgi .framework .FrameworkUtil ;
40
+ import io .sloeber .autoBuild .core .Activator ;
41
41
42
42
public class AutoBuildConfigurationDescription extends AutoBuildResourceData
43
43
implements IAutoBuildConfigurationDescription {
@@ -497,7 +497,7 @@ public AutoBuildConfigurationDescription(ICConfigurationDescription cfgDescripti
497
497
if (autoCfgExtentionDesc != null && autoCfgExtentionBundel != null && (!autoCfgExtentionDesc .isBlank ())
498
498
&& (!autoCfgExtentionBundel .isBlank ())) {
499
499
try {
500
- Bundle contributingBundle = OSGIUtils . getDefault (). getBundle (autoCfgExtentionBundel );
500
+ Bundle contributingBundle = getBundle (autoCfgExtentionBundel );
501
501
Class <?> autoCfgExtentionDescClass = contributingBundle .loadClass (autoCfgExtentionDesc );
502
502
Constructor <?> ctor = autoCfgExtentionDescClass .getDeclaredConstructor (
503
503
IAutoBuildConfigurationDescription .class , String .class , String .class , String .class );
@@ -508,6 +508,7 @@ public AutoBuildConfigurationDescription(ICConfigurationDescription cfgDescripti
508
508
} catch (NoSuchMethodException e ) {
509
509
System .err .println (
510
510
"Classes derived from AutoBuildConfigurationExtensionDescription need to implement constructor IAutoBuildConfigurationDescription, String, String, String" ); //$NON-NLS-1$
511
+ e .printStackTrace ();
511
512
} catch (SecurityException | ClassNotFoundException | InstantiationException
512
513
513
514
| IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
@@ -517,6 +518,26 @@ public AutoBuildConfigurationDescription(ICConfigurationDescription cfgDescripti
517
518
518
519
}
519
520
521
+ private static Bundle getBundle (String symbolicName ) {
522
+ return org .eclipse .core .internal .registry .osgi .OSGIUtils .getDefault ().getBundle (symbolicName );
523
+ //TOFIX Below is an alternative but as I could not test at the time ...
524
+ // BundleContext bundleContext = Activator.getBundleContext();
525
+ // if (bundleContext == null) {
526
+ // System.err.println("Failed to get the bundleContext");
527
+ // System.err.println("Could not load the plugin this project is created with.");
528
+ // return null;
529
+ // }
530
+ // Bundle result = null;
531
+ // for (Bundle candidate : bundleContext.getBundles()) {
532
+ // if (candidate.getSymbolicName().equals(symbolicName)) {
533
+ // if (result == null || result.getVersion().compareTo(candidate.getVersion()) < 0) {
534
+ // result = candidate;
535
+ // }
536
+ // }
537
+ // }
538
+ // return result;
539
+ }
540
+
520
541
/**
521
542
* get the default options and update the combined options
522
543
*/
0 commit comments