Hi

The attached patch adds a new menu choice for "buildr generate" to generate a 
buildfile from the eclipse projects present in the workspace.

Contrary to the existing Eclipse extension it considers the existing Eclipse 
files to be master and trying to create a buildfile based on the extracted 
values.

It needs some polishing before a final submission, but is already capable of
- detecting eclipse project (which may be anywhere in a subdir)
- project-names from eclipse .project-files override directory names
- uses default eclipse values ('src','bin') for layout[:source,:target]
- get the project version from MANIFEST.MF
- adds dependencies between project
- adds hints for all plugin
- skips fragments (would need buildr4osgi to handle them correctly)

There are quite a few specs (including some pendings, which reflect the task I 
would like to accomplish in the next few months).

I would be happy if you could review the patch. I will try to improve it based 
on your suggestions.

For me it is a first step for a to provide a simple, yet powerful way which 
should convince 'hardcore' Eclipse GUI developers that for continuos 
integration buildr.apache.org provides a simple, powerful way for headless, 
aka command line based builds.

Attached is a generated buildfile (generated in the subdirectory src of a git 
clone https://github.com/zdavatz/elexis).

Please let me know about necessary changes to get my patch accepted.

Best regards

Niklaus


From 0920bb585ec4e0611301fd1aab1c3f3c71a883d7 Mon Sep 17 00:00:00 2001
From: Niklaus Giger <niklaus.gi...@member.fsf.org>
Date: Sat, 21 Jul 2012 23:19:19 +0200
Subject: [PATCH] Generate buildfile from Eclipse workspace


Signed-off-by: Niklaus Giger <niklaus.gi...@member.fsf.org>
---
 lib/buildr/core/application.rb          |   22 ++-
 lib/buildr/core/generate.rb             |  174 ++++++++++++++++-
 spec/core/generate_from_eclipse_spec.rb |  310 +++++++++++++++++++++++++++++++
 3 files changed, 491 insertions(+), 15 deletions(-)
 create mode 100644 spec/core/generate_from_eclipse_spec.rb

diff --git a/lib/buildr/core/application.rb b/lib/buildr/core/application.rb
index 2391372..d00e9c2 100644
--- a/lib/buildr/core/application.rb
+++ b/lib/buildr/core/application.rb
@@ -387,23 +387,31 @@ module Buildr
     end
 
     def ask_generate_buildfile
-      source = choose do |menu|
-        menu.header = "To use Buildr you need a buildfile. Do you want me to create one?"
-        menu.choice("From Maven2 POM file") { 'pom.xml' } if File.exist?('pom.xml')
-        menu.choice("From directory structure") { Dir.pwd }
+      source, fromEclipse = choose do |menu|
+        menu.header = "ngng: To use Buildr you need a buildfile. Do you want me to create one?"
+	menu.choice("From eclipse .project files") { [Dir.pwd, true] } if Generate.hasEclipseProject
+        menu.choice("From Maven2 POM file") { ['pom.xml', false] } if File.exist?('pom.xml')
+        menu.choice("From directory structure") { [Dir.pwd, false] }
         menu.choice("Cancel") { }
       end
       if source
-        buildfile = raw_generate_buildfile(source)
+        buildfile = raw_generate_buildfile(source, fromEclipse)
         [buildfile, File.dirname(buildfile)]
       end
     end
 
-    def raw_generate_buildfile(source)
+    def raw_generate_buildfile(source, fromEclipse)
       # We need rakefile to be known, for settings.build to be accessible.
       @rakefile = File.expand_path(DEFAULT_BUILDFILES.first)
       fail "Buildfile already exists" if File.exist?(@rakefile) && !(tty_output? && agree('Buildfile exists, overwrite?'))
-      script = File.directory?(source) ? Generate.from_directory(source) : Generate.from_maven2_pom(source)
+      script = nil
+      if fromEclipse
+	script = Generate.from_eclipse(source)
+      elsif File.directory?(source)
+	script = Generate.from_directory(source)
+      else
+	script = Generate.from_maven2_pom(source)
+      end
       File.open @rakefile, 'w' do |file|
         file.puts script
       end
diff --git a/lib/buildr/core/generate.rb b/lib/buildr/core/generate.rb
index 815aaac..4ce5595 100644
--- a/lib/buildr/core/generate.rb
+++ b/lib/buildr/core/generate.rb
@@ -20,7 +20,7 @@ module Buildr
       script = nil
       choose do |menu|
         menu.header = "To use Buildr you need a buildfile. Do you want me to create one?"
-
+	menu.choice("From eclipse .project files") { script = Generate.from_eclipse(Dir.pwd).join("\n") } if hasEclipseProject
         menu.choice("From maven2 pom file") { script = Generate.from_maven2_pom('pom.xml').join("\n") } if File.exists?("pom.xml")
         menu.choice("From directory structure") { script = Generate.from_directory(Dir.pwd).join("\n") }
         menu.choice("Skip") { }
@@ -34,15 +34,48 @@ module Buildr
     end
 
     class << self
+      def getProjectNatures(projectFile)
+	return nil if !File.exists?(projectFile)
+	File.open(projectFile) {
+	  |f|
+	  root = REXML::Document.new(f).root
+	  return nil if root == nil
+	  natures = root.elements.collect("natures/nature") { |n| n.text }
+	  return natures if natures
+	}
+	return nil
+      end
+      
+      def isEclipseProjet(projectFile)
+	return getProjectNatures(projectFile)
+	File.open(projectFile) {
+	  |f|
+	  root = REXML::Document.new(f).root
+	  return false if root == nil
+	  natures = root.elements.collect("natures/nature") { |n| n.text }
+	  return true if natures && natures.size > 0
+	}
+	return false
+      end
+      
+      def getBuildProperty(path, propertyName)
+	propertiesFile = File.join(path,'build.properties')
+	return nil if !File.exists?(propertiesFile)
+	inhalt = Hash.from_java_properties(File.read(propertiesFile))
+	binDef = inhalt[propertyName]
+      end
 
-      HEADER = "# Generated by Buildr #{Buildr::VERSION}, change to your liking\n\n"
+      def hasEclipseProject
+	candidates = Dir.glob("**/.project")
+	return false if candidates.size == 0
+	candidates.each { |x| return true if getProjectNatures(x)  }
+	return false
+      end
 
-      def from_directory(path = Dir.pwd, root = true)
-        Dir.chdir(path) do
-          name = File.basename(path)
-          if root
-            script = HEADER.split("\n")
-            header = <<-EOF
+
+      HEADER = "# Generated by Buildr #{Buildr::VERSION}, change to your liking\n\n"
+      def getEclipseBuildfileHeader(path, name)
+	x = <<-EOF
 #{"require 'buildr/scala'\n" if Dir.glob(path + "/**/*.scala").size > 0}
 #{"require 'buildr/groovy'\n" if Dir.glob(path + "/**/*.groovy").size > 0}
 # Version number for this release
@@ -61,6 +94,131 @@ define "#{name}" do
   project.group = GROUP
   manifest["Implementation-Vendor"] = COPYRIGHT
             EOF
+	    return x
+      end
+
+      def setLayout(source=nil, output = nil)
+	script = ""
+	if source
+	source.sub!(/\/$/,'') # remove trailing /
+	  script += <<-EOF
+  layout[:source, :main, :java] = "#{source}"
+  layout[:source, :main, :scala] = "#{source}"
+EOF
+	end
+	if output
+	  output.sub!(/\/$/,'') # remove trailing /
+	  script += <<-EOF
+  layout[:target, :main] = "#{output}"
+  layout[:target, :main, :java] = "#{output}"
+  layout[:target, :main, :scala] = "#{output}"
+EOF
+	end
+	return script
+      end
+      # tries to read as much information as needed at the moment from an existing Eclipse workspace
+      # Here are some links to the relevant information
+      # * http://help.eclipse.org/juno/index.jsp?topic=/org.eclipse.pde.doc.user/reference/pde_feature_generating_build.htm
+      # * http://wiki.eclipse.org/FAQ_What_is_the_plug-in_manifest_file_%28plugin.xml%29%3F
+      # * http://help.eclipse.org/juno/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/bundle_manifest.html
+      # * http://help.eclipse.org/juno/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/plugin_manifest.html
+      def from_eclipse(path = Dir.pwd, root = true)
+	# We need two passes to be able to determine the dependencies correctly
+        Dir.chdir(path) do
+          name = File.basename(path)
+	  dot_projects = []
+	  mf = nil # avoid reloading manifest
+          if root
+	    @@allProjects = Hash.new
+	    @@topDir      = File.expand_path(Dir.pwd)
+            script = HEADER.split("\n")
+	    # p "from_eclipse #{path} pwd #{Dir.pwd} name is #{name}"
+	    script << "require 'buildr/ide/eclipse'"
+            header = getEclipseBuildfileHeader(path, name)
+            script += header.split("\n")
+	    script << "  # you may see hints about which jars are missing and should resolve them correctly"
+	    script << "  # dependencies  << 'junit should be commented out and replace by correct ARTIFACT definition. Eg"
+	    script << "  # dependencies  << 'junit:junit:jar:3.8.2'"
+	    script << setLayout('src', 'bin') # default values for eclipse
+	    dot_projects = Dir.glob('**/.project')
+	    # Get all project names
+            dot_projects.sort.each do |dot_project|
+	      next if !isEclipseProjet(dot_project)
+              from_eclipse(File.dirname(dot_project), false)
+            end
+          else
+	    # p "from_eclipse script name is #{name}. #{Dir.pwd}"
+	    # Skip fragments. Buildr cannot handle it without the help of buildr4osgi
+	    return [""] if File.exists?('fragment.xml')
+	    projectName = name
+	    version = ""
+	    mfName = File.join('META-INF', 'MANIFEST.MF')
+	    if File.exists?(mfName)
+	      mf = Packaging::Java::Manifest.parse(IO.readlines(mfName).join(''))
+	      if mf.main['Bundle-SymbolicName']
+		projectName = mf.main['Bundle-SymbolicName'].split(';')[0]
+		bundleVersion = mf.main['Bundle-Version']
+		version = ", :version => \"#{bundleVersion}\"" if !"1.0.0".eql?(bundleVersion)
+	      end
+	    end
+	    # in the first run we just want to know that we exist
+	    if !@@allProjects[projectName]
+	      @@allProjects[projectName] = Dir.pwd
+	      return
+	    end
+	    base_dir = ""
+	    if !File.join(@@topDir, projectName).eql?(File.expand_path(Dir.pwd))
+	      base_dir = ", :base_dir => \"#{File.expand_path(Dir.pwd).sub(@@topDir+File::SEPARATOR, '')}\""
+	    end
+	    script = [ %{define "#{projectName}"#{version}#{base_dir} do} ]
+	    
+          end
+          script <<  "  # I am in #{File.expand_path(Dir.pwd)}"
+	  natures = getProjectNatures('.project')
+	  if natures && natures.index('org.eclipse.pde.PluginNature')
+	    script <<  "  package(:jar)"
+	  end
+	  if mf && mf.main['Require-Bundle']
+	    mf.main['Require-Bundle'].split(',').each {
+	      |bundle|
+	      requiredName = bundle.split(';')[0]
+	      if @@allProjects.has_key?(requiredName)
+		script <<  "  dependencies << projects(\"#{requiredName}\")"
+	      else
+		script <<  "  # dependencies  << '#{requiredName}'"
+	      end
+	    } 
+	  end
+          script <<  "  compile.with dependencies # Add more classpath dependencies" if Dir.glob(File.join('src', '**', '*.java')).size > 0
+          script <<  "  resources" if File.exist?("rsc")
+	  # TODO: Howto handle eclipse test fragments
+#          script <<  "  test.compile.with # Add classpath dependencies" if File.exist?("src/test/java")
+#          script <<  "  test.resources" if File.exist?("src/test/resources")
+	  sourceProp = getBuildProperty('.', 'source..')
+	  outputProp = getBuildProperty('.', 'output..')
+	  if (sourceProp && !/src\/+/.match(sourceProp)) or (outputProp && !/bin\/+/.match(outputProp))
+	    setLayout(sourceProp, outputProp) # default values are overridden in this project
+	  end
+	  # TODO: Should we also try to detect WAR-projects
+          unless dot_projects.empty?
+            script << ""
+            dot_projects.sort.each do |dot_project|
+	      next if File.dirname(File.expand_path(dot_project)).eql?(File.expand_path(Dir.pwd))
+	      next if !isEclipseProjet(dot_project)
+              script << from_eclipse(File.dirname(dot_project), false).flatten.map { |line| "  " + line } << ""
+            end
+          end
+          script << "end\n\n"
+          script.flatten
+        end
+      end
+    
+      def from_directory(path = Dir.pwd, root = true)
+        Dir.chdir(path) do
+          name = File.basename(path)
+          if root
+            script = HEADER.split("\n")
+            header = getEclipseBuildfileHeader(path, name)
             script += header.split("\n")
           else
             script = [ %{define "#{name}" do} ]
diff --git a/spec/core/generate_from_eclipse_spec.rb b/spec/core/generate_from_eclipse_spec.rb
new file mode 100644
index 0000000..4940ecd
--- /dev/null
+++ b/spec/core/generate_from_eclipse_spec.rb
@@ -0,0 +1,310 @@
+# 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 File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
+
+module EclipseHelper
+  
+  def setupExample(group, projectName, options = {})
+	options[:symName] ? symName = options[:symName] :symName = File.basename(projectName)
+	requiredPlugins = nil
+	if options[:requires]
+	  requiredPlugins = "Require-Bundle: #{options[:requires]};bundle-version=\"1.1.0\",\n"
+	end
+        write "#{group}/#{projectName}/META-INF/MANIFEST.MF", <<-MANIFEST
+Manifest-Version: 1.0
+Name: #{projectName}
+Bundle-Version: 1.1
+Specification-Title: "Examples for #{File.basename(projectName)}"
+Specification-Version: "1.0"
+Specification-Vendor: "Acme Corp.".
+Implementation-Title: "#{File.basename(projectName)}"
+Implementation-Version: "build57"
+Implementation-Vendor: "Acme Corp."
+Bundle-SymbolicName: #{symName}
+#{requiredPlugins}
+MANIFEST
+        write "#{group}/#{projectName}/.project", <<-DOT_PROJECT
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+        <name>#{File.basename(projectName)}</name>
+        <comment></comment>
+        <projects>
+        </projects>
+        <buildSpec>
+                <buildCommand>
+                        <name>org.eclipse.jdt.core.javabuilder</name>
+                        <arguments>
+                        </arguments>
+                </buildCommand>
+                <buildCommand>
+                        <name>org.eclipse.pde.ManifestBuilder</name>
+                        <arguments>
+                        </arguments>
+                </buildCommand>
+                <buildCommand>
+                        <name>org.eclipse.pde.SchemaBuilder</name>
+                        <arguments>
+                        </arguments>
+                </buildCommand>
+        </buildSpec>
+        <natures>
+                <nature>org.eclipse.pde.PluginNature</nature>
+                <nature>org.eclipse.jdt.core.javanature</nature>
+        </natures>
+</projectDescription>
+DOT_PROJECT
+
+write "#{group}/#{projectName}/.classpath", <<-DOT_CLASSPATH
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+        <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+        <classpathentry kind="src" path="src"/>
+        <classpathentry combineaccessrules="false" kind="src" path="/another.plugin"/>
+        <classpathentry kind="output" path="bin"/>
+</classpath>
+DOT_CLASSPATH
+
+write "#{group}/#{projectName}/plugin.xml", <<-PLUGIN_XML
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+<!--some comment
+-->
+</plugin>
+PLUGIN_XML
+        write "#{group}/#{projectName}/build.properties", <<-BUILD_PROPERTIES
+source.. = src/
+output.. = bin/
+javacDefaultEncoding.. = UTF-8
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml,\
+               rsc/,
+BUILD_PROPERTIES
+  end
+end
+
+describe Buildr::Generate do
+  include EclipseHelper
+  describe 'it should find a single eclipse project' do
+    top = "top_#{__LINE__}"
+    
+    before do
+      setupExample(top, 'single')
+      File.open(File.join(top, 'buildfile'), 'w') { |file| file.write Generate.from_eclipse(File.join(Dir.pwd, top)).join("\n") }
+    end
+    
+    it 'should create a valid buildfile' do
+      define('first')
+      File.exists?(File.join(top, 'single', '.project')).should be_true
+      File.exists?(File.join(top, '.project')).should be_false
+      File.exists?('.project').should be_false
+      buildFile = File.join(top, 'buildfile')
+      file(buildFile).should exist
+      file(buildFile).should contain("GROUP = \"#{top}\"")
+      lambda { Buildr.application.run }.should_not raise_error
+    end
+
+    it "should not add project if the corresponding .project file is not an eclipse project" do
+      buildFile = File.join(top, 'buildfile')
+      FileUtils.rm(buildFile)
+      write File.join(top, 'myproject', '.project'), '# Dummy file'
+      File.open(File.join(top, 'buildfile'), 'w') { |file| file.write Generate.from_eclipse(File.join(Dir.pwd, top)).join("\n") }
+      file(buildFile).should exist
+      file(buildFile).should contain('define "single"')
+      file(buildFile).should_not contain('define "myproject"')
+      lambda { Buildr.application.run }.should_not raise_error
+    end
+
+      it 'should honour Bundle-Version in MANIFEST.MF' do
+	define('bundle_version')
+	buildFile = File.join(top, 'buildfile')
+	file(buildFile).should exist
+	file(buildFile).should contain('define "single"')
+	file(buildFile).should contain('define "single", :version => "1.1"')
+	lambda { Buildr.application.run }.should_not raise_error
+      end
+
+    it "should pass source in build.properties to layout[:source, :main, :java] and layout[:source, :main, :scala]" do
+      define('layout_source')
+      buildFile = File.join(top, 'buildfile')
+      file(buildFile).should exist
+      file(buildFile).should contain('define')
+      file(buildFile).should contain('define "single"')
+      file(buildFile).should contain('layout[:source, :main, :java]')
+      file(buildFile).should contain('layout[:source, :main, :scala]')
+      lambda { Buildr.application.run }.should_not raise_error
+    end
+    
+    it "should pass output in build.properties to layout[:target, :main], etc" do
+      define('layout_target')
+      buildFile = File.join(top, 'buildfile')
+      file(buildFile).should exist
+      file(buildFile).should contain('define')
+      file(buildFile).should contain('define "single"')
+      file(buildFile).should contain('layout[:target, :main]')
+      file(buildFile).should contain('layout[:target, :main, :java]')
+      file(buildFile).should contain('layout[:target, :main, :scala]')
+      lambda { Buildr.application.run }.should_not raise_error
+    end
+    
+    it "should package an eclipse plugin" do
+      define('layout_target')
+      buildFile = File.join(top, 'buildfile')
+      file(buildFile).should exist
+      file(buildFile).should contain('define')
+      file(buildFile).should contain('package(:jar)')
+      lambda { Buildr.application.run }.should_not raise_error
+      pending "I don't know why package(:plugin) cannot be built when run in a real workspace!"
+    end
+
+  end
+
+  describe 'it should check for a SymbolicName in MANIFEST.MF' do
+    top = "top_#{__LINE__}"
+    before do
+      setupExample(top, 'single', { :symName => 'singleSymbolicName'} )
+      File.open(File.join(top, 'buildfile'), 'w') { |file| file.write Generate.from_eclipse(File.join(Dir.pwd, top)).join("\n") }
+    end
+    it "should set the project name to the SymbolicName from the MANIFEST.MF" do
+      buildFile = File.join(top, 'buildfile')
+      file(buildFile).should exist
+      file(buildFile).should contain('define "singleSymbolicName"')
+      lambda { Buildr.application.run }.should_not raise_error
+    end
+  end
+    
+  describe 'it should accecpt singleton SymbolicName in MANIFEST.MF' do
+    top = "top_#{__LINE__}"
+    before do
+      setupExample(top, 'single', { :symName => 'singleSymbolicName;singleton:=true'})
+      File.open(File.join(top, 'buildfile'), 'w') { |file| file.write Generate.from_eclipse(File.join(Dir.pwd, top)).join("\n") }
+    end
+    
+    it "should not get confused if SymbolicName in MANIFEST.MF is a singleton:=true" do
+      buildFile = File.join(top, 'buildfile')
+      file(buildFile).should exist
+      file(buildFile).should contain('define "singleSymbolicName"')
+      lambda { Buildr.application.run }.should_not raise_error
+    end
+  end
+
+  describe 'it should find an eclipse project deep' do
+    top = "top_#{__LINE__}"
+    before do
+      setupExample(top, 'nested/single')
+      File.open(File.join(top, 'buildfile'), 'w') { |file| file.write Generate.from_eclipse(File.join(Dir.pwd, top)).join("\n") }
+    end
+
+    it 'should create a valid buildfile for a nested project' do
+      setupExample(top, 'single')
+      define('nested/second')
+      File.exists?(File.join(top, 'single', '.project')).should be_true
+      File.exists?(File.join(top, '.project')).should be_false
+      File.exists?('.project').should be_false
+      buildFile = File.join(top, 'buildfile')
+      file(buildFile).should contain("GROUP = \"#{top}\"")
+      file(buildFile).should contain('define "single"')
+      lambda { Buildr.application.run }.should_not raise_error
+    end
+    
+    it "should correct the path for a nested plugin" do
+      define('base_dir')
+      buildFile = File.join(top, 'buildfile')
+      file(buildFile).should exist
+      file(buildFile).should contain('define "single"')
+      file(buildFile).should contain('define "single", :version => "1.1", :base_dir => "nested/single"')
+      lambda { Buildr.application.run }.should_not raise_error
+    end
+
+  end
+
+  describe 'it should detect dependencies between projects' do
+    top = "top_#{__LINE__}"
+    before do
+      setupExample(top, 'first')
+      write(File.join(top, 'first', 'src','org','demo','Demo.java'))
+      write(File.join(top, 'first', 'rsc','aResource.txt'))
+      setupExample(top, 'second', { :requires => 'first'} )
+      write(File.join(top, 'second', 'src','org','second','Demo.java'))
+      setupExample(top, 'aFragment', { :fragment_host => 'second'})
+      write(File.join(top, 'aFragment', 'fragment.xml'))
+      File.open(File.join(top, 'buildfile'), 'w') { |file| file.write Generate.from_eclipse(File.join(Dir.pwd, top)).join("\n") }
+    end
+
+    it 'should add "compile.with dependencies" in MANIFEST.MF' do
+      define('base_dir')
+      buildFile = File.join(top, 'buildfile')
+      file(buildFile).should exist
+      file(buildFile).should contain('compile.with dependencies')
+      file(buildFile).should contain('resources')
+      lambda { Buildr.application.run }.should_not raise_error
+    end
+                                                           #dependencies << projects("first")
+
+    it 'should honour Require-Bundle in MANIFEST.MF' do
+      define('base_dir')
+      buildFile = File.join(top, 'buildfile')
+      file(buildFile).should exist
+      file(buildFile).should contain(/define "second"/)
+      file(buildFile).should contain(                     /dependencies << projects\("first"\)/)
+      file(buildFile).should contain(/define "second".*do.*dependencies << projects\("first"\).* end/m)
+      lambda { Buildr.application.run }.should_not raise_error
+    end
+    
+    # Fragments are only supported with buildr4osi which is not (yet?) part of buildr
+    it 'should skip fragments.'  do
+      define('base_dir')
+      buildFile = File.join(top, 'buildfile')
+      file(buildFile).should exist
+#      system("cat #{buildFile}")  # if $VERBOSE
+      file(buildFile).should contain('define "first"')
+      lambda { Buildr.application.run }.should_not raise_error
+    end
+
+  end
+
+  it 'should honour bin.includes in build.properties' do
+    pending "bin.includes must done using package(:jar/:zip).with"
+  end
+
+  it 'should honour bin.excludes in build.properties' do
+    pending "bin.excludes must done using package(:jar/:zip).with"
+  end
+
+  it 'should honour import in plugin.xml' do
+    pending "Is this really relevant or just redundant with information from MANIFEST.MF???"
+  end
+
+  it 'should be able to compile my project' do
+    # When running in subdir/src from git clone git://github.com/zdavatz/elexis
+    pending "Why do I get the error NameError : undefined local variable or method `dependencies' for project(\"src:LogBackend\"):Buildr::Project"
+  end
+
+  it 'should be possible to run junit test fragment' do
+    pending "need fragment and finding the correct test runner"
+  end
+
+  it 'should be possible to run PDE-unit test fragment' do
+    pending "Adapt pde_test.rake from https://bitbucket.org/ngiger/elexis-bootstrap (branch 2.1.7)"
+  end
+
+  it 'should be possible to generate P2-sites and applications' do
+    pending "Adapt p2site.rake from https://bitbucket.org/ngiger/elexis-bootstrap (branch 2.1.7)"
+  end
+
+end
-- 
1.7.10.4

# Generated by Buildr 1.4.7.eclipse, change to your liking
require 'buildr/ide/eclipse'


# Version number for this release
VERSION_NUMBER = "1.0.0"
# Group identifier for your projects
GROUP = "src"
COPYRIGHT = ""

# Specify Maven 2.0 remote repositories here, like this:
repositories.remote << "http://repo1.maven.org/maven2";

desc "The Src project"
define "src" do

  project.version = VERSION_NUMBER
  project.group = GROUP
  manifest["Implementation-Vendor"] = COPYRIGHT
  # you may see hints about which jars are missing and should resolve them 
correctly
  # dependencies  << 'junit should be commented out and replace by correct 
ARTIFACT definition. Eg
  # dependencies  << 'junit:junit:jar:3.8.2'
  layout[:source, :main, :java] = "src"
  layout[:source, :main, :scala] = "src"
  layout[:target, :main] = "bin"
  layout[:target, :main, :java] = "bin"
  layout[:target, :main, :scala] = "bin"
  # I am in /opt/src/elexis/src

  define "LogBackend" do
    # I am in /opt/src/elexis/src/LogBackend
    package(:jar)
    # dependencies  << 'ch.qos.logback.classic'
    # dependencies  << 'ch.qos.logback.core'
    # dependencies  << 'org.slf4j.api'
    compile.with dependencies # Add more classpath dependencies
  end


  define "ch.elexis.artikel_ch", :version => "2.0.5" do
    # I am in /opt/src/elexis/src/ch.elexis.artikel_ch
    package(:jar)
    dependencies << projects("ch.elexis")
    # dependencies  << 'org.eclipse.core.runtime'
    # dependencies  << 'org.eclipse.ui'
    # dependencies  << 'org.eclipse.ui.forms'
    dependencies << projects("ch.elexis.importer.div")
    dependencies << projects("ch.rgw.utility")
    dependencies << projects("ch.elexis.core")
    compile.with dependencies # Add more classpath dependencies
  end


  define "ch.elexis.arzttarife_ch", :version => "2.1.0" do
    # I am in /opt/src/elexis/src/ch.elexis.arzttarife_ch
    package(:jar)
    dependencies << projects("ch.elexis")
    dependencies << projects("ch.elexis.artikel_ch")
    # dependencies  << 'org.eclipse.ui.forms'
    # dependencies  << 'org.eclipse.core.runtime'
    # dependencies  << 'org.eclipse.ui'
    dependencies << projects("ch.elexis.ebanking_ch")
    dependencies << projects("ch.rgw.utility")
    dependencies << projects("ch.elexis.labortarif.ch2009")
    dependencies << projects("ch.elexis.core")
    dependencies << projects("ch.elexis.importer.div")
    compile.with dependencies # Add more classpath dependencies
    resources
  end


  define "ch.elexis.core", :version => "0.0.2" do
    # I am in /opt/src/elexis/src/ch.elexis.core
    package(:jar)
    dependencies << projects("ch.rgw.utility")
    # dependencies  << 'org.eclipse.core.runtime'
    compile.with dependencies # Add more classpath dependencies
  end


  define "ch.elexis.developer.resources", :version => "1.0.2" do
    # I am in /opt/src/elexis/src/ch.elexis.developer.resources
    package(:jar)
    dependencies << projects("ch.elexis")
    dependencies << projects("ch.rgw.utility")
    # dependencies  << 'org.eclipse.ui'
    # dependencies  << 'org.eclipse.core.runtime'
    dependencies << projects("ch.elexis.core")
    compile.with dependencies # Add more classpath dependencies
  end


  define "ch.elexis.diagnosecodes_ch", :version => "2.0.2" do
    # I am in /opt/src/elexis/src/ch.elexis.diagnosecodes_ch
    package(:jar)
    dependencies << projects("ch.elexis")
    # dependencies  << 'org.eclipse.core.runtime'
    # dependencies  << 'org.eclipse.swt'
    # dependencies  << 'org.eclipse.jface'
    # dependencies  << 'org.eclipse.ui.forms'
    # dependencies  << 'org.eclipse.ui'
    dependencies << projects("ch.rgw.utility")
    dependencies << projects("ch.elexis.core")
    compile.with dependencies # Add more classpath dependencies
  end


  define "ch.elexis.ebanking_ch", :version => "2.0.2" do
    # I am in /opt/src/elexis/src/ch.elexis.ebanking_ch
    package(:jar)
    dependencies << projects("ch.elexis")
    # dependencies  << 'org.eclipse.swt'
    # dependencies  << 'org.eclipse.core.runtime'
    # dependencies  << 'org.eclipse.ui'
    # dependencies  << 'org.eclipse.ui.forms'
    dependencies << projects("ch.rgw.utility")
    dependencies << projects("ch.elexis.core")
    compile.with dependencies # Add more classpath dependencies
  end


  define "ch.elexis.eigenartikel", :version => "1.0.7" do
    # I am in /opt/src/elexis/src/ch.elexis.eigenartikel
    package(:jar)
    dependencies << projects("ch.elexis")
    # dependencies  << 'org.eclipse.core.runtime'
    dependencies << projects("ch.rgw.utility")
    # dependencies  << 'org.eclipse.jface'
    # dependencies  << 'org.eclipse.ui'
    # dependencies  << 'org.eclipse.ui.forms'
    dependencies << projects("ch.elexis.core")
    compile.with dependencies # Add more classpath dependencies
  end


  define "ch.elexis.h2.connector", :version => "1.2.1" do
    # I am in /opt/src/elexis/src/ch.elexis.h2.connector
    package(:jar)
  end


  define "ch.elexis.importer.div", :version => "1.5.0" do
    # I am in /opt/src/elexis/src/ch.elexis.importer.div
    package(:jar)
    dependencies << projects("ch.elexis")
    # dependencies  << 'org.eclipse.ui'
    # dependencies  << 'org.eclipse.core.runtime'
    dependencies << projects("ch.rgw.utility")
    # dependencies  << 'org.apache.commons.lang'
    dependencies << projects("ch.elexis.core")
    compile.with dependencies # Add more classpath dependencies
    resources
  end


  define "ch.elexis.importer.div_test" do
    # I am in /opt/src/elexis/src/ch.elexis.importer.div_test
    package(:jar)
    # dependencies  << 'org.junit'
    compile.with dependencies # Add more classpath dependencies
    resources
  end


  define "ch.elexis.labortarif.ch2009", :version => "1.0.5" do
    # I am in /opt/src/elexis/src/ch.elexis.labortarif.ch2009
    package(:jar)
    dependencies << projects("ch.elexis")
    dependencies << projects("ch.rgw.utility")
    dependencies << projects("ch.elexis.importer.div")
    # dependencies  << 'org.eclipse.core.runtime'
    # dependencies  << 'org.eclipse.ui.forms'
    # dependencies  << 'org.eclipse.ui'
    dependencies << projects("ch.elexis.core")
    compile.with dependencies # Add more classpath dependencies
    resources
  end


  define "ch.elexis.mysql.connector", :version => "1.0.1" do
    # I am in /opt/src/elexis/src/ch.elexis.mysql.connector
    package(:jar)
  end


  define "ch.elexis.noatext", :version => "1.4.1" do
    # I am in /opt/src/elexis/src/ch.elexis.noatext
    package(:jar)
    dependencies << projects("ch.elexis")
    # dependencies  << 'org.eclipse.core.runtime'
    # dependencies  << 'org.eclipse.ui'
    # dependencies  << 'org.eclipse.ui.forms'
    dependencies << projects("ch.rgw.utility")
    compile.with dependencies # Add more classpath dependencies
    resources
  end


  define "ch.elexis.noatext_jsl", :version => "1.4.3" do
    # I am in /opt/src/elexis/src/ch.elexis.noatext_jsl
    package(:jar)
    dependencies << projects("ch.elexis")
    # dependencies  << 'org.eclipse.core.runtime'
    # dependencies  << 'org.eclipse.ui'
    # dependencies  << 'org.eclipse.ui.forms'
    dependencies << projects("ch.rgw.utility")
    compile.with dependencies # Add more classpath dependencies
    resources
  end


  define "ch.elexis.postgresql.connector", :version => "1.0.2" do
    # I am in /opt/src/elexis/src/ch.elexis.postgresql.connector
    package(:jar)
  end


  define "ch.elexis.scripting.beanshell", :version => "1.0.1" do
    # I am in /opt/src/elexis/src/ch.elexis.scripting.beanshell
    package(:jar)
    dependencies << projects("ch.elexis")
    # dependencies  << 'org.eclipse.core.runtime'
    dependencies << projects("ch.rgw.utility")
    compile.with dependencies # Add more classpath dependencies
  end


  define "ch.elexis", :version => "2.1.6.dev-qualifier" do
    # I am in /opt/src/elexis/src/ch.elexis
    package(:jar)
    # dependencies  << 'org.eclipse.core.runtime'
    # dependencies  << 'org.eclipse.ui'
    # dependencies  << 'org.eclipse.ui.forms'
    dependencies << projects("ch.rgw.utility")
    dependencies << projects("ch.elexis.core")
    compile.with dependencies # Add more classpath dependencies
    resources
  end


  define "ch.elexis_test", :version => "1.0.1" do
    # I am in /opt/src/elexis/src/ch.elexis_test
    package(:jar)
    # dependencies  << 'org.junit'
    compile.with dependencies # Add more classpath dependencies
    resources
  end


  define "ch.medelexis.text.templator", :version => "1.1" do
    # I am in /opt/src/elexis/src/ch.medelexis.text.templator
    package(:jar)
    dependencies << projects("ch.elexis")
    dependencies << projects("ch.rgw.utility")
    # dependencies  << 'org.eclipse.core.runtime'
    # dependencies  << 'org.eclipse.ui'
    # dependencies  << 'org.eclipse.ui.forms'
    compile.with dependencies # Add more classpath dependencies
  end


  define "ch.ngiger.elexis.branding", :version => "1.0.0.qualifier" do
    # I am in /opt/src/elexis/src/ch.ngiger.elexis.branding
    package(:jar)
    # dependencies  << 'org.eclipse.ui'
    # dependencies  << 'org.eclipse.core.runtime'
    # dependencies  << 'org.eclipse.swt'
    # dependencies  << 'org.eclipse.ui.workbench'
    compile.with dependencies # Add more classpath dependencies
  end


  define "ch.ngiger.elexis.oddb_ch", :version => "1.0.0.qualifier" do
    # I am in /opt/src/elexis/src/ch.ngiger.elexis.oddb_ch
    package(:jar)
    dependencies << projects("ch.elexis")
    # dependencies  << 'org.eclipse.core.runtime'
    # dependencies  << 'org.eclipse.ui'
    # dependencies  << 'org.eclipse.ui.forms'
    dependencies << projects("ch.elexis.importer.div")
    dependencies << projects("ch.rgw.utility")
    dependencies << projects("ch.elexis.core")
    compile.with dependencies # Add more classpath dependencies
  end


  define "ch.ngiger.elexis.oddb_ch_test", :version => "1.0.0.qualifier" do
    # I am in /opt/src/elexis/src/ch.ngiger.elexis.oddb_ch_test
    package(:jar)
    # dependencies  << 'org.junit'
    # dependencies  << 'org.eclipse.jdt.core'
    compile.with dependencies # Add more classpath dependencies
    resources
  end


  define "ch.ngiger.elexis.opensource" do
    # I am in /opt/src/elexis/src/ch.ngiger.elexis.opensource
    resources
  end


  define "ch.rgw.utility", :version => "2.0.8" do
    # I am in /opt/src/elexis/src/ch.rgw.utility
    package(:jar)
    dependencies << projects("ch.elexis.postgresql.connector")
    dependencies << projects("ch.elexis.mysql.connector")
    dependencies << projects("ch.elexis.h2.connector")
    # dependencies  << 'org.slf4j.api'
    # dependencies  << 'ch.qos.logback.classic'
    # dependencies  << 'ch.qos.logback.core'
    compile.with dependencies # Add more classpath dependencies
  end


  define "ch.rgw.utility_test", :version => "1.0.1" do
    # I am in /opt/src/elexis/src/ch.rgw.utility_test
    package(:jar)
    # dependencies  << 'org.junit'
    compile.with dependencies # Add more classpath dependencies
  end


  define "de.fhdo.elexis.perspective" do
    # I am in /opt/src/elexis/src/de.fhdo.elexis.perspective
    package(:jar)
    # dependencies  << 'org.eclipse.ui'
    # dependencies  << 'org.eclipse.core.runtime'
    compile.with dependencies # Add more classpath dependencies
  end


  define "org.ekkescorner.logging.osgi", :version => "0.9.40.qualifier" do
    # I am in /opt/src/elexis/src/org.ekkescorner.logging.osgi
    package(:jar)
    # dependencies  << 'org.eclipse.osgi'
    # dependencies  << 'ch.qos.logback.classic'
    # dependencies  << 'ch.qos.logback.core'
    # dependencies  << 'org.slf4j.jul'
    compile.with dependencies # Add more classpath dependencies
  end


  define "org.iatrix.help.wiki", :version => "1.4.1" do
    # I am in /opt/src/elexis/src/org.iatrix.help.wiki
    package(:jar)
    # dependencies  << 'org.eclipse.ui'
    # dependencies  << 'org.eclipse.core.runtime'
    dependencies << projects("ch.elexis")
    dependencies << projects("ch.rgw.utility")
    compile.with dependencies # Add more classpath dependencies
  end


  define "pde.test.utils", :version => "3.5.0" do
    # I am in /opt/src/elexis/src/pde.test.utils
    package(:jar)
    # dependencies  << 'org.apache.ant'
    # dependencies  << 'org.junit'
    # dependencies  << 'org.eclipse.jdt.junit.runtime'
    compile.with dependencies # Add more classpath dependencies
  end


end

Reply via email to