buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From boisv...@apache.org
Subject svn commit: r998463 - in /buildr/trunk: CHANGELOG lib/buildr/ide/eclipse.rb spec/ide/eclipse_spec.rb
Date Sat, 18 Sep 2010 13:01:08 GMT
Author: boisvert
Date: Sat Sep 18 13:01:08 2010
New Revision: 998463

URL: http://svn.apache.org/viewvc?rev=998463&view=rev
Log:
BUILDR-465 Eclipse project names should be customizable
BUILDR-509 Option to generate non-prefixed Eclipse project names


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

Modified: buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=998463&r1=998462&r2=998463&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Sat Sep 18 13:01:08 2010
@@ -2,6 +2,8 @@
 * Added:  BUILDR-415 Ability to exclude tests from command line
 * Added:  BUILDR-495 Document twitter on Buildr's homepage
 * Added:  BUILDR-212 Update support for SNAPSHOT artifacts (Timo Rantalaiho and Izzet Mustafa)
+* Added:  BUILDR-465 Eclipse project names should be customizable
+* Added:  BUILDR-509 Option to generate non-prefixed Eclipse project names
 * Added:  Integration test to show how to change the war packaging spec.
 * Added:  Integration test to show how to use junit 3.
 * Added:  Integration test to show how to get ahold of parent project

Modified: buildr/trunk/lib/buildr/ide/eclipse.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/ide/eclipse.rb?rev=998463&r1=998462&r2=998463&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/ide/eclipse.rb (original)
+++ buildr/trunk/lib/buildr/ide/eclipse.rb Sat Sep 18 13:01:08 2010
@@ -25,11 +25,18 @@ module Buildr
     class Eclipse
 
       attr_reader :options
+      attr_writer :name
 
       def initialize(project)
         @project = project
         @options = Options.new(project)
       end
+      
+      def name
+        return @name if @name
+        return @project.id.split('-').last if @options.short_names
+        @project.id
+      end
 
       # :call-seq:
       #   classpath_variables :VAR => '/path/to/location'
@@ -156,7 +163,7 @@ module Buildr
 
     class Options
 
-      attr_writer :m2_repo_var
+      attr_writer :m2_repo_var, :short_names
 
       def initialize(project)
         @project = project
@@ -173,6 +180,10 @@ module Buildr
           @m2_repo_var || (@project.parent ? @project.parent.eclipse.options.m2_repo_var
: 'M2_REPO')
         end
       end
+      
+      def short_names
+        @short_names || (@project.parent ? @project.parent.eclipse.options.short_names :
false)
+      end
     end
 
     def eclipse
@@ -265,7 +276,7 @@ module Buildr
             File.open(task.name, 'w') do |file|
               xml = Builder::XmlMarkup.new(:target=>file, :indent=>2)
               xml.projectDescription do
-                xml.name project.id
+                xml.name project.eclipse.name
                 xml.projects
                 unless project.eclipse.builders.empty?
                   xml.buildSpec do
@@ -330,8 +341,8 @@ module Buildr
       # Write a classpathentry of kind 'src' for dependent projects.
       # Accept an array of projects.
       def src_projects project_libs
-        project_libs.map(&:id).sort.uniq.each do |project_id|
-          @xml.classpathentry :kind=>'src', :combineaccessrules=>'false', :path=>"/#{project_id}"
+        project_libs.map { |project| project.eclipse.name }.sort.uniq.each do |eclipse_name|
+          @xml.classpathentry :kind=>'src', :combineaccessrules=>'false', :path=>"/#{eclipse_name}"
         end
       end
 

Modified: buildr/trunk/spec/ide/eclipse_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/ide/eclipse_spec.rb?rev=998463&r1=998462&r2=998463&view=diff
==============================================================================
--- buildr/trunk/spec/ide/eclipse_spec.rb (original)
+++ buildr/trunk/spec/ide/eclipse_spec.rb Sat Sep 18 13:01:08 2010
@@ -110,6 +110,15 @@ describe Buildr::Eclipse do
         end
       end
 
+      it 'should use eclipse project name if specified' do
+        define('foo') { eclipse.name = 'bar' }
+        task('eclipse').invoke
+        File.open('.project') do |f|
+          REXML::Document.new(f).root.
+            elements.collect("name") { |e| e.text }.should == ['bar']
+        end
+      end
+
       it 'should not generate a .classpath file' do
         define('foo')
         task('eclipse').invoke
@@ -165,6 +174,32 @@ describe Buildr::Eclipse do
         end
       end
 
+      it 'should use eclipse name for child project if set' do
+        mkdir 'foo'
+        define('myproject') {
+          project.version = '1.0'
+          define('foo') { eclipse.name = 'bar'; compile.using(:javac); package :jar }
+        }
+        task('eclipse').invoke
+        File.open(File.join('foo', '.project')) do |f|
+          REXML::Document.new(f).root.
+            elements.collect("name") { |e| e.text }.should == ['bar']
+        end
+      end
+
+      it 'should use short name for child project if eclipse.options.short_names = true'
do
+        mkdir 'foo'
+        define('myproject') {
+          project.version = '1.0'
+          eclipse.options.short_names = true
+          define('foo') { compile.using(:javac); package :jar }
+        }
+        task('eclipse').invoke
+        File.open(File.join('foo', '.project')) do |f|
+          REXML::Document.new(f).root.
+            elements.collect("name") { |e| e.text }.should == ['foo']
+        end
+      end
     end
 
     describe 'scala project' do
@@ -465,6 +500,21 @@ MANIFEST
             elements.collect("classpathentry[@kind='src']") { |n| n.attributes['path'] }.should
include('/myproject-foo')
         end
       end
+
+      it 'should use eclipse name in its classpath if set' do
+        mkdir 'foo'
+        mkdir 'bar'
+        define('myproject') {
+          project.version = '1.0'
+          define('foo') { eclipse.name = 'eclipsefoo'; package :jar }
+          define('bar') { eclipse.name = 'eclipsebar'; compile.using(:javac).with project('foo');
}
+        }
+        task('eclipse').invoke
+        File.open(File.join('bar', '.classpath')) do |f|
+          REXML::Document.new(f).root.
+            elements.collect("classpathentry[@kind='src']") { |n| n.attributes['path'] }.should
include('/eclipsefoo')
+        end
+      end
     end
   end
 



Mime
View raw message