Detect external annotations in the local project and add them to the generated IntelliJ IDEA module
diff --git a/CHANGELOG b/CHANGELOG
index 4323deb..f5a8f3e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,9 @@
           `https://repo1.maven.org/maven2`.
 * Fixed:  Ensure pom files used in tests use https when referring to maven repositories.
 * Added:  Add support for downloading external annotations and attaching them to IntelliJ IDEA module dependencies.
+* Added:  Detect external annotations in the local project and add them to the generated IntelliJ IDEA
+          module when generating. The default location is `src/main/annotations` but other locations
+          can be specified by modifying the `project.iml.annotation_paths` property.
 
 1.5.7 (2019-02-16)
 * Fixed:  The fix that allowed special characters in usernames and passwords was only partially applied
diff --git a/lib/buildr/ide/idea.rb b/lib/buildr/ide/idea.rb
index 3ead679..e1038ba 100644
--- a/lib/buildr/ide/idea.rb
+++ b/lib/buildr/ide/idea.rb
@@ -212,6 +212,10 @@
         'iml'
       end
 
+      def annotation_paths
+        @annotation_paths ||= [buildr_project._(:source, :main, :annotations)].select {|p| File.exist?(p)}
+      end
+
       def main_source_directories
         @main_source_directories ||= [buildr_project.compile.sources].flatten.compact
       end
@@ -609,6 +613,14 @@
         xml.output(:url => file_path(self.main_output_dir.to_s))
         xml.tag!('output-test', :url => file_path(self.test_output_dir.to_s))
         xml.tag!('exclude-output')
+        paths = self.annotation_paths
+        unless paths.empty?
+          xml.tag!('annotation-paths') do |xml|
+            paths.each do |path|
+              xml.root(:url=> file_path(path))
+            end
+          end
+        end
       end
 
       def generate_content(xml)