Author: assaf
Date: Thu Feb  7 11:58:53 2008
New Revision: 619609

URL: http://svn.apache.org/viewvc?rev=619609&view=rev
Log:
BUILDR-43

Modified:
    incubator/buildr/trunk/Rakefile
    incubator/buildr/trunk/doc/pages/settings_profiles.textile
    incubator/buildr/trunk/lib/buildr.rb
    incubator/buildr/trunk/lib/core/application.rb
    incubator/buildr/trunk/lib/core/generate.rb
    incubator/buildr/trunk/lib/java/artifact.rb
    incubator/buildr/trunk/spec/java_packaging_spec.rb
    incubator/buildr/trunk/spec/java_test_frameworks_spec.rb
    incubator/buildr/trunk/spec/project_spec.rb

Modified: incubator/buildr/trunk/Rakefile
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/Rakefile?rev=619609&r1=619608&r2=619609&view=diff
==============================================================================
--- incubator/buildr/trunk/Rakefile (original)
+++ incubator/buildr/trunk/Rakefile Thu Feb  7 11:58:53 2008
@@ -126,6 +126,7 @@
     rdoc.options  = ruby_spec.rdoc_options
     rdoc.rdoc_files.include('lib/**/*.rb')
     rdoc.rdoc_files.include ruby_spec.extra_rdoc_files
