buildr 1.3.3-java → 1.3.4-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. data/CHANGELOG +76 -0
  2. data/NOTICE +1 -1
  3. data/README.rdoc +9 -21
  4. data/Rakefile +17 -34
  5. data/_buildr +3 -12
  6. data/{doc/print.toc.yaml → _jbuildr} +14 -14
  7. data/addon/buildr/cobertura.rb +5 -219
  8. data/addon/buildr/drb.rb +281 -0
  9. data/addon/buildr/emma.rb +5 -221
  10. data/addon/buildr/nailgun.rb +93 -689
  11. data/bin/buildr +0 -9
  12. data/buildr.buildfile +4 -4
  13. data/buildr.gemspec +27 -21
  14. data/doc/_layouts/default.html +82 -0
  15. data/doc/_layouts/preface.html +22 -0
  16. data/doc/{pages/artifacts.textile → artifacts.textile} +82 -42
  17. data/doc/{pages/building.textile → building.textile} +89 -47
  18. data/doc/{pages/contributing.textile → contributing.textile} +53 -45
  19. data/doc/css/default.css +6 -5
  20. data/doc/css/print.css +17 -24
  21. data/doc/css/syntax.css +7 -36
  22. data/doc/download.textile +68 -0
  23. data/doc/{pages/extending.textile → extending.textile} +45 -24
  24. data/doc/{pages/getting_started.textile → getting_started.textile} +158 -88
  25. data/doc/images/asf-logo.gif +0 -0
  26. data/doc/images/note.png +0 -0
  27. data/doc/index.textile +47 -0
  28. data/doc/{pages/languages.textile → languages.textile} +108 -54
  29. data/doc/mailing_lists.textile +25 -0
  30. data/doc/{pages/more_stuff.textile → more_stuff.textile} +152 -73
  31. data/doc/{pages/packaging.textile → packaging.textile} +181 -96
  32. data/doc/preface.textile +28 -0
  33. data/doc/{pages/projects.textile → projects.textile} +55 -40
  34. data/doc/scripts/buildr-git.rb +364 -264
  35. data/doc/scripts/gitflow.rb +296 -0
  36. data/doc/scripts/install-jruby.sh +2 -2
  37. data/doc/scripts/install-linux.sh +6 -6
  38. data/doc/scripts/install-osx.sh +2 -2
  39. data/doc/{pages/settings_profiles.textile → settings_profiles.textile} +83 -45
  40. data/doc/{pages/testing.textile → testing.textile} +77 -41
  41. data/lib/buildr.rb +5 -5
  42. data/lib/buildr/core.rb +2 -0
  43. data/lib/buildr/core/application.rb +321 -151
  44. data/lib/buildr/core/build.rb +298 -167
  45. data/lib/buildr/core/checks.rb +4 -132
  46. data/lib/buildr/core/common.rb +1 -5
  47. data/lib/buildr/core/compile.rb +3 -9
  48. data/lib/buildr/core/environment.rb +12 -3
  49. data/lib/buildr/core/filter.rb +20 -18
  50. data/lib/buildr/core/generate.rb +36 -36
  51. data/lib/buildr/core/help.rb +2 -1
  52. data/lib/buildr/core/osx.rb +46 -0
  53. data/lib/buildr/core/progressbar.rb +1 -1
  54. data/lib/buildr/core/project.rb +7 -34
  55. data/lib/buildr/core/test.rb +12 -6
  56. data/lib/buildr/core/transports.rb +13 -11
  57. data/lib/buildr/core/util.rb +14 -23
  58. data/lib/buildr/groovy/bdd.rb +3 -2
  59. data/lib/buildr/groovy/compiler.rb +1 -1
  60. data/lib/buildr/ide/eclipse.rb +31 -21
  61. data/lib/buildr/ide/idea.rb +3 -2
  62. data/lib/buildr/ide/idea7x.rb +6 -4
  63. data/lib/buildr/java/ant.rb +3 -1
  64. data/lib/buildr/java/bdd.rb +9 -7
  65. data/lib/buildr/java/cobertura.rb +243 -0
  66. data/lib/buildr/java/compiler.rb +5 -4
  67. data/lib/buildr/java/emma.rb +244 -0
  68. data/lib/buildr/java/packaging.rb +11 -8
  69. data/lib/buildr/java/pom.rb +0 -4
  70. data/lib/buildr/java/rjb.rb +1 -1
  71. data/lib/buildr/java/test_result.rb +5 -7
  72. data/lib/buildr/java/tests.rb +17 -11
  73. data/lib/buildr/packaging.rb +5 -2
  74. data/lib/buildr/packaging/archive.rb +488 -0
  75. data/lib/buildr/packaging/artifact.rb +48 -29
  76. data/lib/buildr/packaging/artifact_namespace.rb +6 -6
  77. data/lib/buildr/packaging/gems.rb +4 -4
  78. data/lib/buildr/packaging/package.rb +3 -2
  79. data/lib/buildr/packaging/tar.rb +85 -3
  80. data/lib/buildr/packaging/version_requirement.rb +172 -0
  81. data/lib/buildr/packaging/zip.rb +24 -682
  82. data/lib/buildr/packaging/ziptask.rb +313 -0
  83. data/lib/buildr/scala.rb +5 -0
  84. data/lib/buildr/scala/bdd.rb +100 -0
  85. data/lib/buildr/scala/compiler.rb +45 -4
  86. data/lib/buildr/scala/tests.rb +12 -59
  87. data/rakelib/checks.rake +57 -0
  88. data/rakelib/doc.rake +58 -68
  89. data/rakelib/jekylltask.rb +110 -0
  90. data/rakelib/package.rake +35 -37
  91. data/rakelib/release.rake +119 -35
  92. data/rakelib/rspec.rake +29 -39
  93. data/rakelib/setup.rake +21 -59
  94. data/rakelib/stage.rake +184 -26
  95. data/spec/addon/drb_spec.rb +328 -0
  96. data/spec/core/application_spec.rb +32 -25
  97. data/spec/core/build_spec.rb +336 -126
  98. data/spec/core/checks_spec.rb +292 -310
  99. data/spec/core/common_spec.rb +8 -2
  100. data/spec/core/compile_spec.rb +17 -1
  101. data/spec/core/generate_spec.rb +3 -3
  102. data/spec/core/project_spec.rb +18 -10
  103. data/spec/core/test_spec.rb +8 -1
  104. data/spec/core/transport_spec.rb +40 -3
  105. data/spec/core/util_spec.rb +67 -0
  106. data/spec/ide/eclipse_spec.rb +96 -28
  107. data/spec/ide/idea7x_spec.rb +84 -0
  108. data/spec/java/ant.rb +5 -0
  109. data/spec/java/bdd_spec.rb +12 -3
  110. data/spec/{addon → java}/cobertura_spec.rb +6 -6
  111. data/spec/{addon → java}/emma_spec.rb +5 -6
  112. data/spec/java/java_spec.rb +12 -2
  113. data/spec/java/packaging_spec.rb +31 -2
  114. data/spec/{addon → java}/test_coverage_spec.rb +3 -3
  115. data/spec/java/tests_spec.rb +5 -0
  116. data/spec/packaging/archive_spec.rb +11 -1
  117. data/spec/{core → packaging}/artifact_namespace_spec.rb +10 -2
  118. data/spec/packaging/artifact_spec.rb +44 -3
  119. data/spec/packaging/packaging_spec.rb +1 -1
  120. data/spec/sandbox.rb +17 -14
  121. data/spec/scala/bdd_spec.rb +150 -0
  122. data/spec/scala/compiler_spec.rb +27 -0
  123. data/spec/scala/scala.rb +38 -0
  124. data/spec/scala/tests_spec.rb +78 -33
  125. data/spec/spec_helpers.rb +29 -5
  126. data/spec/version_requirement_spec.rb +6 -0
  127. metadata +176 -172
  128. data/DISCLAIMER +0 -7
  129. data/doc/images/apache-incubator-logo.png +0 -0
  130. data/doc/pages/download.textile +0 -51
  131. data/doc/pages/index.textile +0 -42
  132. data/doc/pages/mailing_lists.textile +0 -17
  133. data/doc/pages/recipes.textile +0 -103
  134. data/doc/pages/troubleshooting.textile +0 -103
  135. data/doc/pages/whats_new.textile +0 -323
  136. data/doc/print.haml +0 -51
  137. data/doc/site.haml +0 -56
  138. data/doc/site.toc.yaml +0 -47
  139. data/etc/git-svn-authors +0 -16
  140. data/lib/buildr/core/application_cli.rb +0 -139
  141. data/rakelib/apache.rake +0 -191
  142. data/rakelib/changelog.rake +0 -57
  143. data/rakelib/rubyforge.rake +0 -53
  144. data/rakelib/scm.rake +0 -49
