org.gradle.api.plugins.GroovyPlugin Java Examples

The following examples show how to use org.gradle.api.plugins.GroovyPlugin. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClasspathScanPlugin.java    From joinfaces with Apache License 2.0 5 votes vote down vote up
private void configureClasspathScan(SourceSet sourceSet) {
	String taskName = sourceSet.getTaskName("scanJoinfaces", "Classpath");

	TaskProvider<ClasspathScan> scanTaskProvider = this.project.getTasks().register(taskName, ClasspathScan.class, scanTask -> {
		scanTask.getDestinationDir().set(this.project.getLayout().getBuildDirectory().dir("joinfaces/" + sourceSet.getName()));

		scanTask.getClasspath().from((Callable<FileCollection>) () -> this.project.getConfigurations().getByName(sourceSet.getRuntimeClasspathConfigurationName()));
		scanTask.getClasspath().from(this.project.getTasks().named(sourceSet.getCompileJavaTaskName()));

	});

	this.project.getPlugins().withType(GroovyPlugin.class, groovyPlugin ->
		scanTaskProvider.configure(scanTask ->
			scanTask.getClasspath().from(this.project.getTasks().named(sourceSet.getCompileTaskName("groovy")))
		)
	);
	this.project.getPlugins().withType(ScalaBasePlugin.class, scalaBasePlugin ->
		scanTaskProvider.configure(scanTask ->
			scanTask.getClasspath().from(this.project.getTasks().named(sourceSet.getCompileTaskName("scala")))
		)
	);
	this.project.getPlugins().withId("kotlin", kotlinPlugin ->
		scanTaskProvider.configure(scanTask ->
			scanTask.getClasspath().from(this.project.getTasks().named(sourceSet.getCompileTaskName("kotlin")))
		)
	);
	this.project.getPlugins().withId("org.jetbrains.kotlin.jvm", kotlinPlugin ->
		scanTaskProvider.configure(scanTask ->
			scanTask.getClasspath().from(this.project.getTasks().named(sourceSet.getCompileTaskName("kotlin")))
		)
	);

	sourceSet.getOutput().dir(Collections.singletonMap("builtBy", scanTaskProvider), scanTaskProvider.flatMap(ClasspathScan::getDestinationDir));
}
 
Example #2
Source File: CpdPluginTest.java    From gradle-cpd-plugin with Apache License 2.0 5 votes vote down vote up
static Stream<Class<? extends Plugin>> CpdPlugin_shouldAddCpdCheckTaskAsDependencyOfCheckLifecycleTaskIfPluginIsApplied() {
    return Stream.of(
            LifecycleBasePlugin.class,
            BasePlugin.class,
            LanguageBasePlugin.class,
            JavaBasePlugin.class,

            JavaPlugin.class,
            GroovyPlugin.class,
            CppPlugin.class
        );
}
 
Example #3
Source File: CpdPluginTest.java    From gradle-cpd-plugin with Apache License 2.0 5 votes vote down vote up
@Test
void CpdPlugin_shouldAddSourcesOfSubProjectsEvenIfAppliedOnlyOnParentProject(Project project, TaskProvider<Cpd> cpdCheck) {
    // When:
    Project subProject1 = ProjectBuilder.builder().withName("sub1").withParent(project).build();
    subProject1.getPlugins().apply(JavaPlugin.class);
    createProjectFiles(subProject1, "src/main/java/Clazz.java", "src/test/java/ClazzTest.java");

    Project subProject2 = ProjectBuilder.builder().withName("sub2").withParent(project).build();
    subProject2.getPlugins().apply(GroovyPlugin.class);
    createProjectFiles(subProject2, "src/main/groovy/Clazz.groovy", "src/main/resources/clazz.properties");

    subProject1.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME, sourceSet -> {
        sourceSet.getJava().srcDir(testFile(JAVA, "de/aaschmid/annotation"));
        sourceSet.getAllJava().srcDir(testFile(JAVA, "de/aaschmid/clazz"));
        sourceSet.getResources().srcDir(testFile(JAVA, "de/aaschmid/foo"));
    });
    subProject2.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME, sourceSet ->
            sourceSet.getJava().srcDir(testFile(JAVA, "de/aaschmid/test")));

    // Then:
    List<File> expected = testFilesRecurseIn(JAVA, "de/aaschmid/annotation", "de/aaschmid/clazz", "de/aaschmid/test");
    expected.add(subProject1.file("src/main/java/Clazz.java"));
    expected.add(subProject1.file("src/test/java/ClazzTest.java"));
    expected.add(subProject2.file("src/main/groovy/Clazz.groovy"));

    assertThat(cpdCheck.get().getSource()).containsExactlyInAnyOrderElementsOf(expected);

    assertThat(subProject1.getTasks().findByName("cpdCheck")).isNull();
    assertThat(subProject2.getTasks().findByName("cpdCheck")).isNull();
}
 
Example #4
Source File: AspectJPostCompileWeavingPluginTest.java    From gradle-plugins with MIT License 4 votes vote down vote up
@Test
public void applyGroovy_before() {
    project.getPlugins().apply(GroovyPlugin.class);
    project.getPlugins().apply(AspectJPostCompileWeavingPlugin.class);
}
 
Example #5
Source File: AspectJPostCompileWeavingPluginTest.java    From gradle-plugins with MIT License 4 votes vote down vote up
@Test
public void applyGroovy_after() {
    project.getPlugins().apply(AspectJPostCompileWeavingPlugin.class);
    project.getPlugins().apply(GroovyPlugin.class);
}
 
Example #6
Source File: AspectJPostCompileWeavingPluginTest.java    From gradle-plugins with MIT License 4 votes vote down vote up
@Test
public void applyGroovy_before() {
    project.getPlugins().apply(GroovyPlugin.class);
    project.getPlugins().apply(AspectJPostCompileWeavingPlugin.class);
}
 
Example #7
Source File: AspectJPostCompileWeavingPluginTest.java    From gradle-plugins with MIT License 4 votes vote down vote up
@Test
public void applyGroovy_after() {
    project.getPlugins().apply(AspectJPostCompileWeavingPlugin.class);
    project.getPlugins().apply(GroovyPlugin.class);
}