@@ -0,0 +1,3272 @@
+package com.google.common.html.plugin.soy;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0A%0Aimport org.apache.maven.plugin.MojoExecutionException;%0Aimport org.apache.maven.plugin.logging.Log;%0A%0Aimport com.google.common.base.Charsets;%0Aimport com.google.common.collect.ImmutableList;%0Aimport com.google.common.collect.Iterables;%0Aimport com.google.common.collect.Sets;%0Aimport com.google.common.html.plugin.Sources.Source;%0Aimport com.google.common.html.plugin.common.Ingredients.DirScanFileSetIngredient;%0Aimport com.google.common.html.plugin.common.Ingredients.FileIngredient;%0Aimport com.google.common.html.plugin.common.Ingredients.FileSetIngredient;%0Aimport com.google.common.html.plugin.common.Ingredients.OptionsIngredient;%0Aimport com.google.common.html.plugin.common.Ingredients.PathValue;%0Aimport com.google.common.html.plugin.plan.Ingredient;%0Aimport com.google.common.html.plugin.plan.Step;%0Aimport com.google.common.html.plugin.plan.StepSource;%0Aimport com.google.common.io.Files;%0Aimport com.google.template.soy.SoyFileSet;%0A%0Aabstract class AbstractSoyStep extends Step %7B%0A%0A  AbstractSoyStep(%0A      String keyPrefix,%0A      OptionsIngredient%3CSoyOptions%3E options,%0A      FileSetIngredient soySources,%0A      PathValue dest) %7B%0A    super(%0A        keyPrefix + %22:%5B%22 + options.key + %22%5D;%22 + soySources.key + %22;%22 + dest.key,%0A        ImmutableList.%3CIngredient%3Eof(options, soySources, dest),%0A        Sets.immutableEnumSet(StepSource.SOY_GENERATED, StepSource.SOY_SRC),%0A        Sets.immutableEnumSet(StepSource.JS_GENERATED));%0A  %7D%0A%0A  @Override%0A  public void execute(Log log) throws MojoExecutionException %7B%0A    OptionsIngredient%3CSoyOptions%3E optionsIng =%0A        ((OptionsIngredient%3C?%3E) inputs.get(0)).asSuperType(SoyOptions.class);%0A    DirScanFileSetIngredient soySources =%0A        (DirScanFileSetIngredient) inputs.get(1);%0A    PathValue dest = (PathValue) inputs.get(2);%0A%0A    try %7B%0A      soySources.resolve(log);%0A    %7D catch (IOException ex) %7B%0A      throw new MojoExecutionException(%22Failed to find .soy sources%22, ex);%0A    %7D%0A    Iterable%3CFileIngredient%3E soySourceFiles = soySources.mainSources();%0A%0A    if (!Iterables.isEmpty(soySourceFiles)) %7B%0A      SoyOptions options = optionsIng.getOptions();%0A      SoyFileSet.Builder sfsBuilder = options.toSoyFileSetBuilder(log);%0A%0A      ImmutableList.Builder%3CSource%3E sources = ImmutableList.builder();%0A      for (FileIngredient soySource : soySourceFiles) %7B%0A        File relPath = soySource.source.relativePath;%0A        try %7B%0A          sfsBuilder.add(%0A              Files.toString(soySource.source.canonicalPath, Charsets.UTF_8),%0A              relPath.getPath());%0A        %7D catch (IOException ex) %7B%0A          throw new MojoExecutionException(%0A              %22Failed to read soy source: %22 + relPath, ex);%0A        %7D%0A        sources.add(soySource.source);%0A      %7D%0A%0A      compileSoy(log, options, sfsBuilder, sources.build(), dest);%0A    %7D%0A  %7D%0A%0A  protected abstract void compileSoy(%0A      Log log, SoyOptions options, SoyFileSet.Builder sfsBuilder,%0A      ImmutableList%3CSource%3E sources, PathValue dest)%0A  throws MojoExecutionException;%0A%0A  @Override%0A  public void skip(Log log) throws MojoExecutionException %7B%0A    // Done%0A  %7D%0A%0A  @Override%0A  public ImmutableList%3CStep%3E extraSteps(Log log) throws MojoExecutionException %7B%0A    return ImmutableList.of();%0A  %7D%0A%0A%7D%0A

Factored out code common to SoyTo{Java,Js}