Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #81 from robert3005/rk/annotationprocessor
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdanfox authored Sep 5, 2018
2 parents b27d725 + 20a312a commit 15b7b90
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/groovy/org/inferred/gradle/ProcessorsPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ class ProcessorsPlugin implements Plugin<Project> {

void apply(Project project) {

project.configurations.create('processor')
def processorConf = project.configurations.create('processor')
project.extensions.create('processors', ProcessorsExtension)

// compat with gradle 4.6 annotationProcessor
def annotationProcessor = project.configurations.findByName('annotationProcessor')
if (annotationProcessor != null) {
processorConf.extendsFrom(annotationProcessor)
}

/**** javac, groovy, etc. *********************************************************************/
project.plugins.withType(JavaPlugin, { plugin ->
def convention = project.convention.plugins['java'] as JavaPluginConvention
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,37 @@ public class ProcessorsPluginFunctionalTest {
.build()
}

@Test
public void testAnnotationProcessor() throws IOException {
buildFile << """
apply plugin: 'java'
apply plugin: 'org.inferred.processors'
dependencies {
annotationProcessor 'com.google.auto.value:auto-value:1.0'
}
"""

new File(testProjectDir.newFolder('src', 'main', 'java'), 'MyClass.java') << """
import com.google.auto.value.AutoValue;
@AutoValue
public abstract class MyClass {
public abstract int getValue();
public static MyClass create(int value) {
return new AutoValue_MyClass(value);
}
}
"""

GradleRunner.create()
.withProjectDir(testProjectDir.getRoot())
.withArguments("compileJava")
.withGradleVersion("4.6")
.build()
}

@Test
public void testJavaCompilation_processorsFirst() throws IOException {
buildFile << """
Expand Down

0 comments on commit 15b7b90

Please sign in to comment.