+    rdoc.template = File.join(Gem.default_path, 
'gems/allison-2.0.3/lib/allison.rb')
   end
 
   web_docs = {
@@ -145,11 +146,11 @@
   print = Docter::Rake.generate('print', print_docs[:collection], 
print_docs[:template], :one_page)
   pdf_file = file('html/buildr.pdf'=>print) do |task|
     mkpath 'html'
-    sh *%W{prince #{print}/index.html 
--baseurl=http://incubator.apache.org/buildr/ -o #{task.name}} do |ok, res|
+    sh *%W{prince #{print}/index.html 
--baseurl=http://incubator.apache.org/buildr/ -o #{task.name} --media=print} do 
|ok, res|
       fail 'Failed to create PDF, see errors above' unless ok
     end
   end
-  task('pdf'=>pdf_file) { |task| `kpdf #{File.expand_path(pdf_file.to_s)}` }
+  task('pdf'=>pdf_file) { |task| `open #{File.expand_path(pdf_file.to_s)}` }
 
   desc 'Generate HTML documentation'
   html = Docter::Rake.generate('html', web_docs[:collection], 
web_docs[:template])

Modified: incubator/buildr/trunk/doc/pages/settings_profiles.textile
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/doc/pages/settings_profiles.textile?rev=619609&r1=619608&r2=619609&view=diff
==============================================================================
--- incubator/buildr/trunk/doc/pages/settings_profiles.textile (original)
+++ incubator/buildr/trunk/doc/pages/settings_profiles.textile Thu Feb  7 
11:58:53 2008
@@ -45,11 +45,14 @@
 | @DEBUG@       | Set to @no/off@ if you want Buildr to compile without
 debugging information (default when running the @release@ task, see
 "Compiling":building.html#compiling). |
+| @HOME@        | Your home directory. |
 | @HTTP_PROXY@  | URL for HTTP proxy server (see "Specifying
 Repositories":artifacts.html#specifying_repositories). |
 | @JAVA_HOME@   | Points to your JDK, required when using Java and Ant. |
 | @JAVA_OPTS@   | Command line options to pass to the JDK[2] (e.g.
 @'-Xms1g'@). |
+| @M2_REPO@     | Location of the Maven2 local repository.  Defaults to the
[EMAIL PROTECTED]@ directory in your home directory (@ENV['HOME']@). |
 | @NO_PROXY@    | Comma separated list of hosts and domain that should not be
 proxied (see "Specifying 
Repositories":artifacts.html#specifying_repositories).  |
 | @TEST@        | Set to @no/off@ to tell Buildr to skip tests, or @all@ to

Modified: incubator/buildr/trunk/lib/buildr.rb
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr.rb?rev=619609&r1=619608&r2=619609&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr.rb (original)
+++ incubator/buildr/trunk/lib/buildr.rb Thu Feb  7 11:58:53 2008
@@ -14,9 +14,7 @@
 require 'facets/openobject'
 require 'facets/kernel/tap'
 require 'facets/enumerable/uniq_by'
-
-# A different kind of buildr, one we use to create XML.
-require 'builder'
+require 'builder' # A different kind of buildr, one we use to create XML.
 
 
 module Buildr

Modified: incubator/buildr/trunk/lib/core/application.rb
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/core/application.rb?rev=619609&r1=619608&r2=619609&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/core/application.rb (original)
+++ incubator/buildr/trunk/lib/core/application.rb Thu Feb  7 11:58:53 2008
@@ -3,6 +3,9 @@
 
 module Buildr
 
+  # Gem::user_home is nice, but ENV['HOME'] lets you override from the 
environment.
+  ENV["HOME"] ||= File.expand_path(Gem::user_home)
+
   # When running from +rake+, we already have an Application setup and must 
plug into it,
   # since the top-level tasks come from there. When running from +buildr+, we 
get to load
   # Rake and set everything up, and we use our own Application full of cool 
Buildr features.
@@ -160,8 +163,8 @@
     def load_tasks_and_local_files() #:nodoc:
       return false if @build_files
       # Load the settings files.
-      @build_files = [ File.expand_path('buildr.rb', Gem::user_home), 
'buildr.rb' ].select { |file| File.exist?(file) }
-      @build_files += [ File.expand_path('buildr.rake', Gem::user_home), 
File.expand_path('buildr.rake') ].
+      @build_files = [ File.expand_path('buildr.rb', ENV['HOME']), 'buildr.rb' 
].select { |file| File.exist?(file) }
+      @build_files += [ File.expand_path('buildr.rake', ENV['HOME']), 
File.expand_path('buildr.rake') ].
         select { |file| File.exist?(file) }.each { |file| warn "Please use 
'#{file.ext('rb')}' instead of '#{file}'" }
       #Load local tasks that can be used in the Buildfile.
       @build_files += Dir["#{Dir.pwd}/tasks/*.rake"]

Modified: incubator/buildr/trunk/lib/core/generate.rb
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/core/generate.rb?rev=619609&r1=619608&r2=619609&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/core/generate.rb (original)
+++ incubator/buildr/trunk/lib/core/generate.rb Thu Feb  7 11:58:53 2008
@@ -85,7 +85,7 @@
         if root
           script = HEADER.split("\n")
 
-          settings_file = ENV["M2_SETTINGS"] || File.join(Gem::user_home, 
".m2/settings.xml")
+          settings_file = ENV["M2_SETTINGS"] || File.join(ENV['HOME'], 
".m2/settings.xml")
           settings = XmlSimple.xml_in(IO.read(settings_file)) if 
File.exists?(settings_file)
 
           if settings

Modified: incubator/buildr/trunk/lib/java/artifact.rb
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/java/artifact.rb?rev=619609&r1=619608&r2=619609&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/java/artifact.rb (original)
+++ incubator/buildr/trunk/lib/java/artifact.rb Thu Feb  7 11:58:53 2008
@@ -381,7 +381,7 @@
     #
     # The default path is .m2/repository relative to the home directory.
     def local()
-      @local ||= ENV["local_repo"] || File.join(Gem::user_home, 
".m2/repository")
+      @local ||= ENV['M2_REPO'] || ENV["local_repo"] || File.join(ENV['HOME'], 
".m2/repository")
     end
 
     # :call-seq:

Modified: incubator/buildr/trunk/spec/java_packaging_spec.rb
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/java_packaging_spec.rb?rev=619609&r1=619608&r2=619609&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/java_packaging_spec.rb (original)
+++ incubator/buildr/trunk/spec/java_packaging_spec.rb Thu Feb  7 11:58:53 2008
@@ -2,6 +2,9 @@
 require File.join(File.dirname(__FILE__), 'packaging_helper')
 
 
+MANIFEST_LINE_SEP = /\r\n|\n|\r[^\n]/
+MANIFEST_SECTION_SEP = /(#{MANIFEST_LINE_SEP}){2}/
+
 describe Project, '#manifest' do
   it 'should include user name' do
     ENV['USER'] = 'MysteriousJoe'
@@ -52,17 +55,18 @@
     package = project('foo').package(@packaging)
     package.invoke
     Zip::ZipFile.open(package.to_s) do |zip|
-      sections = zip.file.read('META-INF/MANIFEST.MF').split("\n\n").map do 
|section|
-          section.split("\n").each { |line| line.length.should < 72 }.
-            inject([]) { |merged, line|
-              if line[0] == 32
-                merged.last << line[1..-1]
-              else
-                merged << line
-              end
-              merged
-            }.map { |line| line.split(/: /) }.
-            inject({}) { |map, (name, value)| map.merge(name=>value) }
+      sections = 
zip.file.read('META-INF/MANIFEST.MF').split(MANIFEST_SECTION_SEP).
+        reject { |s| s.chomp == "" }.map do |section|
+        section.split(MANIFEST_LINE_SEP).each { |line| line.length.should < 72 
}.
+          inject([]) { |merged, line|
+            if line[0] == 32
+              merged.last << line[1..-1]
+            else
+              merged << line
+            end
+            merged
+          }.map { |line| line.split(/: /) }.
+          inject({}) { |map, (name, value)| map.merge(name=>value) }
         end
       yield sections
     end
@@ -107,7 +111,7 @@
     package_with_manifest 'Foo'=>1, :bar=>'Bar'
     package = project('foo').package(@packaging)
     package.invoke
-    Zip::ZipFile.open(package.to_s) { |zip| 
zip.file.read('META-INF/MANIFEST.MF')[-1].should == ?\n }
+    Zip::ZipFile.open(package.to_s) { |zip| 
zip.file.read('META-INF/MANIFEST.MF').should =~ /#{MANIFEST_LINE_SEP}$/ }
   end
 
   it 'should break hash manifest lines longer than 72 characters using 
continuations' do
@@ -147,9 +151,8 @@
     package_with_manifest [ {}, { 'Name'=>'first', :Foo=>'first', 
:bar=>'second' } ]
     package = project('foo').package(@packaging)
     package.invoke
-    Zip::ZipFile.open(package.to_s) do |zip|
-      sections = zip.file.read('META-INF/MANIFEST.MF').split(/\n\n/)
-      sections[1].split("\n").first.should =~ /^Name: first/
+    inspect_manifest do |sections|
+      sections[1]["Name"].should == "first"
     end
   end
 
@@ -560,12 +563,13 @@
   def inspect_classpath(package)
     project('foo').package(:ear).invoke
     Zip::ZipFile.open(project('foo').package(:ear).to_s) do |ear|
-      File.open('tmp.zip', 'w') do |tmp|
+      File.open('tmp.zip', 'wb') do |tmp|
         tmp.write ear.file.read(package)
       end
       Zip::ZipFile.open('tmp.zip') do |zip|
-        first_section = 
zip.file.read('META-INF/MANIFEST.MF').split("\n\n").first.
-          split("\n").each { |line| line.length.should < 72 }.
+        first_section = 
zip.file.read('META-INF/MANIFEST.MF').split(MANIFEST_SECTION_SEP).
+          reject { |s| s.chomp == "" }.first.
+          split(MANIFEST_LINE_SEP).each { |line| line.length.should < 72 }.
           inject([]) { |merged, line|
             if line[0] == 32
               merged.last << line[1..-1]

Modified: incubator/buildr/trunk/spec/java_test_frameworks_spec.rb
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/java_test_frameworks_spec.rb?rev=619609&r1=619608&r2=619609&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/java_test_frameworks_spec.rb (original)
+++ incubator/buildr/trunk/spec/java_test_frameworks_spec.rb Thu Feb  7 
11:58:53 2008
@@ -129,10 +129,12 @@
 
   it 'should set current directory' do
     mkpath 'baz'
+    expected = File.expand_path('baz')
+    expected.gsub!('/', '\\') if expected =~ /^[A-Z]:/ # Java returns back 
slashed paths for windows
     write 'baz/src/test/java/CurrentDirectoryTest.java', <<-JAVA
       public class CurrentDirectoryTest extends junit.framework.TestCase {
         public void testCurrentDirectory() throws Exception {
-          assertEquals("#{File.expand_path('baz')}", new 
java.io.File(".").getCanonicalPath());
+          assertEquals(#{expected.inspect}, new 
java.io.File(".").getCanonicalPath());
         }
       }
     JAVA

Modified: incubator/buildr/trunk/spec/project_spec.rb
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/project_spec.rb?rev=619609&r1=619608&r2=619609&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/project_spec.rb (original)
+++ incubator/buildr/trunk/spec/project_spec.rb Thu Feb  7 11:58:53 2008
@@ -246,7 +246,7 @@
 
 describe Project, '#path_to' do
   it 'should return absolute paths as is' do
-    define('foo').path_to('/tmp').should eql('/tmp')
+    define('foo').path_to('/tmp').should eql(File.expand_path('/tmp'))
   end
 
   it 'should resolve empty path to project\'s base directory' do
@@ -637,7 +637,7 @@
 
   it 'should create file task with absolute path' do
     define('foo') { file('/tmp') }
-    Rake.application.lookup('/tmp').should_not be_nil
+    Rake.application.lookup(File.expand_path('/tmp')).should_not be_nil
   end
 
   it 'should create file task relative to project base directory' do


Reply via email to