package org.shipkit.internal.gradle.plugin;

import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.shipkit.gradle.plugin.PluginValidatorTask;
import org.shipkit.internal.gradle.util.JavaPluginUtil;
import org.shipkit.internal.gradle.util.TaskMaker;

/**
 * This plugin validates that every plugin has a corresponding .properties file.
 *
 * Adds tasks:
 * <ul>
 *     <li>'validatePlugins' - of type {@link PluginValidatorTask}.
 *          Validates that every plugin has a corresponding .properties file.</li>
 * </ul>
 */
public class PluginValidationPlugin implements Plugin<Project> {

    static final String VALIDATE_PLUGINS = "validatePlugins";

    @Override
    public void apply(final Project project) {
        project.getPlugins().withId("java", plugin -> TaskMaker.task(project, VALIDATE_PLUGINS, PluginValidatorTask.class, task -> {
            task.setDescription("Validates Gradle Plugins and their properties files");
            task.setSourceSet(JavaPluginUtil.getMainSourceSet(project));
        }));
    }
}

@@ -99,16 +99,62 @@
 roject;%0A
+import org.gradle.api.plugins.JavaBasePlugin;%0A
 import o
@@ -399,23 +399,8 @@
 %0A *%0A
- * Adds tasks:%0A
  * %3C
@@ -414,16 +414,21 @@
     %3Cli%3E
+Adds 
 'validat
@@ -437,17 +437,20 @@
 lugins' 
--
+task
  of type
@@ -556,16 +556,150 @@
 es file.
+%0A *          New task is configured as dependency of 'check' task so that when you run 'check', the plugins are validated%0A *          
 %3C/li%3E%0A *
@@ -952,16 +952,30 @@
 lugin -%3E
+ %7B%0A           
  TaskMak
@@ -1050,32 +1050,36 @@
 %3E %7B%0A            
+ 
+   
 task.setDescript
@@ -1142,32 +1142,36 @@
 %22);%0A            
+    
 task.setSourceSe
@@ -1211,24 +1211,135 @@
 (project));%0A
+%0A                project.getTasks().getByName(JavaBasePlugin.CHECK_TASK_NAME).dependsOn(task);%0A            %7D);%0A
         %7D));
@@ -1335,17 +1335,16 @@
        %7D
-)
 );%0A    %7D

Validate plugins with 'check' task