@@ -21,33 +21,9 @@ require 'buildr/java/tests'
21
21
 
22
22
 
23
23
  module Buildr::Scala
24
-
25
- # Scala::Specs is available when using Scala::Test
26
- module ScalaSpecs
27
- VERSION = '1.2.9'
28
-
29
- class << self
30
- def version
31
- Buildr.settings.build['scala.specs'] || VERSION
32
- end
33
-
34
- def dependencies
35
- ["org.specs:specs:jar:#{version}"]
36
- end
37
-
38
- private
39
- def const_missing(const)
40
- return super unless const == :REQUIRES # TODO: remove in 1.5
41
- Buildr.application.deprecated "Please use Scala::Specs.dependencies/.version instead of ScalaSpecs::REQUIRES/VERSION"
42
- dependencies
43
- end
44
- end
45
- end
46
-
47
-
48
- # Scala::Check is available when using Scala::Test
49
- module ScalaCheck
50
- VERSION = '1.3'
24
+ # Scala::Check is available when using Scala::Test or Scala::Specs
25
+ module Check
26
+ VERSION = '1.5'
51
27
 
52
28
  class << self
53
29
  def version
@@ -74,9 +50,9 @@ module Buildr::Scala
74
50
  # * :properties -- Hash of system properties available to the test case.
