Package com.google.gwt.dev.cfg

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


      String syntheticModuleName, Strategy strategy, RunStyle runStyle,
      BatchingStrategy batchingStrategy, TreeLogger treeLogger)
      throws UnableToCompleteException {

    // Let the runstyle compile the module.
    ModuleDef moduleDef = maybeCompileModuleImpl2(moduleName,
        syntheticModuleName, strategy, runStyle, treeLogger);

    // Add all test blocks for the module if we haven't seen this module before.
    if (!compiledModuleNames.contains(syntheticModuleName)) {
      compiledModuleNames.add(syntheticModuleName);
View Full Code Here


      TreeLogger treeLogger) throws UnableToCompleteException {
    /*
     * Synthesize a synthetic module that derives from the user-specified module
     * but also includes JUnit support.
     */
    ModuleDef moduleDef = ModuleDefLoader.createSyntheticModule(treeLogger,
        syntheticModuleName, new String[] {
            moduleName, strategy.getModuleInherit()}, true);

    // Replace any user entry points with our test runner.
    moduleDef.clearEntryPoints();
    moduleDef.addEntryPointTypeName(GWTRunner.class.getName());

    // Squirrel away the name of the active module for GWTRunnerGenerator
    ConfigurationProperty moduleNameProp = moduleDef.getProperties().createConfiguration(
        "junit.moduleName", false);
    moduleNameProp.setValue(syntheticModuleName);

    strategy.processModule(moduleDef);

View Full Code Here

        modulesToCompile.add(curModuleName);
      }
    }

    // Compile the requested module if needed.
    ModuleDef moduleDef = preCompiledModuleDefs.get(syntheticModuleName);
    if (moduleDef == null) {
      moduleDef = maybeCompileModuleImpl(moduleName, syntheticModuleName,
          strategy, runStyle, batchingStrategy, treeLogger);
    }
    return moduleDef;
View Full Code Here

  protected ModuleDef maybeCompileModuleImpl(String moduleName,
      String syntheticModuleName, Strategy strategy, RunStyle runStyle,
      BatchingStrategy batchingStrategy, TreeLogger treeLogger)
      throws UnableToCompleteException {
    modulesToCompile.remove(syntheticModuleName);
    ModuleDef moduleDef = super.maybeCompileModuleImpl(moduleName,
        syntheticModuleName, strategy, runStyle, batchingStrategy, treeLogger);
    preCompiledModuleDefs.put(syntheticModuleName, moduleDef);
    return moduleDef;
  }
View Full Code Here

    if (preCompiledModuleDefs == null) {
      preCompiledModuleDefs = new HashMap<String, ModuleDef>();
      for (String moduleName : GWTTestCase.getAllTestModuleNames()) {
        TestModuleInfo moduleInfo = GWTTestCase.getTestsForModule(moduleName);
        String syntheticModuleName = moduleInfo.getSyntheticModuleName();
        ModuleDef moduleDef = maybeCompileModuleImpl(
            moduleInfo.getModuleName(), syntheticModuleName,
            moduleInfo.getStrategy(), runStyle, batchingStrategy, treeLogger);
        preCompiledModuleDefs.put(syntheticModuleName, moduleDef);
      }
    }
