Package com.google.gwt.dev.cfg

Examples of com.google.gwt.dev.cfg.ModuleDef


    TreeLogger branch = getTopLogger().branch(TreeLogger.INFO,
        "Loading modules");
    for (String moduleName : options.getModuleNames()) {
      TreeLogger moduleBranch = branch.branch(TreeLogger.INFO, moduleName);
      try {
        ModuleDef module = loadModule(moduleBranch, moduleName, false);
        validateServletTags(moduleBranch, servletValidator, module, webXml);
        TreeLogger loadLogger = moduleBranch.branch(TreeLogger.DEBUG,
            "Bootstrap link for command-line module '" + moduleName + "'");
        link(loadLogger, module);
      } catch (UnableToCompleteException e) {
View Full Code Here


   * Overridden to keep our map up to date.
   */
  @Override
  protected ModuleDef loadModule(TreeLogger logger, String moduleName,
      boolean refresh) throws UnableToCompleteException {
    ModuleDef module = super.loadModule(logger, moduleName, refresh);
    modulesByName.put(module.getName(), module);
    return module;
  }
View Full Code Here

      // No need to check mkdirs result because an IOException will occur anyway
      compilerWorkDir.mkdirs();

      File precompilationFile = new File(compilerWorkDir, PRECOMPILE_FILENAME);

      ModuleDef module = ModuleDefLoader.loadFromClassPath(logger, moduleName);

      boolean generateOnShards = options.isEnabledGeneratingOnShards();
      if (options.isValidateOnly()) {
        // Don't bother running on shards for just a validation run
        generateOnShards = false;
      } else if (options.getDumpSignatureFile() != null) {
        logger.log(TreeLogger.INFO,
            "Precompiling on the start node, because a dump signature file was specified");
        /*
         * It would be possible to shard in this case, too. However, each
         * permutation would have its own signatures dumped. Either the output
         * would need to be multiple dump files, or those files would need to be
         * combined back into one.
         */
        generateOnShards = false;
      }

      if (generateOnShards) {
        /*
         * Pre-precompile. Count the permutations and plan to do a real
         * precompile in the CompilePerms shards.
         */
        TreeLogger branch = logger.branch(TreeLogger.INFO,
            "Precompiling (minimal) module " + module.getName());
        Util.writeObjectAsFile(logger, precompilationFile, options);
        int numPermutations = module.getProperties().numPermutations();
        Util.writeStringAsFile(logger, new File(compilerWorkDir,
            PERM_COUNT_FILENAME), String.valueOf(numPermutations));
        branch.log(TreeLogger.INFO,
            "Precompilation (minimal) succeeded, number of permutations: "
                + numPermutations);
      } else {
        // TODO: All JDT checks now before even building TypeOracle?
        module.getCompilationState(logger);

        if (options.isValidateOnly()) {
          TreeLogger branch = logger.branch(TreeLogger.INFO,
              "Validating compilation " + module.getName());
          if (!validate(branch, options, module, options.getGenDir(),
              compilerWorkDir, options.getDumpSignatureFile())) {
            branch.log(TreeLogger.ERROR, "Validation failed");
            return false;
          }
          branch.log(TreeLogger.INFO, "Validation succeeded");
        } else {
          TreeLogger branch = logger.branch(TreeLogger.INFO,
              "Precompiling module " + module.getName());

          Precompilation precompilation = precompile(branch, options, module,
              options.getGenDir(), compilerWorkDir,
              options.getDumpSignatureFile());
          if (precompilation == null) {
View Full Code Here

   * @throws UnableToCompleteException
   */
  protected ModuleDef loadModule(TreeLogger logger, String moduleName,
      boolean refresh) throws UnableToCompleteException {
    refresh &= alreadySeenModules.contains(moduleName);
    ModuleDef moduleDef = ModuleDefLoader.loadFromClassPath(logger, moduleName,
        refresh);
    alreadySeenModules.add(moduleName);
    assert (moduleDef != null) : "Required module state is absent";
    return moduleDef;
  }
View Full Code Here

          moduleName, sessionKey, agentTag, userAgentIcon, maxLevel);
      // TODO(jat): add support for closing an active module
      logger = module.getLogger();
      try {
        // Try to find an existing loaded version of the module def.
        ModuleDef moduleDef = loadModule(logger, moduleName, true);
        assert (moduleDef != null);

        // Create a sandbox for the module.
        // TODO(jat): consider multiple instances of the same module open at
        // once
        TypeOracle typeOracle = moduleDef.getTypeOracle(logger);
        ShellModuleSpaceHost host = doCreateShellModuleSpaceHost(logger,
            typeOracle, moduleDef);

        loadedModules.put(host, module);
        return host;
View Full Code Here

      throws UnableToCompleteException {
    precompilationOptions.setOptimizePrecompile(false);
    precompilationOptions.setCompilationStateRetained(true);
    precompilationOptions.setGenDir(null);

    ModuleDef module = ModuleDefLoader.loadFromClassPath(logger, moduleName);
    PropertyPermutations allPermutations = new PropertyPermutations(
        module.getProperties());
    int[] perms = options.getPermsToCompile();
    if (perms == null) {
      perms = new int[allPermutations.size()];
      for (int i = 0; i < perms.length; ++i) {
        perms[i] = i;
      }
    }

    logger = logger.branch(TreeLogger.INFO, "Compiling " + perms.length
        + " permutation" + (perms.length > 1 ? "s" : ""));
    for (int permId : perms) {
      /*
       * TODO(spoon,scottb): move Precompile out of the loop to run only once
       * per shard. We'll need a new PropertyPermutations constructor that can
       * take a precise list. Then figure out a way to avoid copying the
       * generated artifacts into every perm result on a shard.
       */
      module.getCompilationState(logger).refresh(logger);
      PropertyPermutations onePerm = new PropertyPermutations(allPermutations,
          permId, 1);

      assert (precompilationOptions.getDumpSignatureFile() == null);
      Precompilation precompilation = Precompile.precompile(logger,
View Full Code Here

        options.setWorkDir(Utility.makeTemporaryDirectory(null, "gwtc"));
        tempWorkDir = true;
      }

      for (String moduleName : options.getModuleNames()) {
        ModuleDef module = ModuleDefLoader.loadFromClassPath(logger,
            moduleName, true);
        File compilerWorkDir = options.getCompilerWorkDir(moduleName);

        if (options.isValidateOnly()) {
          if (!Precompile.validate(logger, options, module,
              options.getGenDir(), compilerWorkDir,
              options.getDumpSignatureFile())) {
            return false;
          }
        } else {
          long compileStart = System.currentTimeMillis();
          TreeLogger branch = logger.branch(TreeLogger.INFO,
              "Compiling module " + moduleName);

          // Optimize early since permutation compiles will run in process.
          options.setOptimizePrecompile(true);
          Precompilation precompilation = Precompile.precompile(branch,
              options, module, options.getGenDir(), compilerWorkDir,
              options.getDumpSignatureFile());

          if (precompilation == null) {
            return false;
          }

          Permutation[] allPerms = precompilation.getPermutations();
          List<FileBackedObject<PermutationResult>> resultFiles = CompilePerms.makeResultFiles(
              options.getCompilerWorkDir(moduleName), allPerms);
          CompilePerms.compile(branch, precompilation, allPerms,
              options.getLocalWorkers(), resultFiles);

          ArtifactSet generatedArtifacts = precompilation.getGeneratedArtifacts();
          JJSOptions precompileOptions = precompilation.getUnifiedAst().getOptions();

          precompilation = null; // No longer needed, so save the memory

          File absPath = new File(options.getWarDir(), module.getName());
          absPath = absPath.getAbsoluteFile();
          Link.link(logger.branch(TreeLogger.TRACE, "Linking into " + absPath),
              module, generatedArtifacts, resultFiles, options.getWarDir(),
              options.getExtraDir(), precompileOptions);
View Full Code Here

    List<String> packages = new ArrayList<String>();
    try {
      StandardGeneratorContext stdContext = (StandardGeneratorContext) context;
      Field field = StandardGeneratorContext.class.getDeclaredField("module");
      field.setAccessible(true);
      ModuleDef moduleDef = (ModuleDef) field.get(stdContext);

      // moduleName looks like "com.foo.xyz.MyModule" and we just want the package part
      // for tests .JUnit is appended to the module name by GWT
      String moduleName = moduleDef.getCanonicalName().replace(".JUnit", "");
      String modulePackage = moduleName.substring(0, moduleName.lastIndexOf('.'));

      for (String packageName : findTranslatablePackages(context)) {
        if (packageName != null && packageName.startsWith(modulePackage)) {
          packages.add(packageName);
View Full Code Here

    try {
      final StandardGeneratorContext standardGeneratorContext =
              (StandardGeneratorContext) context;
      final Field field = StandardGeneratorContext.class.getDeclaredField("module");
      field.setAccessible(true);
      final ModuleDef moduleDef = (ModuleDef) field.get(standardGeneratorContext);
      return moduleDef.getCanonicalName();
    }
    catch (Throwable t) {
      return null;
    }
  }
View Full Code Here

    final Set<String> packages = new HashSet<String>();
    try {
      final StandardGeneratorContext stdContext = (StandardGeneratorContext) context;
      final Field field = StandardGeneratorContext.class.getDeclaredField("module");
      field.setAccessible(true);
      final ModuleDef moduleDef = (ModuleDef) field.get(stdContext);

      // moduleName looks like "com.foo.xyz.MyModule" and we just want the package part
      // for tests .JUnit is appended to the module name by GWT
      final String moduleName = moduleDef.getCanonicalName().replace(".JUnit", "");
      final String modulePackage = moduleName.substring(0, moduleName.lastIndexOf('.'));

      for (String packageName : findTranslatablePackages(context)) {
        if (packageName != null && packageName.startsWith(modulePackage)) {
          packages.add(packageName);
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.cfg.ModuleDef

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.