Author: donaldp
Date: Thu Apr 18 01:05:47 2013
New Revision: 1469116

URL: http://svn.apache.org/r1469116
Log:
Added support for SuperDevMode in gwt addon and upgraded to GWT 2.5.1 by 
default.

Modified:
    buildr/trunk/CHANGELOG
    buildr/trunk/lib/buildr/ide/idea.rb

Modified: buildr/trunk/CHANGELOG
URL: 
http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=1469116&r1=1469115&r2=1469116&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Thu Apr 18 01:05:47 2013
@@ -1,4 +1,6 @@
 1.4.12 (Pending)
+* Added:  Improved support for auto-detection of VCS dirs when creating
+          IDEA projects.
 * Added:  Added support for SuperDevMode in gwt addon and upgraded to
           GWT 2.5.1 by default.
 * Change: BUILDR-664 Update Checkstyle addon so that extra_dependencies is

Modified: buildr/trunk/lib/buildr/ide/idea.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/ide/idea.rb?rev=1469116&r1=1469115&r2=1469116&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/ide/idea.rb (original)
+++ buildr/trunk/lib/buildr/ide/idea.rb Thu Apr 18 01:05:47 2013
@@ -531,7 +531,6 @@ module Buildr #:nodoc:
 
     # IdeaModule represents an .ipr file
     class IdeaProject < IdeaFile
-      attr_accessor :vcs
       attr_accessor :extra_modules
       attr_accessor :artifacts
       attr_accessor :configurations
@@ -540,7 +539,6 @@ module Buildr #:nodoc:
       def initialize(buildr_project)
         super()
         @buildr_project = buildr_project
-        @vcs = detect_vcs
         @extra_modules = []
         @artifacts = []
         @configurations = []
@@ -719,14 +717,6 @@ module Buildr #:nodoc:
         "ipr"
       end
 
-      def detect_vcs
-        if File.directory?(buildr_project._('.svn'))
-          "svn"
-        elsif File.directory?(buildr_project._('.git'))
-          "Git"
-        end
-      end
-
       def base_document
         target = StringIO.new
         Builder::XmlMarkup.new(:target => target).project(:version => "4")
@@ -802,9 +792,30 @@ module Buildr #:nodoc:
       end
 
       def vcs_component
-        if vcs
+        project_directories = buildr_project.projects.select { |p| p.iml? 
}.collect { |p| p.base_dir }
+        project_directories << buildr_project.base_dir
+        # Guess the iml file is in the same dir as base dir
+        project_directories += self.extra_modules.collect { |p| 
File.dirname(p) }
+
+        project_directories = project_directories.sort.uniq
+
+        mappings = {}
+
+        project_directories.each do |dir|
+          if File.directory?("#{dir}/.git")
+            mappings[dir] = "Git"
+          elsif File.directory?("#{dir}/.svn")
+            mappings[dir] = "svn"
+          end
+        end
+
+        if mappings.size > 1
           create_component("VcsDirectoryMappings") do |xml|
-            xml.mapping :directory => "", :vcs => vcs
+            mappings.each_pair do |dir, vcs_type|
+              resolved_dir = resolve_path(dir)
+              mapped_dir = resolved_dir == '$PROJECT_DIR$/.' ? 
buildr_project.base_dir : resolved_dir
+              xml.mapping :directory => mapped_dir, :vcs => vcs_type
+            end
           end
         end
       end


Reply via email to