View Full Code Here

      }
    }
  }

  public static Set<File> getAllModuleXMLs(final GeneratorContext context) {
    final ModuleDef moduleDef = getModuleDef(context);

    try {
      Field gwtXmlFilesField = ModuleDef.class.getDeclaredField("gwtXmlFiles");
      gwtXmlFilesField.setAccessible(true);
      return (Set<File>) gwtXmlFilesField.get(moduleDef);
View Full Code Here

          "(you may be using an incompatible GWT version)");
    }
  }

  public static Set<String> getInheritedModules(final GeneratorContext context) {
    final ModuleDef moduleDef = getModuleDef(context);

    try {
      Field inheritedModules = ModuleDef.class.getDeclaredField("inheritedModules");
      inheritedModules.setAccessible(true);
      return (Set<String>) inheritedModules.get(moduleDef);
View Full Code Here

    return getInheritedModules(context).contains(moduleName);
  }

  public static Set<String> getReloadablePackageNames(final GeneratorContext context) {
    Set<String> result = new HashSet<String>();
    ModuleDef module = getModuleDef(context);
    if (module == null) {
      return result;
    }
   
    String moduleName = module.getCanonicalName().replace(".JUnit", "");
    result.add(StringUtils.substringBeforeLast(moduleName, "."));

    List<String> dottedModulePaths = new ArrayList<String>();
    for (File moduleXmlFile : getAllModuleXMLs(context)) {
      String fileName = moduleXmlFile.getAbsolutePath();
View Full Code Here

      final StandardGeneratorContext stdContext = (StandardGeneratorContext) context;
      final Field field = StandardGeneratorContext.class.getDeclaredField("module");
      field.setAccessible(true);
      final Object o = field.get(stdContext);

      final ModuleDef moduleDef = (ModuleDef) o;

      if (moduleDef == null) {
        return Collections.emptySet();
      }

      // 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 int endIndex = moduleName.lastIndexOf('.');
      final String modulePackage = endIndex == -1 ? "" : moduleName.substring(0, endIndex);

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

    this.options = new LinkOptionsImpl(options);
  }

  public boolean run(TreeLogger logger) throws UnableToCompleteException {
    for (String moduleName : options.getModuleNames()) {
      ModuleDef module = ModuleDefLoader.loadFromClassPath(logger, moduleName);

      OutputFileSet outFileSet;
      OutputFileSet extraFileSet;
      try {
        if (options.getOutDir() == null) {
          outFileSet = chooseOutputFileSet(options.getWarDir(),
              module.getName() + "/");
          extraFileSet = chooseOutputFileSet(options.getExtraDir(),
              module.getName() + "/");
        } else {
          outFileSet = chooseOutputFileSet(options.getOutDir(),
              module.getName() + "/");
          if (options.getExtraDir() != null) {
            extraFileSet = chooseOutputFileSet(options.getExtraDir(),
                module.getName() + "-aux/", "");
          } else if (outFileSet instanceof OutputFileSetOnDirectory) {
            // Automatically emit extras into the output directory, if it's in
            // fact a directory
            extraFileSet = chooseOutputFileSet(options.getOutDir(),
                module.getName() + "-aux/");
          } else {
            extraFileSet = new NullOutputFileSet();
          }
        }
      } catch (IOException e) {
        logger.log(TreeLogger.ERROR,
            "Unexpected exception while producing output", e);
        throw new UnableToCompleteException();
      }

      List<Permutation> permsList = new ArrayList<Permutation>();
      ArtifactSet generatedArtifacts = new ArtifactSet();
      JJSOptions precompileOptions = null;

      File compilerWorkDir = options.getCompilerWorkDir(moduleName);
      List<Integer> permutationIds = new ArrayList<Integer>();
      PrecompilationResult precompileResults;
      try {
        precompileResults = Util.readFileAsObject(new File(compilerWorkDir,
            Precompile.PRECOMPILE_FILENAME), PrecompilationResult.class);
      } catch (ClassNotFoundException e) {
        logger.log(TreeLogger.ERROR, "Error reading "
            + Precompile.PRECOMPILE_FILENAME);
        return false;
      } catch (IOException e) {
        logger.log(TreeLogger.ERROR, "Error reading "
            + Precompile.PRECOMPILE_FILENAME);
        return false;
      }

      if (precompileResults instanceof PrecompileOptions) {
        /**
         * Precompiling happened on the shards.
         */
        precompileOptions = (JJSOptions) precompileResults;
        int numPermutations = module.getProperties().numPermutations();
        for (int i = 0; i < numPermutations; ++i) {
          permutationIds.add(i);
        }
      } else {
        /**
         * Precompiling happened on the start node.
         */
        Precompilation precompilation = (Precompilation) precompileResults;
        permsList.addAll(Arrays.asList(precompilation.getPermutations()));
        generatedArtifacts.addAll(precompilation.getGeneratedArtifacts());
        precompileOptions = precompilation.getUnifiedAst().getOptions();

        for (Permutation perm : precompilation.getPermutations()) {
          permutationIds.add(perm.getId());
        }
      }

      List<FileBackedObject<PermutationResult>> resultFiles = new ArrayList<FileBackedObject<PermutationResult>>(
          permutationIds.size());
      for (int id : permutationIds) {
        File f = CompilePerms.makePermFilename(compilerWorkDir, id);
        if (!f.exists()) {
          logger.log(TreeLogger.ERROR, "File not found '" + f.getAbsolutePath()
              + "'; please compile all permutations");
          return false;
        }
        resultFiles.add(new FileBackedObject<PermutationResult>(
            PermutationResult.class, f));
      }

      TreeLogger branch = logger.branch(TreeLogger.INFO, "Linking module "
          + module.getName());
      StandardLinkerContext linkerContext = new StandardLinkerContext(branch,
          module, precompileOptions);

      ArtifactSet artifacts = doLink(branch, linkerContext, generatedArtifacts,
          resultFiles);
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.