Package com.google.gwt.core.ext.linker

Examples of com.google.gwt.core.ext.linker.ArtifactSet


          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());
View Full Code Here


    }

    public ArtifactSet link(TreeLogger logger, LinkerContext context, ArtifactSet artifacts)
            throws UnableToCompleteException {
        // Create a new set of artifacts that we can modify and return.
        ArtifactSet toReturn = new ArtifactSet(artifacts);

        Set<EmittedArtifact> emittedArtifacts = artifacts.find(EmittedArtifact.class);
        for (EmittedArtifact emittedArtifact : emittedArtifacts) {
            String partialPath = emittedArtifact.getPartialPath();

            //if encounter ISC_Core.js or Page.js (when inheriting SmartGwtDebug.gwt.xml), inject the appropriate
            //isomorphicDir var so that users don't need to explicitly specify this in their host html file.
            if (partialPath.endsWith("/ISC_Core.js") || partialPath.endsWith("/Page.js")) {

                String contents = getContents(emittedArtifact, logger);
                int insertIdx = contents.indexOf("*/") + 2;
                StringBuffer sb = new StringBuffer(contents);
                sb.insert(insertIdx, "\nif(typeof isomorphicDir == 'undefined'){isomorphicDir = '" + context.getModuleName() + "/sc/';}\n");

                toReturn.remove(emittedArtifact);
                toReturn.add(emitString(logger, sb.toString(), partialPath));
            }
        }
        return toReturn;
    }
View Full Code Here

  }

  @Override
  public ArtifactSet link(TreeLogger logger, LinkerContext context,
      ArtifactSet artifacts) throws UnableToCompleteException {
    ArtifactSet toReturn = new ArtifactSet(artifacts);

    SortedSet<EmittedArtifact> emitted = toReturn.find(EmittedArtifact.class);

    for (EmittedArtifact artifact : emitted) {
      if (artifact.getPartialPath().equals(GEARS_MANIFEST)) {
        userManifest = artifact;
        toReturn.remove(artifact);
        emitted.remove(artifact);
        break;
      }
    }

    toReturn.add(emitManifest(logger, context, userManifest, emitted));

    return toReturn;
  }
View Full Code Here

  @Override
  public ArtifactSet link(TreeLogger logger, LinkerContext context, ArtifactSet artifacts, boolean onePermutation)
          throws UnableToCompleteException {

    ArtifactSet toReturn = new ArtifactSet(artifacts);
    if (toReturn.find(SelectionInformation.class).isEmpty()) {
      logger.log(TreeLogger.INFO, "devmode: generating empty " + MANIFEST);
      toReturn.add(emitString(logger, "# Empty in DevMode\n", "dev." + MANIFEST));
    }
    else if (onePermutation) {
      // Create an artifact representing the cache manifest for the current
      // permutation
      toReturn.add(createPermutationCacheManifestArtifact(context, logger, artifacts));
    }
    else {
      // Group permutations per user agent
      final Multimap<String, PermutationCacheManifestArtifact> permutations = ArrayListMultimap.create();
      for (PermutationCacheManifestArtifact pcma : artifacts.find(PermutationCacheManifestArtifact.class)) {
        permutations.put(pcma.props.get("user.agent"), pcma);
      }

      for (String userAgent : permutations.keySet()) {
        // Create a cache manifest file for every user agent
        toReturn.add(emitUserAgentCacheManifestFile(userAgent, permutations.get(userAgent), artifacts, logger));

      }

      logger.log(TreeLogger.INFO,
              "Make sure you have the following attribute added to your host page's <html> tag: <html manifest=\""
View Full Code Here

          "Generating a script selection script for module " + moduleName);
    }
    ModuleDef module = getModuleDef(logger, moduleName);
    StandardLinkerContext context = new StandardLinkerContext(logger, module,
        new JJSOptionsImpl());
    ArtifactSet artifacts = context.getArtifactsForPublicResources(logger,
        module);
    HostedModeLinker linker = new HostedModeLinker();
    return linker.generateSelectionScript(logger, context, artifacts);
  }
View Full Code Here

      logger.log(TreeLogger.INFO, "Compiling module " + module.getName(), null);
      // Use the real entry points.
      declEntryPts = module.getEntryPointTypeNames();
    }

    ArtifactSet generatorArtifacts = new ArtifactSet();
    rebindPermOracle = new DistillerRebindPermutationOracle(generatorArtifacts);
    properties = module.getProperties();
    perms = new PropertyPermutations(properties);
    WebModeCompilerFrontEnd frontEnd = new WebModeCompilerFrontEnd(
        compilationState, rebindPermOracle);