75
51
  # * :environment -- Hash of environment variables available to the test case.
76
52
  # * :java_args -- Arguments passed as is to the JVM.
77
- class ScalaTest < TestFramework::Java
53
+ class ScalaTest < Buildr::TestFramework::Java
78
54
 
79
- VERSION = '0.9.3'
55
+ VERSION = '0.9.5'
80
56
 
81
57
  class << self
82
58
  def version
@@ -84,12 +60,12 @@ module Buildr::Scala
84
60
  end
85
61
 
86
62
  def dependencies
87
- ["org.scalatest:scalatest:jar:#{version}"] + ScalaSpecs.dependencies +
88
- ScalaCheck.dependencies + JMock.dependencies
63
+ ["org.scala-tools.testing:scalatest:jar:#{version}"] + Check.dependencies +
64
+ JMock.dependencies + JUnit.dependencies
89
65
  end
90
66
 
91
67
  def applies_to?(project) #:nodoc:
92
- project.test.compile.language == :scala
68
+ !Dir[project.path_to(:source, :test, :scala, '**/*.scala')].empty?
93
69
  end
94
70
 
95
71
  private
@@ -113,35 +89,13 @@ module Buildr::Scala
113
89
  end
114
90
 
115
91
  def tests(dependencies) #:nodoc:
116
- suites = filter_classes(dependencies, :interfaces => %w{org.scalatest.Suite})
117
- # we should really filter using :class => %w{org.specs.Specification} instead of naming convention
118
- specs = filter_classes(dependencies, :class_names => [/Specs?$/])
119
- [suites, specs].flatten
92
+ filter_classes(dependencies, :interfaces => %w{org.scalatest.Suite})
120
93
  end
121
94
 
122
- def run(tests, dependencies) #:nodoc:
95
+ def run(scalatest, dependencies) #:nodoc:
123
96
  mkpath task.report_to.to_s
124
97
  success = []
