Skip to content
This repository was archived by the owner on Nov 16, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/main/groovy/com/jimdo/gradle/AptPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ class AptPlugin implements Plugin<Project> {

def applyToJavaProject(project) {
File aptOutputDir = getAptOutputDir(project)
File testAptOutputDir = getAptTestOutputDir(project)
project.task('addAptCompilerArgs') << {
project.compileJava.options.compilerArgs.addAll '-processorpath',
project.configurations.apt.asPath, '-s', aptOutputDir.path

project.compileTestJava.options.compilerArgs.addAll '-processorpath',
project.configurations.apt.asPath, '-s', testAptOutputDir.path

project.compileJava.source = project.compileJava.source.filter {
!it.path.startsWith(aptOutputDir.path)
}
Expand All @@ -38,8 +42,20 @@ class AptPlugin implements Plugin<Project> {

aptOutputDir.mkdirs()
}

project.compileTestJava.source = project.compileTestJava.source.filter {
!it.path.startsWith(testAptOutputDir.path)
}

project.compileTestJava.doFirst {
logger.info "Generating sources using the annotation processing tool:"
logger.info " Output directory: ${testAptOutputDir}"

testAptOutputDir.mkdirs()
}
}
project.tasks.getByName('compileJava').dependsOn 'addAptCompilerArgs'
project.tasks.getByName('compileTestJava').dependsOn 'addAptCompilerArgs'
}

def applyToAndroidProject(project) {
Expand Down Expand Up @@ -106,4 +122,12 @@ class AptPlugin implements Plugin<Project> {
}
project.file aptOutputDirName
}

def getAptTestOutputDir(project){
def aptTestOutputDirName = project.apt.testOutputDirName
if (!aptTestOutputDirName){
aptTestOutputDirName = 'build/source/apt-test'
}
project.file aptTestOutputDirName
}
}
1 change: 1 addition & 0 deletions src/main/groovy/com/jimdo/gradle/AptPluginExtension.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ package com.jimdo.gradle

class AptPluginExtension {
String outputDirName
String testOutputDirName
}