Author: donaldp
Date: Wed Jun 22 10:02:30 2011
New Revision: 1138371

URL: http://svn.apache.org/viewvc?rev=1138371&view=rev
Log:
BUILDR-591 Sort modules in iml files generated by idea task to ensure 
main_dependencies are exported

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

Modified: buildr/trunk/CHANGELOG
URL: 
http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=1138371&r1=1138370&r2=1138371&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Wed Jun 22 10:02:30 2011
@@ -1,4 +1,6 @@
 1.4.6 (2011-06-21)
+* Fixed:  BUILDR-591 Sort modules in iml files generated by idea task to ensure
+          main_dependencies are exported
 * Added:  Support for Scala 2.9.0+ (with help of Alexis Midon)
 * Fixed:  BUILDR-583 Update jruby install to use jruby version 1.6.1 (Alexis 
Midon)
 * Fixed:  BUILDR-582 Revert the name change for the task to generate Intellij

Modified: buildr/trunk/lib/buildr/ide/idea.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/ide/idea.rb?rev=1138371&r1=1138370&r2=1138371&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/ide/idea.rb (original)
+++ buildr/trunk/lib/buildr/ide/idea.rb Wed Jun 22 10:02:30 2011
@@ -196,7 +196,6 @@ module Buildr
 
       protected
 
-      # Note: Use the test classpath since IDEA compiles both "main" and 
"test" classes using the same classpath
       def test_dependency_details
         main_dependencies_paths = main_dependencies.map(&:to_s)
         target_dir = buildr_project.compile.target.to_s
@@ -250,26 +249,38 @@ module Buildr
           generate_initial_order_entries(xml)
           project_dependencies = []
 
+
           self.test_dependency_details.each do |dependency_path, export, 
source_path|
-            project_for_dependency = Buildr.projects.detect do |project|
-              [project.packages, project.compile.target, 
project.resources.target, project.test.compile.target, 
project.test.resources.target].flatten.
-                detect { |proj_art| proj_art.to_s == dependency_path }
-            end
-            if project_for_dependency
-              if project_for_dependency.iml? && 
!project_dependencies.include?(project_for_dependency)
-                generate_project_dependency(xml, 
project_for_dependency.iml.name, export, !export)
-              end
-              project_dependencies << project_for_dependency
-              next
-            else
-              generate_module_lib(xml, url_for_path(dependency_path), export, 
(source_path ? url_for_path(source_path) : nil), !export)
-            end
+            next unless export
+            generate_lib(xml, dependency_path, export, source_path, 
project_dependencies)
+          end
+
+          self.test_dependency_details.each do |dependency_path, export, 
source_path|
+            next if export
+            generate_lib(xml, dependency_path, export, source_path, 
project_dependencies)
           end
 
           xml.orderEntryProperties
         end
       end
 
+      def generate_lib(xml, dependency_path, export, source_path, 
project_dependencies)
+        project_for_dependency = Buildr.projects.detect do |project|
+          [project.packages, project.compile.target, project.resources.target, 
project.test.compile.target, project.test.resources.target].flatten.
+            detect { |artifact| artifact.to_s == dependency_path }
+        end
+        if project_for_dependency
+          if project_for_dependency.iml? &&
+            !project_dependencies.include?(project_for_dependency) &&
+            project_for_dependency != self.buildr_project
+            generate_project_dependency(xml, project_for_dependency.iml.name, 
export, !export)
+          end
+          project_dependencies << project_for_dependency
+        else
+          generate_module_lib(xml, url_for_path(dependency_path), export, 
(source_path ? url_for_path(source_path) : nil), !export)
+        end
+      end
+
       def jar_path(path)
         "jar://#{resolve_path(path)}!/"
       end

Modified: buildr/trunk/spec/ide/idea_spec.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/spec/ide/idea_spec.rb?rev=1138371&r1=1138370&r2=1138371&view=diff
==============================================================================
--- buildr/trunk/spec/ide/idea_spec.rb (original)
+++ buildr/trunk/spec/ide/idea_spec.rb Wed Jun 22 10:02:30 2011
@@ -551,7 +551,7 @@ describe Buildr::IntellijIdea do
       end
 
       it "depends on the associated module exactly once" do
-        @bar_iml.should have_nodes("//orderEntry[@type='module', 
@module-name='foo']", 1)
+        @bar_iml.should have_nodes("//orderEntry[@type='module', 
@module-name='foo', @exported=""]", 1)
       end
 
       it "does not depend on the other project's packaged JAR" do


Reply via email to