Author: boisvert
Date: Sun Sep 13 23:59:15 2009
New Revision: 814444

URL: http://svn.apache.org/viewvc?rev=814444&view=rev
Log:
BUILDR-300: Make Eclipse task more configurable; forgot new directory

Added:
    buildr/trunk/lib/buildr/ide/eclipse/
    buildr/trunk/lib/buildr/ide/eclipse/java.rb
    buildr/trunk/lib/buildr/ide/eclipse/plugin.rb
    buildr/trunk/lib/buildr/ide/eclipse/scala.rb

Added: buildr/trunk/lib/buildr/ide/eclipse/java.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/ide/eclipse/java.rb?rev=814444&view=auto
==============================================================================
--- buildr/trunk/lib/buildr/ide/eclipse/java.rb (added)
+++ buildr/trunk/lib/buildr/ide/eclipse/java.rb Sun Sep 13 23:59:15 2009
@@ -0,0 +1,53 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+
+require 'buildr/core/project'
+require 'buildr/core/common'
+
+module Buildr
+  module Eclipse
+    module Java
+      include Extension
+
+      NATURE    = 'org.eclipse.jdt.core.javanature'
+      CONTAINER = 'org.eclipse.jdt.launching.JRE_CONTAINER'
+      BUILDER    = 'org.eclipse.jdt.core.javabuilder'
+
+      after_define do |project|
+        eclipse = project.eclipse
+
+        # smart defaults
+        if project.compile.language == :java || project.test.compile.language 
== :java
+          eclipse.natures = NATURE if eclipse.natures.empty?
+          eclipse.classpath_containers = CONTAINER if 
eclipse.classpath_containers.empty?
+          eclipse.builders = BUILDER if eclipse.builders.empty?
+        end
+
+        # :java nature explicitly set
+        if eclipse.natures.include? :java
+          eclipse.natures += NATURE unless eclipse.natures.include? NATURE
+          eclipse.classpath_containers += CONTAINER unless 
eclipse.classpath_containers.include? CONTAINER
+          eclipse.builders += BUILDER unless eclipse.builders.include? BUILDER
+        end
+      end
+
+    end
+  end
+end
+
+class Buildr::Project
+  include Buildr::Eclipse::Java
+end

Added: buildr/trunk/lib/buildr/ide/eclipse/plugin.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/ide/eclipse/plugin.rb?rev=814444&view=auto
==============================================================================
--- buildr/trunk/lib/buildr/ide/eclipse/plugin.rb (added)
+++ buildr/trunk/lib/buildr/ide/eclipse/plugin.rb Sun Sep 13 23:59:15 2009
@@ -0,0 +1,68 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+
+require 'buildr/core/project'
+require 'buildr/core/common'
+
+module Buildr
+  module Eclipse
+    module Plugin
+      include Extension
+
+      NATURE    = 'org.eclipse.pde.PluginNature'
+      CONTAINER = 'org.eclipse.pde.core.requiredPlugins'
+      BUILDERS   = ['org.eclipse.pde.ManifestBuilder', 
'org.eclipse.pde.SchemaBuilder']
+
+      after_define do |project|
+        eclipse = project.eclipse
+
+        # smart defaults
+        if eclipse.natures.empty? && ((File.exists? 
project.path_to("plugin.xml")) || (File.exists? project.path_to("OSGI-INF")))
+          eclipse.natures = [NATURE, Buildr::Eclipse::Java::NATURE]
+          eclipse.classpath_containers = [CONTAINER, 
Buildr::Eclipse::Java::CONTAINER] if eclipse.classpath_containers.empty?
+          eclipse.builders = BUILDERS + [Buildr::Eclipse::Java::BUILDER] if 
eclipse.builders.empty?
+        end
+
+        # :plugin nature explicitly set
+        if eclipse.natures.include? :plugin
+          unless eclipse.natures.include? NATURE
+            # plugin nature must be before java nature
+            eclipse.natures += [Buildr::Eclipse::Java::NATURE] unless 
eclipse.natures.include? Buildr::Eclipse::Java::NATURE
+            index = eclipse.natures.index(Buildr::Eclipse::Java::NATURE) || -1
+            eclipse.natures = eclipse.natures.insert(index, NATURE)
+          end
+          unless eclipse.classpath_containers.include? CONTAINER
+            # plugin container must be before java container
+            index = 
eclipse.classpath_containers.index(Buildr::Eclipse::Java::CONTAINER) || -1
+            eclipse.classpath_containers = 
eclipse.classpath_containers.insert(index, CONTAINER)
+          end
+          unless (eclipse.builders.include?(BUILDER[0]) && 
eclipse.builders.include?(BUILDER[1]))
+            # plugin builder must be before java builder
+            index = 
eclipse.classpath_containers.index(Buildr::Eclipse::Java::BUILDER) || -1
+            eclipse.builders = eclipse.builders.insert(index, BUILDER[1]) 
unless eclipse.builders.include? BUILDER[1]
+            index = eclipse.classpath_containers.index(BUILDER[1]) || -1
+            eclipse.builders = eclipse.builders.insert(index, BUILDER[0]) 
unless eclipse.builders.include? BUILDER[0]
+          end
+        end
+      end
+
+    end
+  end
+end
+
+class Buildr::Project
+  include Buildr::Eclipse::Plugin
+end

