#!/usr/bin/perl
use File::Find;

# After a build, look in all the target directories to get a list of the bundles that are created.
# Run this from the top level Aries directory.
# Discard version information and the org.apache.aries portion to create a list


$aries_dir = @ARGV[0];
if (defined @ARGV[1]) {$version = ",".@ARGV[1];}

if (!-d $aries_dir) {
    print "\nUsage: perl list_bundles_in_aries.pl source_dir <optional version number>\n";
    exit;
}

chdir $aries_dir;

@bundles = ();

@modules = (
           "application",
           "blueprint",
           "jmx",
           "jndi",
           "jpa",
           "proxy",
           "quiesce",
           "testsupport",
           "transaction",
           "util",
           "web"
           );

foreach $module (@modules) {
      @bundles = ();
      print "#\n";
      print "Module: $module \n";;
      find (\&getbundles, $module);

      sub getbundles {
          if ( /^org\.apache\.aries.([\w\.]*)-.*\.jar$/i) {
                  push @bundles, $1;
          }
      }
      foreach $bundle (@bundles) {
        print $bundle.$version."\n";
      }
      print "ModuleEnd\n";
}

