예제 #1
0
  /**
   * Starts the underlying Chameleon instance.
   *
   * @param root the base directory of the Chameleon.
   * @throws java.io.IOException if the chameleon configuration cannot be read.
   * @throws org.osgi.framework.BundleException if the chameleon cannot be started.
   */
  private void start(File root) throws BundleException, IOException {
    ChameleonConfiguration configuration = new ChameleonConfiguration(root);
    StringBuilder packages = new StringBuilder();
    Packages.junit(packages);
    Packages.wisdomtest(packages);
    Packages.javaxinject(packages);
    Packages.assertj(packages);
    Packages.osgihelpers(packages);
    configuration.put("org.osgi.framework.system.packages.extra", packages.toString());

    chameleon = new Chameleon(configuration);
    fixLoggingSystem(root);
    chameleon.start();
    Stability.waitForStability(chameleon.context());
  }
예제 #2
0
 /**
  * Searches for the available class names given the text search
  *
  * @return all the class names found on the current classpath using the given text search filter
  */
 public SortedSet<String> findClassNames(String search, Integer limit) {
   Map<Package, ClassLoader[]> packageMap =
       Packages.getPackageMap(getClassLoaders(), ignorePackages);
   return findClassNamesInPackages(search, limit, packageMap);
 }
예제 #3
0
 private String[] getPackageNames() {
   Packages annotation = this.testClass.getAnnotation(Packages.class);
   return (annotation != null ? annotation.value() : EMPTY_STRING_ARRAY);
 }
예제 #4
0
 public LispObject execute(LispObject[] args) throws ConditionThrowable {
   if (args.length != 10) return error(new WrongNumberOfArgumentsException(this));
   final String packageName = args[0].getStringValue();
   LispObject nicknames = checkList(args[1]);
   // FIXME size is ignored
   // LispObject size = args[2];
   LispObject shadows = checkList(args[3]);
   LispObject shadowingImports = checkList(args[4]);
   LispObject use = checkList(args[5]);
   LispObject imports = checkList(args[6]);
   LispObject interns = checkList(args[7]);
   LispObject exports = checkList(args[8]);
   // FIXME docString is ignored
   // LispObject docString = args[9];
   Package pkg = Packages.findPackage(packageName);
   if (pkg != null) return pkg;
   if (nicknames != NIL) {
     LispObject list = nicknames;
     while (list != NIL) {
       String nick = javaString(list.car());
       if (Packages.findPackage(nick) != null) {
         return error(new PackageError("A package named " + nick + " already exists."));
       }
       list = list.cdr();
     }
   }
   pkg = Packages.createPackage(packageName);
   while (nicknames != NIL) {
     LispObject string = nicknames.car().STRING();
     pkg.addNickname(string.getStringValue());
     nicknames = nicknames.cdr();
   }
   while (shadows != NIL) {
     String symbolName = shadows.car().getStringValue();
     pkg.shadow(symbolName);
     shadows = shadows.cdr();
   }
   while (shadowingImports != NIL) {
     LispObject si = shadowingImports.car();
     Package otherPkg = coerceToPackage(si.car());
     LispObject symbolNames = si.cdr();
     while (symbolNames != NIL) {
       String symbolName = symbolNames.car().getStringValue();
       Symbol sym = otherPkg.findAccessibleSymbol(symbolName);
       if (sym != null) pkg.shadowingImport(sym);
       else
         return error(
             new LispError(
                 symbolName + " not found in package " + otherPkg.getName() + "."));
       symbolNames = symbolNames.cdr();
     }
     shadowingImports = shadowingImports.cdr();
   }
   while (use != NIL) {
     LispObject obj = use.car();
     if (obj instanceof Package) pkg.usePackage((Package) obj);
     else {
       LispObject string = obj.STRING();
       Package p = Packages.findPackage(string.getStringValue());
       if (p == null)
         return error(new LispError(obj.writeToString() + " is not the name of a package."));
       pkg.usePackage(p);
     }
     use = use.cdr();
   }
   while (imports != NIL) {
     LispObject si = imports.car();
     Package otherPkg = coerceToPackage(si.car());
     LispObject symbolNames = si.cdr();
     while (symbolNames != NIL) {
       String symbolName = symbolNames.car().getStringValue();
       Symbol sym = otherPkg.findAccessibleSymbol(symbolName);
       if (sym != null) pkg.importSymbol(sym);
       else
         return error(
             new LispError(
                 symbolName + " not found in package " + otherPkg.getName() + "."));
       symbolNames = symbolNames.cdr();
     }
     imports = imports.cdr();
   }
   while (interns != NIL) {
     String symbolName = interns.car().getStringValue();
     pkg.intern(symbolName);
     interns = interns.cdr();
   }
   while (exports != NIL) {
     String symbolName = exports.car().getStringValue();
     pkg.export(pkg.intern(symbolName));
     exports = exports.cdr();
   }
   return pkg;
 }