Added: buildr/trunk/lib/buildr/ide/eclipse/scala.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/ide/eclipse/scala.rb?rev=814444&view=auto
==============================================================================
--- buildr/trunk/lib/buildr/ide/eclipse/scala.rb (added)
+++ buildr/trunk/lib/buildr/ide/eclipse/scala.rb Sun Sep 13 23:59:15 2009
@@ -0,0 +1,66 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+
+require 'buildr/core/project'
+require 'buildr/core/common'
+
+module Buildr
+  module Eclipse
+    module Scala
+      include Extension
+
+      NATURE    = 'ch.epfl.lamp.sdt.core.scalanature'
+      CONTAINER = 'ch.epfl.lamp.sdt.launching.SCALA_CONTAINER'
+      BUILDER   = 'ch.epfl.lamp.sdt.core.scalabuilder'
+
+      after_define do |project|
+        eclipse = project.eclipse
+
+        # smart defaults
+        if eclipse.natures.empty? && (project.compile.language == :scala || 
project.test.compile.language == :scala)
+          eclipse.natures = [NATURE, Buildr::Eclipse::Java::NATURE]
+          eclipse.classpath_containers = [CONTAINER, 
Buildr::Eclipse::Java::CONTAINER] if eclipse.classpath_containers.empty?
+          eclipse.builders = BUILDER if eclipse.builders.empty?
+        end
+
+        # :scala nature explicitly set
+        if eclipse.natures.include? :scala
+          unless eclipse.natures.include? NATURE
+            # scala nature must be before java nature
+            eclipse.natures += [Buildr::Eclipse::Java::NATURE] unless 
eclipse.natures.include? Buildr::Eclipse::Java::NATURE
+            index = eclipse.natures.index(Buildr::Eclipse::Java::NATURE) || -1
+            eclipse.natures = eclipse.natures.insert(index, NATURE)
+          end
+          unless eclipse.classpath_containers.include? CONTAINER
+            # scala container must be before java container
+            index = 
eclipse.classpath_containers.index(Buildr::Eclipse::Java::CONTAINER) || -1
+            eclipse.classpath_containers = 
eclipse.classpath_containers.insert(index, CONTAINER)
+          end
+          unless eclipse.builders.include? BUILDER
+            # scala builder overrides java builder
+            eclipse.builders -= [Buildr::Eclipse::Java::BUILDER]
+            eclipse.builders += [BUILDER]
+          end
+        end
+      end
+
+    end
+  end
+end
+
+class Buildr::Project
+  include Buildr::Eclipse::Scala
+end


Reply via email to