コード例 #1
0
  private void _configureTaskReplaceSoyTranslationForJavaPlugin(
      final ReplaceSoyTranslationTask replaceSoyTranslationTask) {

    replaceSoyTranslationTask.dependsOn(JavaPlugin.PROCESS_RESOURCES_TASK_NAME);

    replaceSoyTranslationTask.setSource(
        new Callable<File>() {

          @Override
          public File call() throws Exception {
            SourceSet sourceSet =
                GradleUtil.getSourceSet(
                    replaceSoyTranslationTask.getProject(), SourceSet.MAIN_SOURCE_SET_NAME);

            SourceSetOutput sourceSetOutput = sourceSet.getOutput();

            return sourceSetOutput.getResourcesDir();
          }
        });

    Task classesTask =
        GradleUtil.getTask(replaceSoyTranslationTask.getProject(), JavaPlugin.CLASSES_TASK_NAME);

    classesTask.dependsOn(replaceSoyTranslationTask);
  }
コード例 #2
0
  @SuppressWarnings("rawtypes")
  private ReplaceSoyTranslationTask _addTaskReplaceSoyTranslation(Project project) {

    final ReplaceSoyTranslationTask replaceSoyTranslationTask =
        GradleUtil.addTask(
            project, REPLACE_SOY_TRANSLATION_TASK_NAME, ReplaceSoyTranslationTask.class);

    replaceSoyTranslationTask.setDescription("Replaces 'goog.getMsg' definitions.");
    replaceSoyTranslationTask.setGroup(BasePlugin.BUILD_GROUP);
    replaceSoyTranslationTask.setIncludes(Collections.singleton("**/*.soy.js"));

    PluginContainer pluginContainer = project.getPlugins();

    pluginContainer.withId(
        _JS_MODULE_CONFIG_GENERATOR_PLUGIN_ID,
        new Action<Plugin>() {

          @Override
          public void execute(Plugin plugin) {
            replaceSoyTranslationTask.dependsOn(_CONFIG_JS_MODULES_TASK_NAME);
          }
        });

    pluginContainer.withId(
        _JS_TRANSPILER_PLUGIN_ID,
        new Action<Plugin>() {

          @Override
          public void execute(Plugin plugin) {
            replaceSoyTranslationTask.dependsOn(_TRANSPILE_JS_TASK_NAME);
          }
        });

    pluginContainer.withType(
        JavaPlugin.class,
        new Action<JavaPlugin>() {

          @Override
          public void execute(JavaPlugin javaPlugin) {
            _configureTaskReplaceSoyTranslationForJavaPlugin(replaceSoyTranslationTask);
          }
        });

    return replaceSoyTranslationTask;
  }