125
- scalatest = tests.select { |t| t !~ /Specs?$/ }
126
- specs = tests.select { |t| t =~ /Specs?$/ }
127
-
128
- # Specs
129
- nostacktrace = (options[:nostacktrace]) ? "-ns" : ""
130
- cmd_options = { :properties => options[:properties],
131
- :java_args => options[:java_args],
132
- :classpath => dependencies}
133
- specs.each do |spec|
134
- Java.load
135
- begin
136
- Java::Commands.java(spec, cmd_options)
137
- rescue => e
138
- print e.message
139
- else
140
- success << spec
141
- end
142
- end
143
98
 
144
- # ScalaTest
145
99
  reporter_options = 'TFGBSAR' # testSucceeded, testFailed, testIgnored, suiteAborted, runStopped, runAborted, runCompleted
146
100
  scalatest.each do |suite|
147
101
  info "ScalaTest #{suite.inspect}"
@@ -195,9 +149,8 @@ end
195
149
 
196
150
  # Backwards compatibility stuff. Remove in 1.5.
197
151
  module Buildr
198
- ScalaSpecs = Scala::ScalaSpecs
199
- ScalaCheck = Scala::ScalaCheck
152
+ ScalaCheck = Scala::Check
200
153
  ScalaTest = Scala::ScalaTest
201
154
  end
202
155
 
