You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by do...@apache.org on 2019/07/13 11:09:24 UTC

[buildr] 05/05: Detect external annotations in the local project and add them to the generated IntelliJ IDEA module

This is an automated email from the ASF dual-hosted git repository.

donaldp pushed a commit to branch SupportExternalAnnotationArtifacts
in repository https://gitbox.apache.org/repos/asf/buildr.git

commit f3ad71f15846179237a32a0146eaa2c8ec53b3a7
Author: Peter Donald <pe...@realityforge.org>
AuthorDate: Sat Jul 13 21:09:06 2019 +1000

    Detect external annotations in the local project and add them to the generated IntelliJ IDEA module
---
 CHANGELOG              |  3 +++
 lib/buildr/ide/idea.rb | 12 ++++++++++++
 2 files changed, 15 insertions(+)

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 @@ module Buildr #:nodoc:
         '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 @@ module Buildr #:nodoc:
         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)