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

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


@LinkerOrder(Order.PRIMARY)
public class ExtensionLinker extends AbstractLinker {

  private static ArtifactSet addArtifacts(ArtifactSet artifacts,
      Artifact<?>... newArtifacts) {
    final ArtifactSet newSet = new ArtifactSet(artifacts);
    for (Artifact<?> artifact : newArtifacts) {
      newSet.add(artifact);
    }
    return newSet;
  }
View Full Code Here


    try {
      // Buffer for streaming data to be compressed
      byte[] buf = new byte[BUF_SIZE];

      ArtifactSet updated = new ArtifactSet(artifacts);
      for (EmittedArtifact art : artifacts.find(EmittedArtifact.class)) {
        if (art.getVisibility() != Visibility.Public) {
          // only compress things that will be served to the client
          continue;
        }
        if (art.getPartialPath().endsWith(".gz")) {
          // Already a compressed artifact
          continue;
        }
        if (allPaths.contains(art.getPartialPath() + ".gz")) {
          // It's already been compressed
          continue;
        }
        if (!filter.isIncluded(logger.branch(TreeLogger.TRACE,
            "Checking the path patterns"), art.getPartialPath())) {
          continue;
        }

        TreeLogger compressBranch = logger.branch(TreeLogger.TRACE,
            "Compressing " + art.getPartialPath());

        InputStream originalBytes = art.getContents(compressBranch);
        ByteArrayOutputStream compressedBytes = new ByteArrayOutputStream();
        GZIPOutputStream gzip = new GZIPOutputStream(compressedBytes) {
            {
              def.setLevel(Deflater.BEST_COMPRESSION);
            }
        };

        int originalLength = 0;
        int n;
        while ((n = originalBytes.read(buf)) > 0) {
          originalLength += n;
          gzip.write(buf, 0, n);
        }
        gzip.close();

        byte[] compressed = compressedBytes.toByteArray();
        if (compressed.length < originalLength) {
          updated.add(emitBytes(compressBranch, compressed,
              art.getPartialPath() + ".gz"));
          if (!leaveOriginals) {
            updated.remove(art);
          }
        }
      }
      return updated;
    } catch (IOException e) {
View Full Code Here

    CompilerContext compilerContext = compilerContextBuilder.build();
    ModuleDef module = ModuleDefLoader.loadFromClassPath(logger, compilerContext, moduleName);
    compilerContext = compilerContextBuilder.module(module).build();
    compilerContext.getOptions().setGenDir(new File(System.getProperty("java.io.tmpdir")));

    ArtifactSet allGenreatedArtifacts = new ArtifactSet();
    boolean isProd = false;
    StandardGeneratorContext context = new StandardGeneratorContext(
        compilerContext, module.getCompilationState(logger, compilerContext), allGenreatedArtifacts,
        isProd);
    return context;
View Full Code Here

        if (art.getPartialPath().startsWith(ProxyCreator.MANIFEST_ARTIFACT_DIR)) {
          readOneManifest(logger, art.getContents(logger));
        }
      }

      ArtifactSet toReturn = new ArtifactSet(artifacts);
      SyntheticArtifact manifestArt = emitString(logger,
          generateManifest(context), MANIFEST_TXT);
      manifestArt.setVisibility(Visibility.LegacyDeploy);
      toReturn.add(manifestArt);
      return toReturn;
    }
  }
View Full Code Here

  @Override
  public ArtifactSet link(TreeLogger logger, LinkerContext context,
      ArtifactSet artifacts, boolean onePermutation)
      throws UnableToCompleteException {
    if (onePermutation) {
      ArtifactSet toReturn = new ArtifactSet(artifacts);
      logger = logger.branch(TreeLogger.TRACE, "Emitting RPC log files");

      for (CompilationResult result : artifacts.find(CompilationResult.class)) {
        for (RpcLogArtifact logArt : artifacts.find(RpcLogArtifact.class)) {
          String policyStrongName = logArt.getSerializationPolicyStrongName();
          if (policyStrongName.equals(RpcLogArtifact.UNSPECIFIED_STRONGNAME)) {
            /*
             * If the artifact has no strong name of its own, use the
             * compilation strong name.
             */
            policyStrongName = result.getStrongName();
          }
          EmittedArtifact art = emitBytes(logger, logArt.getContents(),
              logArt.getQualifiedSourceName() + "-" + policyStrongName
                  + ".rpc.log");
          art.setVisibility(Visibility.Private);
          toReturn.add(art);
        }
      }

      return toReturn;
    } else {
View Full Code Here

  }

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

    toReturn.add(emitSelectionScript(logger, context, artifacts));

    return toReturn;
  }