203
- Buildr::TestFramework << Buildr::Scala::ScalaTest
156
+ Buildr::TestFramework << Buildr::Scala::ScalaTest
@@ -0,0 +1,57 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ desc "Check that source files contain the Apache license"
18
+ task :license=>FileList["**/*.{rb,rake,java,gemspec,buildfile}", 'Rakefile'] do |task|
19
+ puts "Checking that files contain the Apache license ... "
20
+ required = task.prerequisites.select { |fn| File.file?(fn) }
21
+ missing = required.reject { |fn|
22
+ comments = File.read(fn).scan(/(\/\*(.*?)\*\/)|^#\s+(.*?)$|^-#\s+(.*?)$|<!--(.*?)-->/m).
23
+ map { |match| match.compact }.flatten.join("\n")
24
+ comments =~ /Licensed to the Apache Software Foundation/ && comments =~ /http:\/\/www.apache.org\/licenses\/LICENSE-2.0/
25
+ }
26
+ fail "#{missing.join(', ')} missing Apache License, please add it before making a release!" unless missing.empty?
27
+ puts "[x] Source files contain the Apache license"
28
+ end
29
+
30
+
31
+ desc "Look for new dependencies, check transitive dependencies"
32
+ task :dependency do
33
+ puts "Checking that all dependencies are up to date ..."
34
+ # Find if anything has a more recent dependency. These are not errors, just reports.
35
+ spec.dependencies.each do |dep|
36
+ current = Gem::SourceInfoCache.search(dep).last
37
+ latest = Gem::SourceInfoCache.search(Gem::Dependency.new(dep.name, '>0')).last
38
+ puts "A new version of #{dep.name} is available, #{latest.version} replaces #{current.version}" if (current && latest && latest.version > current.version)
39
+ end
40
+
41
+ # Returns orderd list of transitive dependencies for the given dependency.
42
+ transitive = lambda { |depend|
43
+ dep_spec = Gem::SourceIndex.from_installed_gems.search(depend).last
44
+ fail "No specification for dependency #{depend}" unless dep_spec
45
+ dep_spec.runtime_dependencies.map { |trans| transitive[trans].push(trans) }.flatten.uniq }
46
+ # For each dependency, make sure *all* its transitive dependencies are listed
47
+ # as a Buildr dependency, and order is preserved.
48
+ spec.dependencies.each_with_index do |dep, index|
49
+ puts "checking #{dep.name}"
50
+ transitive[dep].each do |trans|
51
+ matching = spec.dependencies.find { |existing| trans =~ existing }
52
+ fail "#{trans} required by #{dep} and missing from spec" unless matching
53
+ fail "#{trans} must come before #{dep} in dependency list" unless spec.dependencies.index(matching) < index
54
+ end
55
+ end
56
+ puts "[X] Checked all dependencies are up to date and transitive dependencies are correctly ordered"
57
+ end
@@ -14,90 +14,80 @@
14
14
  # the License.
15
15
 
16
16
 
17
+ task 'doc:setup'
18
+ begin # For the Web site, we use the SDoc RDoc generator/theme (http://github.com/voloko/sdoc/)
19
+ require 'sdoc'
20
+ rescue LoadError
21
+ puts "Buildr uses the SDoc RDoc generator/theme. You can install it by running rake doc:setup"
22
+ task('doc:setup') { install_gem 'voloko-sdoc', :source=>'http://gems.github.com' }
23
+ end
24
+
25
+
17
26
  require 'rake/rdoctask'
18
27
 
19
- desc 'Generate RDoc documentation'
20
- rdoc = Rake::RDocTask.new('rdoc') do |rdoc|
28
+ desc "Generate RDoc documentation in rdoc/"
29
+ Rake::RDocTask.new :rdoc do |rdoc|
21
30
  rdoc.rdoc_dir = 'rdoc'
22
31
  rdoc.title = spec.name
23
- rdoc.options = spec.rdoc_options + ['--promiscuous']
32
+ rdoc.options = spec.rdoc_options.clone
24
33
  rdoc.rdoc_files.include('lib/**/*.rb')
25
34
  rdoc.rdoc_files.include spec.extra_rdoc_files
26
35
  end
27
36
 
28
37
 
29
38
  begin
30
- gem 'allison'
31
- rdoc.template = File.expand_path('lib/allison.rb', Gem.loaded_specs['allison'].full_gem_path)
32
- rescue LoadError
33
- puts 'Please run rake setup to install the Allison RDoc template'
34
- task 'setup' do
35
- install_gem 'allison'
36
- end
37
- task 'stage:check' do
38
- fail 'Please run rake setup to install the Allison RDoc template'
39
- end
40
- end
41
-
42
-
43
- begin
44
- require 'docter'
45
- require 'docter/server'
46
-
47
- #Docter.filter_for(:footnote) do |html|
48
- # html.gsub(/<p id="fn(\d+)">(.*?)<\/p>/, %{<p id="fn\\1" class="footnote">\\2</p>})
49
- #end
50
-
51
- collection = Docter.collection(spec.name).using('doc/site.toc.yaml').include('doc/pages', 'LICENSE', 'CHANGELOG')
52
- # TODO: Add coverage reports when we get them to run.
53
- template = Docter.template('doc/site.haml').
54
- include('doc/css', 'doc/images', 'doc/scripts', 'reports/coverage', 'reports/specs.html', 'rdoc', 'print/buildr.pdf')
55
-
56
- desc 'Run Docter server on port 3000'
57
- Docter::Rake.serve 'docter', collection, template, :port=>3000
58
-
59
- desc 'Generate Web site in directory site'
60
- Docter::Rake.generate 'site', collection, template
39
+ require 'rakelib/jekylltask'
61
40
 
62
- Docter::Rake.generate 'print',
63
- Docter.collection(spec.name).using('doc/print.toc.yaml').include('doc/pages'),
64
- Docter.template('doc/print.haml').include('doc/css', 'doc/images'), :one_page
41
+ desc "Generate Buildr documentation in _site/"
42
+ JekyllTask.new :jekyll do |task|
43
+ task.source = 'doc'
44
+ task.target = '_site'
45
+ task.pygments = true
46
+ end
65
47
 
66
- file('print/buildr.pdf'=>'print') do |task|
67
- mkpath 'site'
68
- sh 'prince', 'print/index.html', '-o', task.name, '--media=print' do |ok, res|
69
- fail 'Failed to create PDF, see errors above' unless ok
48
+ rescue LoadError
49
+ puts "Buildr uses the mojombo-jekyll to generate the Web site. You can install it by running rake doc:setup"
50
+ task 'doc:setup' do
51
+ install_gem 'mojombo-jekyll', :source=>'http://gems.github.com', :version=>'0.4.1'
52
+ if `pygmentize -V`.empty?
53
+ args = %w{easy_install Pygments}
54
+ args.unshift 'sudo' unless Config::CONFIG['host_os'] =~ /windows/
55
+ sh *args
70
56
  end
71
57
  end
72
- task 'site'=>'print/buildr.pdf' do
73
- cp 'print/buildr.pdf', 'site'
74
- end
58
+ end
75
59
 
76
- task 'site' do
77
- print 'Checking that we have site documentation, RDoc and PDF ... '
78
- fail 'No PDF generated, you need to install PrinceXML!' unless File.exist?('site/buildr.pdf')
79
- fail 'No RDocs in site directory' unless File.exist?('site/rdoc/files/lib/buildr_rb.html')
80
- fail 'No site documentation in site directory' unless File.exist?('site/index.html')
81
- fail 'No specifications site directory' unless File.exist?('site/specs.html')
82
- puts 'OK'
83
- end
84
60
 
85
- desc 'Produce PDF'
86
- task 'pdf'=>'print/buildr.pdf' do |task|
87
- sh 'open', 'print/buildr.pdf'
88
- end
61
+ desc "Generate Buildr documentation as buildr.pdf"
62
+ file 'buildr.pdf'=>'_site' do |task|
63
+ pages = File.read('doc/preface.textile').scan(/^#.*":(\S*)$/).flatten.map { |f| "_site/#{f}" }
64
+ sh 'prince', '--input=html', '--no-network', '--log=prince_errors.log', "--output=#{task.name}", '_site/preface.html', *pages
65
+ end
89
66
 
90
- task 'clobber' do
91
- rm_rf 'print'
92
- rm_rf 'site'
93
- end
67
+ desc "Build a copy of the Web site in the ./_site"
68
+ task :site=>['_site', :rdoc, '_reports/specs.html', '_reports/coverage', 'buildr.pdf'] do
69
+ cp_r 'rdoc', '_site'
70
+ fail 'No RDocs in site directory' unless File.exist?('_site/rdoc/files/lib/buildr_rb.html')
71
+ cp '_reports/specs.html', '_site'
72
+ cp_r '_reports/coverage', '_site'
73
+ fail 'No coverage report in site directory' unless File.exist?('_site/coverage/index.html')
74
+ cp 'CHANGELOG', '_site'
75
+ cp 'buildr.pdf', '_site'
76
+ fail 'No PDF in site directory' unless File.exist?('_site/buildr.pdf')
77
+ puts 'OK'
78
+ end
94
79
 
95
- rescue LoadError
96
- puts 'Please run rake setup to install the Docter document generation library'
97
- task 'setup' do
98
- install_gem 'docter', '~>1.1.3'
99
- end
100
- task 'stage:check' do
101
- fail 'Please run rake setup to install the Docter document generation library'
102
- end
80
+ # Publish prerequisites to Web site.
81
+ task 'publish'=>:site do
82
+ target = "people.apache.org:/www/#{spec.name}.apache.org/"
83
+ puts "Uploading new site to #{target} ..."
84
+ sh 'rsync', '--progress', '--recursive', '--delete', '_site/', target
85
+ sh 'ssh', 'people.apache.org', 'chmod', '-R', 'g+w', "/www/#{spec.name}.apache.org/*"
86
+ puts "Done"
87
+ end
88
+
89
+ task :clobber do
90
+ rm_rf '_site'
91
+ rm_f 'buildr.pdf'
92
+ rm_f 'prince_errors.log'
103
93
  end
@@ -0,0 +1,110 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ require 'rake/tasklib'
18
+ require 'jekyll'
19
+
20
+
21
+ class JekyllTask < Rake::TaskLib
22
+ def initialize(name=:jekyll) # :yield: self
23
+ @name = name
24
+ @source = name
25
+ @target = name
26
+ yield self if block_given?
27
+ task name, :auto, :needs=>[@source] do |task, args|
28
+ generate args.auto
29
+ end
30
+ if @source != @target
31
+ file @target=>FileList["#{@source}/**/*"] do
32
+ generate
33
+ end
34
+ task 'clobber' do
35
+ rm_rf @target
36
+ end
37
+ end
38
+ end
39
+
40
+ attr_accessor :source
41
+ attr_accessor :target
42
+ attr_accessor :pygments
43
+
44
+ def generate(auto = false)
45
+ process = lambda do
46
+ Jekyll.pygments = @pygments
47
+ Jekyll.process source, target
48
+ touch target
49
+ end
50
+
51
+ if auto
52
+ require 'directory_watcher'
53
+ puts "Auto generating: just edit a page and save, watch the console to see when we're done regenerating pages"
54
+ dw = DirectoryWatcher.new(source)
55
+ dw.interval = 1
56
+ dw.glob = Dir.chdir(source) do
57
+ dirs = Dir['*'].select { |x| File.directory?(x) }
58
+ dirs -= [target]
59
+ dirs = dirs.map { |x| "#{x}/**/*" }
60
+ dirs += ['*']
61
+ end
62
+ dw.start
63
+ dw.add_observer do |*args|
64
+ t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
65
+ puts "[#{t}] regeneration: #{args.size} files changed"
66
+ process.call
67
+ puts "Done"
68
+ end
69
+ loop { sleep 1 }
70
+ else
71
+ puts "Generating documentation in #{target}"
72
+ process.call
73
+ end
74
+ end
75
+ end
76
+
77
+
78
+ # TODO: Worked around bug in Jekyll 0.4.1. Removed when 0.4.2 is out.
79
+ # http://github.com/mojombo/jekyll/commit/c180bc47bf2f63db1bff9f6600cccbe5ad69077e#diff-0
80
+ class Albino
81
+ def execute(command)
82
+ output = ''
83
+ Open4.popen4(command) do |pid, stdin, stdout, stderr|
84
+ stdin.puts @target
85
+ stdin.close
86
+ output = stdout.read.strip
87
+ [stdout, stderr].each { |io| io.close }
88
+ end
89
+ output
90
+ end
91
+ end
92
+
93
+ class Jekyll::Page
94
+ def render(layouts, site_payload)
95
+ puts "... #{@name}"
96
+ payload = {"page" => self.data}.deep_merge(site_payload)
97
+ do_layout(payload, layouts)
98
+ end
99
+ end
100
+
101
+ module TocFilter
102
+ def toc(input)
103
+ input.scan(/<(h2)(?:>|\s+(.*?)>)(.*?)<\/\1\s*>/mi).inject(%{<ol class="toc">}) { |toc, entry|
104
+ id = entry[1][/^id=(['"])(.*)\1$/, 2]
105
+ title = entry[2].gsub(/<(\w*).*?>(.*?)<\/\1\s*>/m, '\2').strip
106
+ toc << %{<li><a href="##{id}">#{title}</a></li>}
107
+ } << "</ol>"
108
+ end
109
+ end
110
+ Liquid::Template.register_filter(TocFilter)
@@ -17,57 +17,55 @@
17
17
  require 'rake/gempackagetask'
18
18
 
19
19
 
20
- desc 'Clean up all temporary directories used for running tests, creating documentation, packaging, etc.'
21
- task 'clobber'
22
-
23
20
  package = Rake::GemPackageTask.new(spec) do |pkg|
24
21
  pkg.need_tar = true
25
22
  pkg.need_zip = true
26
23
  end
27
24
 
28
- desc 'Install the package locally'
29
- task 'install'=>['setup', "#{package.package_dir}/#{package.gem_file}"] do |task|
25
+ desc "Install Buildr from source"
26
+ task :install=>["#{package.package_dir}/#{package.gem_file}"] do |task|
30
27
  print "Installing #{spec.name} ... "
31
- args = [Config::CONFIG['ruby_install_name'], '-S', 'gem', 'install', "#{package.package_dir}/#{package.gem_file}"]
28
+ args = Config::CONFIG['ruby_install_name'], '-S', 'gem', 'install', "#{package.package_dir}/#{package.gem_file}"
32
29
  args.unshift('sudo') if sudo_needed?
33
30
  sh *args
34
- puts 'Done'
31
+ puts "[x] Installed Buildr #{spec.version}"
35
32
  end
36
33
 
37
- desc 'Uninstall previously installed packaged'
38
- task 'uninstall' do |task|
39
- print "Uninstalling #{spec.name} ... "
40
- args = [Config::CONFIG['ruby_install_name'], '-S', 'gem', 'uninstall', spec.name, '--version', spec.version.to_s]
34
+ desc "Uninstall previous rake install"
35
+ task :uninstall do |task|
36
+ puts "Uninstalling #{spec.name} ... "
37
+ args = Config::CONFIG['ruby_install_name'], '-S', 'gem', 'uninstall', spec.name, '--version', spec.version.to_s
41
38
  args.unshift('sudo') if sudo_needed?
42
39
  sh *args
43
- puts 'Done'
40
+ puts "[x] Uninstalled Buildr #{spec.version}"
44
41
  end
45
42
 
46
43
 
47
- desc 'Look for new dependencies, check transitive dependencies'
48
- task 'dependency' do
49
- puts "Checking that all dependencies are up to date ..."
50
- # Find if anything has a more recent dependency. These are not errors, just reports.
51
- for dep in spec.dependencies
52
- current = Gem::SourceInfoCache.search(dep, true, true).last
53
- latest = Gem::SourceInfoCache.search(Gem::Dependency.new(dep.name, '>0'), true, true).last
54
- puts "A new version of #{dep.name} is available, #{latest.version} replaces #{current.version}" if latest.version > current.version
55
- end
56
-
57
- # Returns orderd list of transitive dependencies for the given dependency.
58
- transitive = lambda { |depend|
59
- dep_spec = Gem::SourceIndex.from_installed_gems.search(depend).last
60
- dep_spec.dependencies.map { |trans| transitive[trans].push(trans) }.flatten.uniq }
61
- # For each dependency, make sure *all* its transitive dependencies are listed
62
- # as a Buildr dependency, and order is preserved.
63
- spec.dependencies.each_with_index do |dep, index|
64
- puts "checking #{dep.name}"
65
- for trans in transitive[dep]
66
- matching = spec.dependencies.find { |existing| trans =~ existing }
67
- fail "#{trans} required by #{dep} and missing from spec" unless matching
68
- fail "#{trans} must come before #{dep} in dependency list" unless spec.dependencies.index(matching) < index
69
- end
70
- end
44
+ desc "Compile Java libraries used by Buildr"
45
+ task :compile do
46
+ puts "Compiling Java libraries ..."
47
+ args = Config::CONFIG['ruby_install_name'], File.expand_path(RUBY_PLATFORM[/java/] ? '_jbuildr' : '_buildr'), '--buildfile', 'buildr.buildfile', 'compile'
48
+ args << '--trace' if Rake.application.options.trace
49
+ sh *args
71
50
  end
51
+ file Rake::GemPackageTask.new(spec).package_dir=>:compile
52
+ file Rake::GemPackageTask.new(spec).package_dir_path=>:compile
72
53
 
73
- task 'stage:check'=>'dependency'
54
+ # We also need the other package (JRuby if building on Ruby, and vice versa)
55
+ # Must call new with block, even if block does nothing, otherwise bad things happen.
56
+ Rake::GemPackageTask.new(spec(RUBY_PLATFORM[/java/] ? 'ruby' : 'java')) { |task| }
57
+
58
+
59
+ desc "Upload snapshot packages over to people.apache.org"
60
+ task :snapshot=>[:package] do
61
+ rm_rf '_snapshot' # Always start with empty directory
62
+ puts "Copying existing gems from Apache"
63
+ sh 'rsync', '--progress', '--recursive', 'people.apache.org:public_html/buildr/snapshot/', '_snapshot/'
64
+ puts "Copying new gems over"
65
+ cp FileList['pkg/{*.gem,*.tgz,*.zip}'], '_snapshot/gems'
66
+ puts "Generating gem index ..."
67
+ sh 'gem', 'generate_index', '--directory', '_snapshot'
68
+ puts "Copying gem and index back to Apache"
69
+ sh 'rsync', '--progress', '--recursive', '_snapshot/', 'people.apache.org:public_html/buildr/snapshot/'
70
+ end
71
+ task(:clobber) { rm_rf '_snapshot' }