예제 #1
0
  private void _addTasksExpandSoyCompileDependencies(
      TranspileJSTask transpileJSTask, Configuration configuration) {

    Project project = transpileJSTask.getProject();

    RenameDependencyClosure renameDependencyClosure =
        new RenameDependencyClosure(project, configuration.getName());

    for (File file : configuration) {
      Copy copy =
          _addTaskExpandCompileDependency(
              project,
              file,
              project.getBuildDir(),
              "expandSoyCompileDependency",
              renameDependencyClosure);

      transpileJSTask.dependsOn(copy);

      String path = FileUtil.getAbsolutePath(copy.getDestinationDir());

      path += "/META-INF/resources/**/*.soy";

      transpileJSTask.soyDependency(path);
    }
  }
예제 #2
0
  private void _configureTaskTranspileJS(
      TranspileJSTask transpileJSTask,
      final DownloadNodeModuleTask downloadMetalCliTask,
      final ExecuteNpmTask npmInstallTask) {

    FileCollection fileCollection = transpileJSTask.getSourceFiles();

    if (!transpileJSTask.isEnabled()
        || (transpileJSTask.isSkipWhenEmpty() && fileCollection.isEmpty())) {

      transpileJSTask.setDependsOn(Collections.emptySet());
      transpileJSTask.setEnabled(false);

      return;
    }

    transpileJSTask.dependsOn(downloadMetalCliTask, npmInstallTask);

    transpileJSTask.setScriptFile(
        new Callable<File>() {

          @Override
          public File call() throws Exception {
            return new File(downloadMetalCliTask.getModuleDir(), "index.js");
          }
        });

    transpileJSTask.soyDependency(
        new Callable<String>() {

          @Override
          public String call() throws Exception {
            return npmInstallTask.getWorkingDir() + "/node_modules/lexicon*/src/**/*.soy";
          }
        },
        new Callable<String>() {

          @Override
          public String call() throws Exception {
            return npmInstallTask.getWorkingDir() + "/node_modules/metal*/src/**/*.soy";
          }
        });
  }