예제 #5
0
 public LispObject execute() {
   return Packages.listAllPackages();
 }
예제 #6
0
파일: Main.java 프로젝트: noscripter/kissy
  public static void commandRunnerCLI(String[] args) throws Exception {

    Options options = new Options();
    options.addOption("encodings", true, "baseUrls 's encodings");
    options.addOption("baseUrls", true, "baseUrls");
    options.addOption("require", true, "require");
    options.addOption("excludeReg", true, "excludeReg");
    options.addOption("output", true, "output");
    options.addOption("v", "version", false, "version");
    options.addOption("outputEncoding", true, "outputEncoding");
    options.addOption("outputDependency", true, "outputDependency");
    options.addOption("fixModuleName", true, "fixModuleName");

    // create the command line parser
    CommandLineParser parser = new GnuParser();
    CommandLine line;

    try {
      // parse the command line arguments
      line = parser.parse(options, args);
    } catch (ParseException exp) {
      System.out.println("Unexpected exception:" + exp.getMessage());
      return;
    }

    if (line.hasOption("v")) {
      System.out.println("KISSY Module Compiler 1.3.1");
      return;
    }

    Main builder = new Main();

    Packages packages = builder.getPackages();

    String encodingStr = line.getOptionValue("encodings");
    if (encodingStr != null) {
      packages.setEncodings(encodingStr.split(","));
    }

    String baseUrlStr = line.getOptionValue("baseUrls");
    if (baseUrlStr != null) {
      packages.setBaseUrls(baseUrlStr.split(","));
    }

    String fixModuleName = line.getOptionValue("fixModuleName");
    if (fixModuleName != null) {
      builder.setFixModuleName(true);
    }

    builder.setRequire(line.getOptionValue("require"));

    String excludeReg = line.getOptionValue("excludeReg");
    if (excludeReg != null) {
      builder.setExcludePattern(Pattern.compile(excludeReg));
    }

    builder.setOutput(line.getOptionValue("output"));

    String outputEncoding = line.getOptionValue("outputEncoding");
    if (outputEncoding != null) {
      builder.setOutputEncoding(outputEncoding);
    }

    builder.setOutputDependency(line.getOptionValue("outputDependency"));

    builder.run();
  }
예제 #7
0
파일: Main.java 프로젝트: noscripter/kissy
  /**
   * x -> a,b,c : x depends on a,b,c add a,b,c then add x to final code buffer
   *
   * @param requiredModuleName module name required
   */
  private void combineRequire(String requiredModuleName) {

    // if css file, do not combine with js files
    if (requiredModuleName.endsWith(".css")
        ||
        // conditional loader
        requiredModuleName.startsWith("#")) {
      this.addDependency(requiredModuleName);
      return;
    }

    // if specify exclude this module, just return
    if (excludePattern != null && excludePattern.matcher(requiredModuleName).matches()) {
      this.addDependency(requiredModuleName);
      return;
    }

    if (!packages.isModuleExists(requiredModuleName)) {
      System.out.println("warning: module not found: " + requiredModuleName);
      this.addDependency(requiredModuleName);
      return;
    }

    Module requiredModule = packages.getModuleFromName(requiredModuleName);

    if (requiredModule == null) {
      System.err.println("error: invalid module: " + requiredModuleName);
      System.exit(1);
    }

    // x -> a,b,c
    // a -> b
    // reduce redundant parse and recursive
    if (processedModules.contains(requiredModule)) {
      return;
    }

    if (modulesVisited.contains(requiredModuleName)) {
      String error =
          "cyclic dependence: "
              + ArrayUtils.join(modulesVisited.toArray(new String[modulesVisited.size()]), ",")
              + ","
              + requiredModuleName;
      // if silence ,just return
      System.err.println(error);
      System.exit(1);
      return;
    }

    // mark as start for cyclic detection
    modulesVisited.add(requiredModuleName);

    requiredModule.completeModuleName(fixModuleName);

    String[] requires = requiredModule.getRequires();

    for (String require : requires) {
      combineRequire(require);
    }

    // remove mark for cyclic detection
    modulesVisited.remove(modulesVisited.size() - 1);

    processedModules.add(requiredModule);
  }