Created
July 18, 2012 17:13
-
-
Save cacoco/3137530 to your computer and use it in GitHub Desktop.
Apache Buildr Task for Generating Java sources using the Java Annotation Processor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWS_JAVA_SDK_BUILD_TOOLS = ["com.amazonaws:aws-java-sdk:jar:1.3.10", | |
"com.amazonaws:aws-java-sdk-flow-build-tools:jar:1.3.10"] | |
# The following is assumed to be embedded inside a project definition, otherwise | |
# you will need to pass the project to the task. | |
... | |
# Task for Generating Sources via Java APT, note this overwrites any current source | |
task :apt do | |
rm_rf project.path_to(:src, :generated, :java) | |
mkdir_p project.path_to(:src, :generated, :java) | |
classpath = Buildr.artifacts(AWS_JAVA_SDK_BUILD_TOOLS).each(&:invoke).map(&:to_s) | |
classpath << project.path_to(:target, :classes) | |
Buildr.ant("apt") do |ant| | |
ant.apt :includeantruntime => false, | |
:fork => true, | |
:optimize => "on", | |
:srcdir => project.path_to(:src, :main, :java), # what files to use as input | |
:classpath => classpath.join(File::PATH_SEPARATOR), # what's the classpath, the aws build tools jar needs to be here | |
:source => "1.5", # APT only works with 1.5 or lower... | |
:verbose => true do | |
ant.compilerarg :line => "-proc:only" # don't compile, process only | |
ant.compilerarg :line => "-s #{project.path_to(:src, :generated, :java)}" # where to put the generated source | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment