105105import aQute .bnd .service .export .Exporter ;
106106import aQute .bnd .service .release .ReleaseBracketingPlugin ;
107107import aQute .bnd .service .specifications .RunSpecification ;
108- import aQute .bnd .service .tags .Tags ;
109108import aQute .bnd .stream .MapStream ;
110109import aQute .bnd .version .Version ;
111110import aQute .bnd .version .VersionRange ;
@@ -638,6 +637,8 @@ public List<Container> getBundles(Strategy strategyx, String spec, String source
638637 decorator .decorate (bundles , true );
639638 }
640639
640+ List <RepositoryPlugin > repos = getRepositories (repoTagsBySource (source ));
641+
641642 List <Container > result = new ArrayList <>();
642643 try {
643644 for (Entry <String , Attrs > entry : bundles .entrySet ()) {
@@ -650,12 +651,12 @@ public List<Container> getBundles(Strategy strategyx, String spec, String source
650651 boolean triedGetBundle = false ;
651652
652653 if (bsn .indexOf ('*' ) >= 0 ) {
653- return getBundlesWildcard (bsn , versionRange , strategyx , attrs );
654+ return getBundlesWildcard (bsn , versionRange , strategyx , attrs , repos );
654655 }
655656
656657 if (versionRange != null ) {
657658 if (versionRange .equals (VERSION_ATTR_LATEST ) || versionRange .equals (VERSION_ATTR_SNAPSHOT )) {
658- found = getBundle (bsn , versionRange , strategyx , attrs );
659+ found = getBundle (bsn , versionRange , strategyx , attrs , repos );
659660 triedGetBundle = true ;
660661 }
661662 }
@@ -694,7 +695,7 @@ public List<Container> getBundles(Strategy strategyx, String spec, String source
694695 found = new Container (this , bsn , "file" , Container .TYPE .EXTERNAL , f , error , attrs , null );
695696 }
696697 } else if (!triedGetBundle ) {
697- found = getBundle (bsn , versionRange , strategyx , attrs );
698+ found = getBundle (bsn , versionRange , strategyx , attrs , repos );
698699 }
699700 }
700701
@@ -728,6 +729,25 @@ public List<Container> getBundles(Strategy strategyx, String spec, String source
728729 return result ;
729730 }
730731
732+ private String [] repoTagsBySource (String source ) {
733+
734+ if (source == null ) {
735+ return null ;
736+ }
737+
738+ if (Constants .BUILDPATH .equals (source )) {
739+ return new String [] {
740+ Constants .REPOTAGS_COMPILE
741+ };
742+ } else if (Constants .TESTPATH .equals (source )) {
743+ return new String [] {
744+ Constants .REPOTAGS_COMPILE , Constants .REPOTAGS_TEST
745+ };
746+ }
747+ // TODO how to determine tag "debug"
748+ return null ;
749+ }
750+
731751 /**
732752 * Just calls a new method with a default parm.
733753 *
@@ -751,6 +771,13 @@ Collection<Container> getBundles(Strategy strategy, String spec) throws Exceptio
751771 public List <Container > getBundlesWildcard (String bsnPattern , String range , Strategy strategyx ,
752772 Map <String , String > attrs ) throws Exception {
753773
774+ List <RepositoryPlugin > plugins = getRepositories ();
775+ return getBundlesWildcard (bsnPattern , range , strategyx , attrs , plugins );
776+ }
777+
778+ private List <Container > getBundlesWildcard (String bsnPattern , String range , Strategy strategyx ,
779+ Map <String , String > attrs , List <RepositoryPlugin > repos ) throws Exception {
780+
754781 if (VERSION_ATTR_SNAPSHOT .equals (range ) || VERSION_ATTR_PROJECT .equals (range ))
755782 return Collections .singletonList (new Container (this , bsnPattern , range , TYPE .ERROR , null ,
756783 "Cannot use snapshot or project version with wildcard matches" , null , null ));
@@ -774,8 +801,7 @@ public List<Container> getBundlesWildcard(String bsnPattern, String range, Strat
774801
775802 SortedMap <String , Pair <Version , RepositoryPlugin >> providerMap = new TreeMap <>();
776803
777- List <RepositoryPlugin > plugins = getRepositories ();
778- for (RepositoryPlugin plugin : plugins ) {
804+ for (RepositoryPlugin plugin : repos ) {
779805
780806 if (repoFilter != null && !repoFilter .match (plugin ))
781807 continue ;
@@ -1256,6 +1282,14 @@ public void release(String name, boolean test) throws Exception {
12561282 public Container getBundle (String bsn , String range , Strategy strategy , Map <String , String > attrs )
12571283 throws Exception {
12581284
1285+ List <RepositoryPlugin > plugins = getRepositories ();
1286+ return getBundle (bsn , range , strategy , attrs , plugins );
1287+
1288+ }
1289+
1290+ private Container getBundle (String bsn , String range , Strategy strategy , Map <String , String > attrs ,
1291+ List <RepositoryPlugin > repos ) throws Exception {
1292+
12591293 if (range == null )
12601294 range = "0" ;
12611295 if (attrs == null ) {
@@ -1281,7 +1315,7 @@ public Container getBundle(String bsn, String range, Strategy strategy, Map<Stri
12811315 useStrategy = overrideStrategy (attrs , useStrategy );
12821316 RepoFilter repoFilter = parseRepoFilter (attrs );
12831317
1284- List < RepositoryPlugin > plugins = getRepositories ();
1318+
12851319
12861320 if (useStrategy == Strategy .EXACT ) {
12871321 if (!Verifier .isVersion (range ))
@@ -1291,7 +1325,8 @@ public Container getBundle(String bsn, String range, Strategy strategy, Map<Stri
12911325 // For an exact range we just iterate over the repos
12921326 // and return the first we find.
12931327 Version version = new Version (range );
1294- for (RepositoryPlugin plugin : plugins ) {
1328+
1329+ for (RepositoryPlugin plugin : repos ) {
12951330 DownloadBlocker blocker = new DownloadBlocker (this );
12961331 File result = plugin .get (bsn , version , attrs , blocker );
12971332 if (result != null )
@@ -1307,7 +1342,8 @@ public Container getBundle(String bsn, String range, Strategy strategy, Map<Stri
13071342 // multiple repos we take the first
13081343
13091344 SortedMap <Version , RepositoryPlugin > versions = new TreeMap <>();
1310- for (RepositoryPlugin plugin : plugins ) {
1345+
1346+ for (RepositoryPlugin plugin : repos ) {
13111347
13121348 if (repoFilter != null && !repoFilter .match (plugin ))
13131349 continue ;
@@ -1385,8 +1421,7 @@ public Container getBundle(String bsn, String range, Strategy strategy, Map<Stri
13851421 //
13861422
13871423 return new Container (this , bsn , range , Container .TYPE .ERROR , null ,
1388- bsn + ";version=" + range + " Not found in " + plugins , attrs , null );
1389-
1424+ bsn + ";version=" + range + " Not found in " + repos , attrs , null );
13901425 }
13911426
13921427 /**
@@ -1397,19 +1432,8 @@ public Container getBundle(String bsn, String range, Strategy strategy, Map<Stri
13971432 *
13981433 * @return a list of relevant repositories used by various methods.
13991434 */
1400- public List <RepositoryPlugin > getRepositories () {
1401-
1402- return workspace .getRepositories ()
1403- .stream ()
1404- .filter (repo -> {
1405- Tags tags = repo .getTags ();
1406-
1407- if (tags == null || tags .includesAny (Constants .REPOTAGS_COMPILE )) {
1408- return true ;
1409- }
1410- return false ;
1411- })
1412- .toList ();
1435+ public List <RepositoryPlugin > getRepositories (String ... tags ) {
1436+ return workspace .getRepositories (tags );
14131437 }
14141438
14151439 /**
0 commit comments