View Full Code Here

   * been upgraded for the sharding API.
   */
  @Override
  public ArtifactSet link(TreeLogger logger, LinkerContext context,
      ArtifactSet artifacts) throws UnableToCompleteException {
    ArtifactSet toReturn = link(logger, context, artifacts, true);
    toReturn = link(logger, context, toReturn, false);
    return toReturn;
  }
View Full Code Here

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

      /*
       * Support having multiple compilation results because this method is also
       * called from the legacy link method.
       */
      for (CompilationResult compilation : toReturn.find(CompilationResult.class)) {
        // pass a writable set so that other stages can use this set for temporary storage
        toReturn.addAll(doEmitCompilation(logger, context, compilation, writableArtifacts));
        maybeAddHostedModeFile(logger, context, toReturn, compilation);
      }
      /*
       * Find edit artifacts added during linking and add them. This is done as a way of returning
       * arbitrary extra outputs from within the linker methods without having to modify
       * their return signatures to pass extra return data around.
       */
      for (SymbolMapsLinker.ScriptFragmentEditsArtifact ea : writableArtifacts.find(
          SymbolMapsLinker.ScriptFragmentEditsArtifact.class)) {
        toReturn.add(ea);
      }
      return toReturn;
    } else {
      permutationsUtil.setupPermutationsMap(artifacts);
      ArtifactSet toReturn = new ArtifactSet(artifacts);
      EmittedArtifact art = emitSelectionScript(logger, context, artifacts);
      if (art != null) {
        toReturn.add(art);
      }
      maybeOutputPropertyMap(logger, context, toReturn);
      maybeAddHostedModeFile(logger, context, toReturn, null);
      return toReturn;
    }
View Full Code Here

  /**
   * Convert all static resources in the specified module to artifacts.
   */
  public ArtifactSet getArtifactsForPublicResources(TreeLogger logger,
      ModuleDef module) {
    ArtifactSet artifacts = new ArtifactSet();
    for (String path : publicResourceOracle.getPathNames()) {
      String partialPath = path.replace(File.separatorChar, '/');
      PublicResource resource = new StandardPublicResource(partialPath,
          publicResourceOracle.getResourceMap().get(path));
      artifacts.add(resource);
      if (logger.isLoggable(TreeLogger.SPAM)) {
        logger.log(TreeLogger.SPAM, "Added public resource " + resource, null);
      }
    }

    {
      int index = 0;
      for (Script script : module.getScripts()) {
        String url = script.getSrc();
        artifacts.add(new StandardScriptReference(url, index++));
        if (logger.isLoggable(TreeLogger.SPAM)) {
          logger.log(TreeLogger.SPAM, "Added script " + url, null);
        }
      }
    }

    {
      int index = 0;
      for (String style : module.getStyles()) {
        artifacts.add(new StandardStylesheetReference(style, index++));
        if (logger.isLoggable(TreeLogger.SPAM)) {
          logger.log(TreeLogger.SPAM, "Added style " + style, null);
        }
      }
    }
View Full Code Here

  /**
   * Run linkers that have not been updated for the shardable API.
   */
  public ArtifactSet invokeLegacyLinkers(TreeLogger logger,
      ArtifactSet artifacts) throws UnableToCompleteException {
    ArtifactSet workingArtifacts = new ArtifactSet(artifacts);

    for (Linker linker : linkers) {
      if (!linker.isShardable()) {
        TreeLogger linkerLogger = logger.branch(TreeLogger.TRACE,
            "Invoking Linker " + linker.getDescription(), null);
        workingArtifacts.freeze();
        try {
          workingArtifacts = linker.link(linkerLogger, this, workingArtifacts);
        } catch (Throwable e) {
          linkerLogger.log(TreeLogger.ERROR, "Failed to link", 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.