Author: boisvert
Date: Wed Aug 20 09:07:18 2008
New Revision: 687380

URL: http://svn.apache.org/viewvc?rev=687380&view=rev
Log:
Eclipse task updated to latest documented Scala plugin requirements

Modified:
    incubator/buildr/trunk/lib/buildr/ide/eclipse.rb
    incubator/buildr/trunk/spec/eclipse_spec.rb

Modified: incubator/buildr/trunk/lib/buildr/ide/eclipse.rb
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/ide/eclipse.rb?rev=687380&r1=687379&r2=687380&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/ide/eclipse.rb (original)
+++ incubator/buildr/trunk/lib/buildr/ide/eclipse.rb Wed Aug 20 09:07:18 2008
@@ -130,8 +130,8 @@
                 end
               end
 
-              xml.classpathentry :kind=>'con', 
:path=>'org.eclipse.jdt.launching.JRE_CONTAINER'
               xml.classpathentry :kind=>'con', 
:path=>'ch.epfl.lamp.sdt.launching.SCALA_CONTAINER' if scala
+              xml.classpathentry :kind=>'con', 
:path=>'org.eclipse.jdt.launching.JRE_CONTAINER'
             end
           end
         end
@@ -145,20 +145,19 @@
               xml.name project.id
               xml.projects
               xml.buildSpec do
-                xml.buildCommand do
-                  xml.name "org.eclipse.jdt.core.javabuilder"
-                end
                 if scala
                   xml.buildCommand do
                     xml.name "ch.epfl.lamp.sdt.core.scalabuilder"
-                    #xml.name "scala.plugin.scalabuilder"
+                  end
+                else
+                  xml.buildCommand do
+                    xml.name "org.eclipse.jdt.core.javabuilder"
                   end
                 end
               end
               xml.natures do
-                xml.nature "org.eclipse.jdt.core.javanature"
                 xml.nature "ch.epfl.lamp.sdt.core.scalanature" if scala
-                #xml.nature "scala.plugin.scalanature" if scala
+                xml.nature "org.eclipse.jdt.core.javanature"
               end
             end
           end

Modified: incubator/buildr/trunk/spec/eclipse_spec.rb
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/eclipse_spec.rb?rev=687380&r1=687379&r2=687380&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/eclipse_spec.rb (original)
+++ incubator/buildr/trunk/spec/eclipse_spec.rb Wed Aug 20 09:07:18 2008
@@ -18,8 +18,74 @@
 
 describe Buildr::Eclipse do
 
+  describe "eclipse's .project file" do
+    
+    describe 'scala project' do
+
+      SCALA_NATURE = 'ch.epfl.lamp.sdt.core.scalanature'
+      JAVA_NATURE  = 'org.eclipse.jdt.core.javanature'
+
+      SCALA_BUILDER = 'ch.epfl.lamp.sdt.core.scalabuilder'
+      JAVA_BUILDER  = 'org.eclipse.jdt.core.javabuilder'
+      
+      def project_natures
+        task('eclipse').invoke
+        REXML::Document.new(File.open('.project')).
+          root.elements.collect("natures/nature") { |n| n.text }
+      end
+
+      def build_commands
+        task('eclipse').invoke
+        REXML::Document.new(File.open('.project')).
+          root.elements.collect("buildSpec/buildCommand/name") { |n| n.text }
+      end
+
+      before do
+        write 'buildfile'
+        write 'src/main/scala/Main.scala'
+      end
+      
+      it 'should have Scala nature before Java nature' do
+        define('foo')
+        project_natures.should include(SCALA_NATURE)
+        project_natures.should include(JAVA_NATURE)
+        project_natures.index(SCALA_NATURE).should < 
project_natures.index(JAVA_NATURE)
+      end
+
+      it 'should have Scala build command and no Java build command' do
+        define('foo')
+        build_commands.should include(SCALA_BUILDER)
+        build_commands.should_not include(JAVA_BUILDER)
+      end
+    end
+  end
+  
   describe "eclipse's .classpath file" do
     
+    describe 'scala project' do
+
+      SCALA_CONTAINER = 'ch.epfl.lamp.sdt.launching.SCALA_CONTAINER'
+      JAVA_CONTAINER  = 'org.eclipse.jdt.launching.JRE_CONTAINER'
+      
+      def classpath_containers attribute='path'
+        task('eclipse').invoke
+        REXML::Document.new(File.open('.classpath')).
+          root.elements.collect("[EMAIL PROTECTED]'con']") { |n| 
n.attributes[attribute] }
+      end
+
+      before do
+        write 'buildfile'
+        write 'src/main/scala/Main.scala'
+      end
+      
+      it 'should have SCALA_CONTAINER before JRE_CONTAINER' do
+        define('foo')
+        classpath_containers.should include(SCALA_CONTAINER)
+        classpath_containers.should include(JAVA_CONTAINER)
+        classpath_containers.index(SCALA_CONTAINER).should < 
classpath_containers.index(JAVA_CONTAINER)
+      end
+    end
+    
     describe 'source folders' do
       
       def classpath_sources attribute='path'


Reply via email to