View Full Code Here

    // Set up the rebind oracle for the module.
    // It has to wait until now because we need to inject javascript.
    //
    Rules rules = module.getRules();
    rebindOracle = new StandardRebindOracle(module.getCompilationState(),
        propOracle, module, rules, genDir, shellDir, new ArtifactSet());

    // Create a completely isolated class loader which owns all classes
    // associated with a particular module. This effectively builds a
    // separate 'domain' for each running module, so that they all behave as
    // though they are running separately. This allows the shell to run
View Full Code Here

  /**
   * Run the linker stack.
   */
  private ArtifactSet invokeLinkerStack(TreeLogger logger)
      throws UnableToCompleteException {
    ArtifactSet workingArtifacts = new ArtifactSet(artifacts);
    Stack<Linker> linkerStack = new Stack<Linker>();

    EnumSet<Order> phasePre = EnumSet.of(Order.PRE, Order.PRIMARY);
    EnumSet<Order> phasePost = EnumSet.of(Order.POST);

    // Instantiate instances of the Linkers
    for (Class<? extends Linker> clazz : linkerClasses) {
      Linker linker;

      // Create an instance of the Linker
      try {
        linker = clazz.newInstance();
        linkerStack.push(linker);
      } catch (InstantiationException e) {
        logger.log(TreeLogger.ERROR, "Unable to create LinkerContextShim", e);
        throw new UnableToCompleteException();
      } catch (IllegalAccessException e) {
        logger.log(TreeLogger.ERROR, "Unable to create LinkerContextShim", e);
        throw new UnableToCompleteException();
      }

      // Detemine if we need to invoke the Linker in the current link phase
      Order order = clazz.getAnnotation(LinkerOrder.class).value();
      if (!phasePre.contains(order)) {
        continue;
      }

      // The primary Linker is guaranteed to be last in the order
      if (order == Order.PRIMARY) {
        assert linkerClasses.get(linkerClasses.size() - 1).equals(clazz);
      }

      TreeLogger linkerLogger = logger.branch(TreeLogger.TRACE,
          "Invoking Linker " + linker.getDescription(), null);

      workingArtifacts.freeze();
      try {
        workingArtifacts = linker.link(linkerLogger, this, workingArtifacts);
      } catch (Exception e) {
        linkerLogger.log(TreeLogger.ERROR, "Failed to link", e);
        throw new UnableToCompleteException();
      }
    }

    // Pop the primary linker off of the stack
    linkerStack.pop();

    // Unwind the stack
    while (!linkerStack.isEmpty()) {
      Linker linker = linkerStack.pop();
      Class<? extends Linker> linkerType = linker.getClass();

      // See if the Linker should be run in the current phase
      Order order = linkerType.getAnnotation(LinkerOrder.class).value();
      if (phasePost.contains(order)) {
        TreeLogger linkerLogger = logger.branch(TreeLogger.TRACE,
            "Invoking Linker " + linker.getDescription(), null);

        workingArtifacts.freeze();
        try {
          workingArtifacts = linker.link(linkerLogger, this, workingArtifacts);
        } catch (Exception e) {
          linkerLogger.log(TreeLogger.ERROR, "Failed to link", e);
          throw new UnableToCompleteException();
View Full Code Here

  private final Map<CompilationResult, String> compilationPartialPaths = new IdentityHashMap<CompilationResult, String>();

  @Override
  public ArtifactSet link(TreeLogger logger, LinkerContext context,
      ArtifactSet artifacts) throws UnableToCompleteException {
    ArtifactSet toReturn = new ArtifactSet(artifacts);

    for (CompilationResult compilation : toReturn.find(CompilationResult.class)) {
      toReturn.add(doEmitCompilation(logger, context, compilation));
    }

    toReturn.add(emitSelectionScript(logger, context, artifacts));
    return toReturn;
  }
View Full Code Here

  }

  @Override
  public ArtifactSet link(TreeLogger logger, LinkerContext context,
      ArtifactSet artifacts) throws UnableToCompleteException {
    ArtifactSet toReturn = super.link(logger, context, artifacts);

    try {
      // Add hosted mode iframe contents
      // TODO move this into own impl package if HostedModeLinker goes away
      String hostedHtml = Utility.getFileFromClassPath("com/google/gwt/core/ext/linker/impl/hosted.html");
      toReturn.add(emitBytes(logger, Util.getBytes(hostedHtml), "hosted.html"));
    } catch (IOException e) {
      logger.log(TreeLogger.ERROR, "Unable to copy support resource", e);
      throw new UnableToCompleteException();
    }
View Full Code Here

TOP

Related Classes of com.google.gwt.core.ext.linker.ArtifactSet

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.