vic-buildr 1.3.3 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/CHANGELOG +42 -11
  2. data/Rakefile +5 -3
  3. data/_buildr +9 -31
  4. data/addon/buildr/cobertura.rb +5 -218
  5. data/addon/buildr/drb.rb +281 -0
  6. data/addon/buildr/emma.rb +5 -220
  7. data/addon/buildr/nailgun.rb +94 -686
  8. data/bin/buildr +0 -9
  9. data/buildr.gemspec +6 -6
  10. data/doc/images/favicon.png +0 -0
  11. data/doc/pages/contributing.textile +6 -4
  12. data/doc/pages/download.textile +11 -0
  13. data/doc/pages/extending.textile +2 -2
  14. data/doc/pages/getting_started.textile +4 -4
  15. data/doc/pages/index.textile +8 -11
  16. data/doc/pages/more_stuff.textile +50 -22
  17. data/doc/pages/packaging.textile +1 -1
  18. data/doc/pages/projects.textile +2 -2
  19. data/doc/pages/settings_profiles.textile +2 -2
  20. data/doc/pages/testing.textile +1 -1
  21. data/doc/pages/whats_new.textile +12 -0
  22. data/doc/site.haml +1 -0
  23. data/lib/buildr.rb +2 -4
  24. data/lib/buildr/core.rb +2 -0
  25. data/lib/buildr/core/application.rb +304 -149
  26. data/lib/buildr/core/checks.rb +3 -131
  27. data/lib/buildr/core/common.rb +0 -4
  28. data/lib/buildr/core/compile.rb +1 -7
  29. data/lib/buildr/core/environment.rb +0 -3
  30. data/lib/buildr/core/filter.rb +7 -3
  31. data/lib/buildr/core/generate.rb +50 -52
  32. data/lib/buildr/core/help.rb +2 -1
  33. data/lib/buildr/core/osx.rb +49 -0
  34. data/lib/buildr/core/progressbar.rb +1 -1
  35. data/lib/buildr/core/project.rb +7 -9
  36. data/lib/buildr/core/test.rb +4 -4
  37. data/lib/buildr/core/transports.rb +13 -30
  38. data/lib/buildr/core/util.rb +8 -3
  39. data/lib/buildr/groovy/bdd.rb +1 -0
  40. data/lib/buildr/groovy/compiler.rb +1 -1
  41. data/lib/buildr/ide/eclipse.rb +30 -20
  42. data/lib/buildr/ide/idea.rb +3 -2
  43. data/lib/buildr/ide/idea7x.rb +4 -2
  44. data/lib/buildr/java/ant.rb +1 -1
  45. data/lib/buildr/java/bdd.rb +9 -5
  46. data/lib/buildr/java/cobertura.rb +236 -0
  47. data/lib/buildr/java/commands.rb +2 -1
  48. data/lib/buildr/java/emma.rb +238 -0
  49. data/lib/buildr/java/jtestr_runner.rb.erb +2 -0
  50. data/lib/buildr/java/packaging.rb +6 -2
  51. data/lib/buildr/java/pom.rb +0 -4
  52. data/lib/buildr/java/test_result.rb +45 -15
  53. data/lib/buildr/java/tests.rb +14 -9
  54. data/lib/buildr/packaging.rb +5 -2
  55. data/lib/buildr/packaging/archive.rb +488 -0
  56. data/lib/buildr/packaging/artifact.rb +36 -7
  57. data/lib/buildr/packaging/artifact_namespace.rb +2 -2
  58. data/lib/buildr/packaging/gems.rb +3 -3
  59. data/lib/buildr/packaging/package.rb +1 -1
  60. data/lib/buildr/packaging/tar.rb +85 -3
  61. data/lib/buildr/packaging/version_requirement.rb +172 -0
  62. data/lib/buildr/packaging/zip.rb +24 -682
  63. data/lib/buildr/packaging/ziptask.rb +313 -0
  64. data/lib/buildr/scala/compiler.rb +1 -1
  65. data/lib/buildr/scala/tests.rb +2 -2
  66. data/rakelib/apache.rake +58 -8
  67. data/rakelib/package.rake +4 -1
  68. data/rakelib/rspec.rake +2 -2
  69. data/rakelib/rubyforge.rake +6 -3
  70. data/rakelib/scm.rake +1 -1
  71. data/rakelib/setup.rake +0 -5
  72. data/rakelib/stage.rake +4 -1
  73. data/spec/addon/drb_spec.rb +328 -0
  74. data/spec/core/application_spec.rb +29 -22
  75. data/spec/core/build_spec.rb +8 -0
  76. data/spec/core/checks_spec.rb +293 -311
  77. data/spec/core/common_spec.rb +8 -2
  78. data/spec/core/compile_spec.rb +17 -1
  79. data/spec/core/generate_spec.rb +33 -0
  80. data/spec/core/project_spec.rb +18 -10
  81. data/spec/core/test_spec.rb +24 -1
  82. data/spec/ide/eclipse_spec.rb +96 -28
  83. data/spec/java/ant.rb +5 -0
  84. data/spec/java/bdd_spec.rb +4 -4
  85. data/spec/{addon → java}/cobertura_spec.rb +3 -3
  86. data/spec/{addon → java}/emma_spec.rb +3 -3
  87. data/spec/java/java_spec.rb +9 -1
  88. data/spec/java/packaging_spec.rb +19 -2
  89. data/spec/{addon → java}/test_coverage_spec.rb +7 -1
  90. data/spec/java/tests_spec.rb +5 -0
  91. data/spec/packaging/archive_spec.rb +1 -1
  92. data/spec/{core → packaging}/artifact_namespace_spec.rb +2 -2
  93. data/spec/packaging/artifact_spec.rb +46 -5
  94. data/spec/packaging/packaging_spec.rb +1 -1
  95. data/spec/sandbox.rb +16 -14
  96. data/spec/spec_helpers.rb +26 -3
  97. metadata +20 -11
  98. data/lib/buildr/core/application_cli.rb +0 -139
data/bin/buildr CHANGED
@@ -14,15 +14,6 @@
14
14
  # License for the specific language governing permissions and limitations under
15
15
  # the License.
16
16
 
17
- start = Time.now
18
17
  require 'rubygems'
19
18
  require 'buildr'
20
19
  Buildr.application.run
21
- if verbose
22
- elapsed = Time.now - start
23
- real = []
24
- real << ("%ih" % (elapsed / 3600)) if elapsed >= 3600
25
- real << ("%im" % ((elapsed / 60) % 60)) if elapsed >= 60
26
- real << ("%.3fs" % (elapsed % 60))
27
- puts $terminal.color("Completed in #{real.join}", :green)
28
- end
data/buildr.gemspec CHANGED
@@ -16,11 +16,11 @@
16
16
 
17
17
  Gem::Specification.new do |spec|
18
18
  spec.name = 'buildr'
19
- spec.version = '1.3.3'
19
+ spec.version = '1.3.4'
20
20
  spec.author = 'Apache Buildr'
21
21
  spec.email = "buildr-user@incubator.apache.org"
22
22
  spec.homepage = "http://incubator.apache.org/buildr"
23
- spec.summary = 'A build system that doesn\'t suck'
23
+ spec.summary = "A build system that doesn't suck"
24
24
  spec.rubyforge_project = 'buildr'
25
25
 
26
26
  # Rakefile needs to create spec for both platforms (ruby and java), using the
@@ -41,17 +41,17 @@ Gem::Specification.new do |spec|
41
41
  '--webcvs' << 'http://svn.apache.org/repos/asf/incubator/buildr/trunk/'
42
42
 
43
43
  # Tested against these dependencies.
44
- spec.add_dependency 'rake', '0.8.1'
44
+ spec.add_dependency 'rake', '0.8.3'
45
45
  spec.add_dependency 'builder', '2.1.2'
46
46
  spec.add_dependency 'net-ssh', '2.0.4'
47
47
  spec.add_dependency 'net-sftp', '2.0.1'
48
48
  spec.add_dependency 'rubyzip', '0.9.1'
49
49
  spec.add_dependency 'highline', '1.4.0'
50
- spec.add_dependency 'rubyforge', '1.0.0'
51
- spec.add_dependency 'hoe', '1.7.0'
50
+ spec.add_dependency 'rubyforge', '1.0.1'
51
+ spec.add_dependency 'hoe', '1.8.1'
52
52
  spec.add_dependency 'rjb', '1.1.6' if spec.platform.to_s == 'ruby'
53
53
  spec.add_dependency 'Antwrap', '0.7.0'
54
- spec.add_dependency 'rspec', '1.1.5'
54
+ spec.add_dependency 'rspec', '1.1.11'
55
55
  spec.add_dependency 'xml-simple', '1.0.11'
56
56
  spec.add_dependency 'archive-tar-minitar', '0.5.2'
57
57
  spec.add_dependency 'jruby-openssl', '0.2' if spec.platform.to_s == 'java'
Binary file
@@ -86,7 +86,7 @@ If you want to learn more about Git, you can start by watching Scott Chacon’s
86
86
 
87
87
  And keep this "Git cheat sheet":http://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png close at hand. Very useful.
88
88
 
89
- *Note:* The GitHub repository is maintained by contributors to this project, but is *not* an official Apache repository. To obtain Buildr from the official Apache repository, consider using @giv-svn@ instead.
89
+ *Note:* The GitHub repository is maintained by contributors to this project, but is *not* an official Apache repository. To obtain Buildr from the official Apache repository, consider using @git-svn@ instead.
90
90
 
91
91
  h3. Working with Source Code
92
92
 
@@ -116,7 +116,7 @@ h3. Using development build
116
116
  Occasionally we'll make development builds from the current code in trunk/head. We appreciate if you can take the time to test those out and report any bugs. To install development builds, use the Gem repository at @people.apache.org/~assaf/buildr/snapshot@:
117
117
 
118
118
  {{{!sh
119
- gem source --add http://people.apache.org/~assaf/buildr/snapshot
119
+ gem source --add http://people.apache.org/~assaf/buildr/snapshot/
120
120
  }}}
121
121
 
122
122
  Since Ruby Gems uses version numbers to detect new releases, if you installed Buildr from a snapshot and want to upgrade to a newer snapshot or the latest official release, you need to use @gem install buildr@ rather than @gem upgrade@.
@@ -124,7 +124,7 @@ Since Ruby Gems uses version numbers to detect new releases, if you installed Bu
124
124
  If you want to go back to using the RubyForge releases:
125
125
 
126
126
  {{{!sh
127
- gem source --remove http://people.apache.org/~assaf/buildr/snapshot
127
+ gem source --remove http://people.apache.org/~assaf/buildr/snapshot/
128
128
  gem install buildr
129
129
  }}}
130
130
 
@@ -173,7 +173,7 @@ Yes, we do make typos, spelling errors and sometimes we write things that don't
173
173
 
174
174
  For simple typos and quick fixes, just send a message to the mailing list or log an issue in JIRA.
175
175
 
176
- If you end up rewriting a significant piece of text, or add new documentation (your rock!), send a patch. Making documentation patches is fairly easy. All the documentation is generated from text files in the @doc/pages@ directory, so all you need to do is check it out from SVN, edit, and @svn diff@ to create a patch.
176
+ If you end up rewriting a significant piece of text, or add new documentation (you rock!), send a patch. Making documentation patches is fairly easy. All the documentation is generated from text files in the @doc/pages@ directory, so all you need to do is check it out from SVN, edit, and @svn diff@ to create a patch.
177
177
 
178
178
  We use "Textile":http://www.textism.com/tools/textile/ as the markup language, it takes all of a few minutes to learn, it's intuitive to use, and produces clean HTML. You can learn it all in a few minutes from the "Textile Reference Manual":http://redcloth.org/textile. Also check out the "Textile Quick Reference":http://hobix.com/textile/quick.html.
179
179
 
@@ -195,6 +195,8 @@ Here is the list of people who are actively working and committing on Buildr:
195
195
 
196
196
  *Alex Boisvert*
197
197
 
198
+ Came to Buildr as a refuge from the Maven Uncertainty Principle. Alex has been working mostly on the Scala integration and believes Ruby scripting is a great complement to statically typed languages.
199
+
198
200
  *"Matthieu Riou":http://offthelip.org*
199
201
 
200
202
  *Victor Hugo Borja* (vborja at apache.org)
@@ -14,6 +14,17 @@ The source code is included in both source and binary distribution, the Gem dist
14
14
 
15
15
  h2. Binaries and Source Code
16
16
 
17
+ h3. buildr 1.3.3-incubating (2008-10-08)
18
+
19
+ |_. Package |_. MD5 Checksum |_. PGP |
20
+ | "buildr-1.3.3-incubating.gem":http://www.apache.org/dist/incubator/buildr/1.3.3-incubating/buildr-1.3.3-incubating.gem | "7192dad45441630cbf07b85af5f9069a":http://www.apache.org/dist/incubator/buildr/1.3.3-incubating/buildr-1.3.3-incubating.gem.md5 | "Sig":http://www.apache.org/dist/incubator/buildr/1.3.3-incubating/buildr-1.3.3-incubating.gem.asc |
21
+ | "buildr-1.3.3-java-incubating.gem":http://www.apache.org/dist/incubator/buildr/1.3.3-incubating/buildr-1.3.3-java-incubating.gem | "71ad4f0f8bfa951fa129db67a06b608a":http://www.apache.org/dist/incubator/buildr/1.3.3-incubating/buildr-1.3.3-java-incubating.gem.md5 | "Sig":http://www.apache.org/dist/incubator/buildr/1.3.3-incubating/buildr-1.3.3-java-incubating.gem.asc |
22
+ | "buildr-1.3.3-incubating.tgz":http://www.apache.org/dist/incubator/buildr/1.3.3-incubating/buildr-1.3.3-incubating.tgz | "e5ee6fe5b86386520c91a9633d02814b":http://www.apache.org/dist/incubator/buildr/1.3.3-incubating/buildr-1.3.3-incubating.tgz.md5 | "Sig":http://www.apache.org/dist/incubator/buildr/1.3.3-incubating/buildr-1.3.3-incubating.tgz.asc |
23
+ | "buildr-1.3.3-incubating.zip":http://www.apache.org/dist/incubator/buildr/1.3.3-incubating/buildr-1.3.3-incubating.zip | "baab601fd46a877ee8e408891d68c842":http://www.apache.org/dist/incubator/buildr/1.3.3-incubating/buildr-1.3.3-incubating.zip.md5 | "Sig":http://www.apache.org/dist/incubator/buildr/1.3.3-incubating/buildr-1.3.3-incubating.zip.asc |
24
+
25
+ p>. ("Release signing keys":http://www.apache.org/dist/incubator/buildr/1.3.3-incubating/KEYS)
26
+
27
+
17
28
  h3. buildr 1.3.2-incubating (2008-07-18)
18
29
 
19
30
  |_. Package |_. MD5 Checksum |_. PGP |
@@ -21,7 +21,7 @@ file('derby.sql') do
21
21
  :classpath=>REQUIRES.join(File::PATH_SEPARATOR)
22
22
  ant.mapping :schemaAction=>'build', :sqlFile=>task.name,
23
23
  :ignoreErrors=>true do
24
- ant.config :propertiesFile=>_(:source, :main, :sql, 'derby.xml')
24
+ ant.config :propertiesFile=>_('src/main/sql/derby.xml')
25
25
  ant.classpath :path=>projects('store', 'utils' ).
26
26
  flatten.map(&:to_s).join(File::PATH_SEPARATOR)
27
27
  end
@@ -34,7 +34,7 @@ To this:
34
34
  {{{!ruby
35
35
  file('derby.sql') do
36
36
  mapping_tool :action=>'build', :sql=>task.name,
37
- :properties=>_(:source, :main, :sql, 'derby.xml'),
37
+ :properties=>_('src/main/sql/derby.xml'),
38
38
  :classpath=>projects('store', 'utils')
39
39
  end
40
40
  }}}
@@ -46,7 +46,7 @@ To upgrade to a new version or install a specific version:
46
46
 
47
47
  {{{!sh
48
48
  $ sudo env JAVA_HOME=$JAVA_HOME gem update buildr
49
- $ sudo env JAVA_HOME=$JAVA_HOME gem install buildr -v 1.3.0
49
+ $ sudo env JAVA_HOME=$JAVA_HOME gem install buildr -v 1.3.4
50
50
  }}}
51
51
 
52
52
  You can also use this script "to install Buildr on Linux":scripts/install-linux.sh. This script will install Buildr or if already installed, upgrade to a more recent version. It will also install Ruby 1.8.6 if not already installed (using @yum@ or @apt-get@) and upgrage RubyGems to 1.0.1.
@@ -78,7 +78,7 @@ To upgrade to a new version or install a specific version:
78
78
 
79
79
  {{{!sh
80
80
  $ sudo env JAVA_HOME=$JAVA_HOME gem update buildr
81
- $ sudo env JAVA_HOME=$JAVA_HOME gem install buildr -v 1.3.0
81
+ $ sudo env JAVA_HOME=$JAVA_HOME gem install buildr -v 1.3.4
82
82
  }}}
83
83
 
84
84
  You can also use this script "to install Buildr on OS X":scripts/install-osx.sh. This script will install Buildr or if already installed, upgrade to a more recent version. It will also install Ruby 1.8.6 if not already installed (using MacPorts) and upgrage RubyGems to 1.0.1.
@@ -106,7 +106,7 @@ To upgrade to a new version or install a specific version:
106
106
 
107
107
  {{{!sh
108
108
  > gem update buildr
109
- > gem install buildr -v 1.3.0
109
+ > gem install buildr -v 1.3.4
110
110
  }}}
111
111
 
112
112
 
@@ -134,7 +134,7 @@ To upgrade to a new version or install a specific version:
134
134
 
135
135
  {{{!sh
136
136
  $ jruby -S gem update buildr
137
- $ jruby -S gem install buildr -v 1.3.0
137
+ $ jruby -S gem install buildr -v 1.3.4
138
138
  }}}
139
139
 
140
140
  You can also use this script "to install Buildr on JRuby":scripts/install-jruby.sh. This script will install Buildr or if already installed, upgrade to a more recent version. If necessary, it will also install JRuby 1.1 in @/opt/jruby@ and update the @PATH@ variable in @~/.bash_profile@ or @~/.profile@.
@@ -22,17 +22,14 @@ So let's get started. You can "read the documentation online":getting_started.h
22
22
 
23
23
  h2. News
24
24
 
25
- Check out "all that's new in Buildr 1.3.2":whats_new.html.
26
-
27
- * Buildr 1.3 now runs on JRuby 1.1
28
- * Support for building Scala projects
29
- * Support for building Groovy projects
30
- * EAR packages
31
- * Behaviour-Driven Development frameworks
32
- * Profiles
33
- * New API for accessing Java libraries
34
- * Alternative source layouts
35
- * More documentation
25
+ Check out "all that's new in Buildr 1.3.3":whats_new.html.
26
+
27
+ * Buildr 1.3 now runs on JRuby 1.1 and Ruby 1.8.6.
28
+ * Support for building Scala and Groovy projects.
29
+ * Behavior-Driven Development frameworks (RSpec, JBehave, etc).
30
+ * Profiles and build.yml settings file.
31
+ * New API for accessing Java libraries.
32
+ * More documentation.
36
33
  * Other features and bug fixes.
37
34
 
38
35
 
@@ -82,37 +82,59 @@ When building an extension, make sure to follow these rules:
82
82
  # Check on a clean build with empty local repository.
83
83
 
84
84
 
85
- h2. Nailgun
85
+ h2. BuildrServer
86
86
 
87
- "Nailgun":http://www.martiansoftware.com/nailgun/index.html is a client, protocol, and server for running Java programs from the command line without incurring the JVM startup overhead. Nailgun integration is available only when running Buildr within JRuby.
87
+ Buildr provides an addon that allows you start a "dRuby":http://www.ruby-doc.org/stdlib/libdoc/drb/rdoc/index.html server hosting a buildfile, so that you can later invoke tasks on it without having to load the complete buildr runtime again.
88
88
 
89
- Buildr provides a custom nailgun server, allowing you to start a single JVM and let buildr create a queue of runtimes. These JRuby runtimes can be cached (indexed by buildfile path) and are automatically reloaded when the buildfile has been modified. Runtime caching allows you to execute tasks without spending time creating the buildr environment.
89
+ Usage:
90
90
 
91
- Start the BuildrServer by executing
91
+ {{{!sh
92
+ buildr -r buildr/drb drb:start
93
+ }}}
94
+
95
+ To stop the BuildrServer simply use Ctrl+C or kill the process.
96
+
97
+ Once the server has been started you can invoke tasks using a simple script:
92
98
 
93
99
  {{{!ruby
94
- $ jruby -S buildr -rbuildr/nailgun nailgun:start
100
+ #!/usr/bin/env ruby
101
+ require 'rubygems'
102
+ require 'buildr/drb'
103
+ Buildr::DRbApplication.run
95
104
  }}}
96
105
 
97
- Server output will display a message when it becomes ready, you will also see messages when the JRuby runtimes are being created, or when a new buildr environment is being loaded on them. After the runtime queues have been populated, you can start calling buildr as you normally do, by invoking the $NAILGUN_HOME/ng binary:
106
+ Save this script as @dbuildr@, make it executable and use it to invoke tasks.
107
+
108
+ {{{!sh
109
+ $ dbuildr clean compile
110
+ }}}
111
+
112
+ @dbuildr@ will start the BuildrServer if there isn't one already running.
113
+ Subsequent calls to dbuildr will act as the client and invoke the tasks you
114
+ provide to the server.
115
+ If the buildfile has been modified it will be reloaded on the BuildrServer.
116
+
117
+ h3. Nailgun
118
+
119
+ "Nailgun":http://www.martiansoftware.com/nailgun/index.html is a client, protocol, and server for running Java programs from the command line without incurring the JVM startup overhead. Nailgun integration is available only when running Buildr within JRuby.
120
+
121
+ JRuby users need not to create the @dbuildr@ script listed on the previous section, as they can benefit from
122
+ using a nailgun client to invoke tasks without having to wait for JVM+JRuby to load.
123
+
124
+ Start the BuildrServer by executing
98
125
 
99
126
  {{{!sh
100
- # on another terminal, change directory to a project.
101
- # if this project is the same nailgun:start was invoked on, it's
102
- # runtime has been cached, so no loading is performed unless
103
- # the buildfile has been modified. otherwise the buildfile
104
- # will be loaded on a previously loaded fresh-buildr runtime
105
- # and it will be cached.
106
- cd /some/buildr/project
107
- ng nailgun:help # display nailgun help
108
- ng nailgun:tasks # display overview of ng tasks
109
- ng clean compile # just invoke those two tasks
127
+ $ jruby -S buildr -rbuildr/nailgun nailgun:start
110
128
  }}}
111
129
 
112
- Some nailgun tasks have been provided to manage the cached runtimes, to get an overview of them execute the @nailgun:tasks@ task.
130
+ To stop the BuildrServer simply use Ctrl+C or kill the process.
113
131
 
114
- Be sure to read the nailgun help by executing the @nailgun:help@ task.
132
+ Once the server has been started you can invoke tasks using the nailgun client
133
+ installed on @$JRUBY_HOME/tool/nailgun/ng@
115
134
 
135
+ {{{!sh
136
+ $ ng clean compile
137
+ }}}
116
138
 
117
139
  h2. Growl, Qube
118
140
 
@@ -158,6 +180,12 @@ The @eclipse@ task will generate a @.classpath@ and @.project@ file for each of
158
180
 
159
181
  If you add a new project, change the dependencies, or make any other change to your Buildfile, just run the @eclipse@ task again to re-generate the Eclipse project files.
160
182
 
183
+ To have your libraries' source code available in Eclipse, run:
184
+
185
+ {{{!sh
186
+ $ buildr artifacts:sources
187
+ }}}
188
+
161
189
  If you prefer IntelliJ IDEA, you can always:
162
190
 
163
191
  {{{!sh
@@ -213,8 +241,8 @@ The other two tasks are @jdepend:text@ and @jdepend:xml@.
213
241
  We want Buildr to load fast, and not everyone cares for these tasks, so we don't include them by default. If you want to use one of them, you need to require it explicitly. The proper way to do it in Ruby:
214
242
 
215
243
  {{{!ruby
216
- require 'buildr/cobertura'
217
- require 'buildr/emma'
244
+ require 'buildr/java/cobertura'
245
+ require 'buildr/java/emma'
218
246
  require 'buildr/jdepend'
219
247
  }}}
220
248
 
@@ -224,7 +252,7 @@ Another option is to require it from the command line (@--require@ or @-r@), for
224
252
 
225
253
  {{{!sh
226
254
  $ buildr --require buildr/jdepend jdepend:swing
227
- $ buildr -rbuildr/cobertura cobertura:html
255
+ $ buildr -rbuildr/java/cobertura cobertura:html
228
256
  }}}
229
257
 
230
258
 
@@ -250,7 +278,7 @@ You can use functions to keep your code simple. For example, in the ODE project
250
278
  def distro(project, id)
251
279
  project.package(:zip, :id=>id).path("#{id}-#{version}").tap do |zip|
252
280
  zip.include meta_inf + ['RELEASE_NOTES', 'README'].map { |f| path_to(f) }
253
- zip.path('examples').include project.path_to(:source, :examples), :as=>'.'
281
+ zip.path('examples').include project.path_to('src/examples'), :as=>'.'
254
282
  zip.merge project('ode:tools-bin').package(:zip)
255
283
  zip.path('lib').include artifacts(COMMONS.logging, COMMONS.codec,
256
284
  COMMONS.httpclient, COMMONS.pool, COMMONS.collections, JAXEN, SAXON,
@@ -384,7 +384,7 @@ If you need to upload other files, you can always extend the @upload@ task and u
384
384
 
385
385
  {{{!ruby
386
386
  # We'll let some other task decide how to create 'docs'
387
- task 'deploy'=>'docs' do
387
+ task 'upload'=>'docs' do
388
388
  uri = URI("sftp://#{username}:#{password}@var/www/docs")
389
389
  uri.upload file('docs')
390
390
  end
@@ -17,7 +17,7 @@ AXIS2 = 'org.apache.axis2:axis2:jar:1.2'
17
17
  AXIOM = group('axiom-api', 'axiom-impl', 'axiom-dom',
18
18
  :under=>'org.apache.ws.commons.axiom', :version=>'1.2.4')
19
19
  AXIS_OF_WS = [AXIOM, AXIS2]
20
- OPENJPA = ['org.apache.openjpa:openjpa-all:jar:0.9.7',
20
+ OPENJPA = ['org.apache.openjpa:openjpa:jar:1.2.0',
21
21
  'net.sourceforge.serp:serp:jar:1.12.0']
22
22
 
23
23
  repositories.remote << 'http://www.ibiblio.org/maven2/'
@@ -44,7 +44,7 @@ define 'killer-app' do
44
44
 
45
45
  desc 'What our users see'
46
46
  define 'la-web' do
47
- test.using AXIS_OF_WS
47
+ test.with AXIS_OF_WS
48
48
  package(:war).with :libs=>projects('teh-api', 'teh-impl')
49
49
  end
50
50
 
@@ -201,7 +201,7 @@ Here's a simple example for handling different environments within the Buildfile
201
201
  {{{!ruby
202
202
  project 'db-module' do
203
203
  db = (environment == 'production' ? 'oracle' : 'hsql')
204
- resources.from(_(:source, :main, db))
204
+ resources.from(_("src/main/#{db}"))
205
205
  end
206
206
  }}}
207
207
 
@@ -244,7 +244,7 @@ Here's a simple example for a buildfile that uses the profile information:
244
244
  project 'db-module' do
245
245
  # Copy SQL files specific for the database we're using,
246
246
  # for example, everything under src/main/hsql.
247
- resources.from(_(:source, :main, profile['db']))
247
+ resources.from(_("src/main/#{Buildr.settings.profile['db']}"))
248
248
  # Set the JDBC URL in copied resource files (config.xml needs this).
249
249
  resources.filter :jdbc=>profile['jdbc']
250
250
  end
@@ -195,7 +195,7 @@ Buildr provides the following matchers:
195
195
  | @empty@ | Given a file task checks that the file (or directory) is empty. |
196
196
  | @contain@ | Given a file task referencing a file, checks its contents, using string or regular expression. For a file task referencing a directory, checks that it contains the specified files; global patterns using @*@ and @**@ are allowed. |
197
197
 
198
- All these matchers operate against a file task. If you run them against a ZipTask (including JAR, WAR, etc) they can also check the contents of the ZIP file. And as you can see in the examples above, you can also run them against a path in a ZIP file, checking its contents as if it was a directory, or against an entry in a ZIP file, checking the content of that file.
198
+ All these matchers operate against a file task. If you run them against a ZipTask (including JAR, WAR, etc) or a TarTask, they can also check the contents of the archive. And as you can see in the examples above, you can also run them against a path in an archive, checking its contents as if it was a directory, or against an entry in an archive, checking the content of that file.
199
199
 
200
200
  p(note). The @package@ method returns a package task based on packaging type, identifier, group, version and classifier. The last four are inferred, but if you create a package with different specifications (for example, you specify a classifier) your checks must call @package@ with the same qualifying arguments to return the very same package task.
201
201
 
@@ -1,5 +1,16 @@
1
1
  h1. What's New
2
2
 
3
+ h2. Buildr 1.3.3
4
+
5
+ * Support for "JtestR":http://jtestr.codehaus.org/ test framework.
6
+ * Support for "Emma":http://emma.sourceforge.net/ code coverage tool.
7
+ * Growl notifications (OS X only).
8
+ * Starting with this release you can use the @build.yml@ file to control versions of various 3rd party libraries, e.g. Ant, JUnit, ScalaCheck.
9
+ * The _release_ task now supports alternative SVN repository layouts. Releases are tagged in SVN using the version number, but you can customize the tag name (see @Releases.tag_name@). The @NEXT_VERSION@ constant is no longer used during the release process.
10
+ * This release is tested against JRuby 1.1.3 and JRuby 1.1.4. There are also some improvements towards Ruby 1.9 support.
11
+ * 27 other bug fixes and minor changes, see the "CHANGELOG":changelog.html for full details.
12
+
13
+
3
14
  h2. Buildr 1.3.2
4
15
 
5
16
  * New @--prereqs@ command line argument lists all the tasks and their dependencies. You can also filter specific tasks by following with a regular expression, for example, @--prereqs foo@.
@@ -13,6 +24,7 @@ h2. Buildr 1.3.2
13
24
  * Fixed: BUILDR-100 Directory structure documentation needs updating.
14
25
  * Fixed: Installation instructions updated for RubyGems 1.2.0.
15
26
 
27
+
16
28
  h2. Buildr 1.3.1
17
29
 
18
30
  * Fixed to specific Gem dependencies, so should install cleanly on Windows.
data/doc/site.haml CHANGED
@@ -25,6 +25,7 @@
25
25
  @import 'css/print.css';
26
26
  \#header { display: none }
27
27
  %meta{ :name=>'subject', :content=>'Official Buildr documentation from the people in the know' }
28
+ %link{ :rel=>'shortcut icon', :href=>'images/favicon.png'}
28
29
  %body
29
30
  #wrap
30
31
  #header
data/lib/buildr.rb CHANGED
@@ -14,12 +14,13 @@
14
14
  # the License.
15
15
 
16
16
  module Buildr
17
- VERSION = '1.3.3'.freeze
17
+ VERSION = '1.3.4'.freeze
18
18
  end
19
19
 
20
20
  require 'buildr/core'
21
21
  require 'buildr/packaging'
22
22
  require 'buildr/java'
23
+ require 'buildr/scala'
23
24
  require 'buildr/ide'
24
25
 
25
26
  # Methods defined in Buildr are both instance methods (e.g. when included in Project)
@@ -30,6 +31,3 @@ class << self ; include Buildr ; end
30
31
  class Object #:nodoc:
31
32
  Buildr.constants.each { |c| const_set c, Buildr.const_get(c) unless const_defined?(c) }
32
33
  end
33
-
34
- # Prevent RSpec runner from running at_exit.
35
- require 'spec'
data/lib/buildr/core.rb CHANGED
@@ -24,4 +24,6 @@ require 'buildr/core/filter'
24
24
  require 'buildr/core/compile'
25
25
  require 'buildr/core/test'
26
26
  require 'buildr/core/checks'
27
+ require 'buildr/core/transports'
27
28
  require 'buildr/core/generate'
29
+ require 'buildr/core/osx' if RUBY_PLATFORM =~ /darwin/
@@ -13,6 +13,7 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
+
16
17
  # Portion of this file derived from Rake.
17
18
  # Copyright (c) 2003, 2004 Jim Weirich
18
19
  #
@@ -35,15 +36,15 @@
35
36
  # SOFTWARE.
36
37
 
37
38
 
38
- require 'highline/import'
39
39
  require 'rake'
40
+ require 'highline/import'
40
41
  require 'rubygems/source_info_cache'
41
- require 'buildr/core/application_cli'
42
42
  require 'buildr/core/util'
43
+ Gem.autoload :SourceInfoCache, 'rubygems/source_info_cache'
43
44
 
44
45
 
45
46
  # Gem::user_home is nice, but ENV['HOME'] lets you override from the environment.
46
- ENV["HOME"] ||= File.expand_path(Gem::user_home)
47
+ ENV['HOME'] ||= File.expand_path(Gem::user_home)
47
48
  ENV['BUILDR_ENV'] ||= 'development'
48
49
 
49
50
 
@@ -68,19 +69,22 @@ module Buildr
68
69
 
69
70
  def initialize(application) #:nodoc:
70
71
  @application = application
71
- @user = load_from('settings', @application.home_dir)
72
- @build = load_from('build')
73
- @profiles = load_from('profiles')
74
72
  end
75
73
 
76
74
  # User settings loaded from setting.yaml file in user's home directory.
77
- attr_reader :user
75
+ def user
76
+ @user ||= load_from('settings', @application.home_dir)
77
+ end
78
78
 
79
79
  # Build settings loaded from build.yaml file in build directory.
80
- attr_reader :build
80
+ def build
81
+ @build ||= load_from('build')
82
+ end
81
83
 
82
84
  # Profiles loaded from profiles.yaml file in build directory.
83
- attr_reader :profiles
85
+ def profiles
86
+ @profiles ||= load_from('profiles')
87
+ end
84
88
 
85
89
  # :call-seq:
86
90
  # profile => hash
@@ -92,9 +96,12 @@ module Buildr
92
96
 
93
97
  private
94
98
 
95
- def load_from(base_name, dir = nil)
96
- base_name = File.expand_path(base_name, dir) if dir
97
- file_name = ['yaml', 'yml'].map { |ext| "#{base_name}.#{ext}" }.find { |fn| File.exist?(fn) }
99
+ def load_from(name, path = nil)
100
+ unless path
101
+ fail "Internal error: attempting to access local setting before buildfile located" unless @application.rakefile
102
+ path = File.dirname(@application.rakefile)
103
+ end
104
+ file_name = ['yaml', 'yml'].map { |ext| File.join(path, "#{name}.#{ext}") }.find { |fn| File.exist?(fn) }
98
105
  return {} unless file_name
99
106
  yaml = YAML.load(File.read(file_name)) || {}
100
107
  fail "Expecting #{file_name} to be a map (name: value)!" unless Hash === yaml
@@ -107,28 +114,41 @@ module Buildr
107
114
 
108
115
  class Application < Rake::Application #:nodoc:
109
116
 
117
+ # Deprecated: rakefile/Rakefile, removed in 1.5
110
118
  DEFAULT_BUILDFILES = ['buildfile', 'Buildfile'] + DEFAULT_RAKEFILES
111
119
 
112
- include CommandLineInterface
113
-
114
120
  attr_reader :rakefiles, :requires
115
121
  private :rakefiles, :requires
116
122
 
117
123
  def initialize
118
124
  super
119
- @rakefiles = DEFAULT_BUILDFILES
120
- @name = 'Buildr'
121
- @requires = []
125
+ @rakefiles = DEFAULT_BUILDFILES.dup
122
126
  @top_level_tasks = []
123
- parse_options
124
- collect_tasks
125
127
  @home_dir = File.expand_path('.buildr', ENV['HOME'])
126
128
  mkpath @home_dir, :verbose=>false unless File.exist?(@home_dir)
127
- @environment = ENV['BUILDR_ENV'] ||= 'development'
129
+ @settings = Settings.new(self)
128
130
  @on_completion = []
129
131
  @on_failure = []
130
132
  end
131
133
 
134
+ def run
135
+ standard_exception_handling do
136
+ init 'Buildr'
137
+ load_buildfile
138
+ top_level
139
+ end
140
+ end
141
+
142
+ # Not for external consumption.
143
+ def switch_to_namespace(names) #:nodoc:
144
+ current, @scope = @scope, names
145
+ begin
146
+ yield
147
+ ensure
148
+ @scope = current
149
+ end
150
+ end
151
+
132
152
  # Returns list of Gems associated with this buildfile, as listed in build.yaml.
133
153
  # Each entry is of type Gem::Specification.
134
154
  attr_reader :gems
@@ -137,13 +157,12 @@ module Buildr
137
157
  attr_reader :home_dir
138
158
 
139
159
  # Copied from BUILD_ENV.
140
- attr_reader :environment
160
+ def environment
161
+ ENV['BUILDR_ENV']
162
+ end
141
163
 
142
164
  # Returns the Settings associated with this build.
143
- def settings
144
- fail "Internal error: Called Buildr.settings before buildfile located" unless rakefile
145
- @settings ||= Settings.new(self)
146
- end
165
+ attr_reader :settings
147
166
 
148
167
  # :call-seq:
149
168
  # buildfile
@@ -151,28 +170,13 @@ module Buildr
151
170
  def buildfile
152
171
  @buildfile_task ||= BuildfileTask.define_task(File.expand_path(rakefile))
153
172
  end
154
-
173
+
155
174
  # Files that complement the buildfile itself
156
175
  def build_files #:nodoc:
176
+ deprecated 'Please call buildfile.prerequisites instead'
157
177
  buildfile.prerequisites
158
178
  end
159
179
 
160
- def run
161
- standard_exception_handling do
162
- find_buildfile
163
- load_gems
164
- load_artifacts
165
- load_tasks
166
- load_requires
167
- load_buildfile
168
- load_imports
169
- task('buildr:initialize').invoke
170
- top_level
171
- end
172
- title, message = 'Your build has completed', "#{Dir.pwd}\nbuildr #{@top_level_tasks.join(' ')}"
173
- @on_completion.each { |block| block.call(title, message) rescue nil }
174
- end
175
-
176
180
  # Yields to block on successful completion. Primarily used for notifications.
177
181
  def on_completion(&block)
178
182
  @on_completion << block
@@ -183,16 +187,6 @@ module Buildr
183
187
  @on_failure << block
184
188
  end
185
189
 
186
- # Not for external consumption.
187
- def switch_to_namespace(names) #:nodoc:
188
- current, @scope = @scope, names
189
- begin
190
- yield
191
- ensure
192
- @scope = current
193
- end
194
- end
195
-
196
190
  # :call-seq:
197
191
  # deprecated(message)
198
192
  #
@@ -213,30 +207,206 @@ module Buildr
213
207
  end
214
208
  end
215
209
 
216
- private
217
-
218
- # Returns Gem::Specification for every listed and installed Gem, Gem::Dependency
219
- # for listed and uninstalled Gem, which is the installed before loading the buildfile.
220
- def listed_gems #:nodoc:
221
- Array(settings.build['gems']).map do |dep|
222
- name, trail = dep.scan(/^\s*(\S*)\s*(.*)\s*$/).first
223
- versions = trail.scan(/[=><~!]{0,2}\s*[\d\.]+/)
224
- versions = ['>= 0'] if versions.empty?
225
- dep = Gem::Dependency.new(name, versions)
226
- Gem::SourceIndex.from_installed_gems.search(dep).last || dep
210
+ protected
211
+
212
+ def load_buildfile # replaces load_rakefile
213
+ standard_exception_handling do
214
+ find_buildfile
215
+ load_gems
216
+ load_artifact_ns
217
+ load_tasks
218
+ raw_load_buildfile
227
219
  end
228
220
  end
229
221
 
230
- # Load artifact specs from the build.yaml file, making them available
231
- # by name ( ruby symbols ).
232
- def load_artifacts #:nodoc:
233
- hash = settings.build['artifacts']
234
- return unless hash
235
- raise "Expected 'artifacts' element to be a hash" unless Hash === hash
236
- # Currently we only use one artifact namespace to rule them all. (the root NS)
237
- Buildr::ArtifactNamespace.load(:root => hash)
222
+ def top_level # adds on_completion hook
223
+ standard_exception_handling do
224
+ if options.show_tasks
225
+ display_tasks_and_comments
226
+ elsif options.show_prereqs
227
+ display_prerequisites
228
+ elsif options.execute
229
+ eval options.execute
230
+ else
231
+ @start = Time.now
232
+ top_level_tasks.each { |task_name| invoke_task(task_name) }
233
+ if verbose
234
+ elapsed = Time.now - @start
235
+ real = []
236
+ real << ('%ih' % (elapsed / 3600)) if elapsed >= 3600
237
+ real << ('%im' % ((elapsed / 60) % 60)) if elapsed >= 60
238
+ real << ('%.3fs' % (elapsed % 60))
239
+ puts $terminal.color("Completed in #{real.join}", :green)
240
+ end
241
+ # On OS X this will load Cocoa and Growl which takes half a second we
242
+ # don't want to measure, so put this after the console message.
243
+ title, message = "Your build has completed", "#{Dir.pwd}\nbuildr #{@top_level_tasks.join(' ')}"
244
+ @on_completion.each do |block|
245
+ block.call(title, message) rescue nil
246
+ end
247
+ end
248
+ end
238
249
  end
250
+
251
+ def handle_options
252
+ options.rakelib = ['tasks']
253
+
254
+ opts = OptionParser.new
255
+ opts.banner = "buildr [-f rakefile] {options} targets..."
256
+ opts.separator ""
257
+ opts.separator "Options are ..."
239
258
 
259
+ opts.on_tail("-h", "--help", "-H", "Display this help message.") do
260
+ puts opts
261
+ exit
262
+ end
263
+
264
+ standard_buildr_options.each { |args| opts.on(*args) }
265
+ parsed_argv = opts.parse(ARGV)
266
+ parsed_argv
267
+ end
268
+
269
+ def standard_buildr_options # replaces standard_rake_options
270
+ [
271
+ ['--describe', '-D [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
272
+ lambda { |value|
273
+ options.show_tasks = true
274
+ options.full_description = true
275
+ options.show_task_pattern = Regexp.new(value || '')
276
+ }
277
+ ],
278
+ ['--execute', '-E CODE',
279
+ "Execute some Ruby code after loading the buildfile",
280
+ lambda { |value| options.execute = value }
281
+ ],
282
+ ['--environment', '-e ENV',
283
+ "Environment name (e.g. development, test, production).",
284
+ lambda { |value| ENV['BUILDR_ENV'] = value }
285
+ ],
286
+ ['--generate [PATH]',
287
+ "Generate buildfile from either pom.xml file or directory path.",
288
+ lambda { |value|
289
+ value ||= File.exist?('pom.xml') ? 'pom.xml' : Dir.pwd
290
+ raw_generate_buildfile value
291
+ exit
292
+ }
293
+ ],
294
+ ['--libdir', '-I LIBDIR', "Include LIBDIR in the search path for required modules.",
295
+ lambda { |value| $:.push(value) }
296
+ ],
297
+ ['--prereqs', '-P [PATTERN]', "Display the tasks and dependencies (matching optional PATTERN), then exit.",
298
+ lambda { |value|
299
+ options.show_prereqs = true
300
+ options.show_task_pattern = Regexp.new(value || '')
301
+ }
302
+ ],
303
+ ['--quiet', '-q', "Do not log messages to standard output.",
304
+ lambda { |value| verbose(false) }
305
+ ],
306
+ ['--buildfile', '-f FILE', "Use FILE as the buildfile.",
307
+ lambda { |value|
308
+ @rakefiles.clear
309
+ @rakefiles << value
310
+ }
311
+ ],
312
+ ['--rakelibdir', '--rakelib', '-R PATH',
313
+ "Auto-import any .rake files in PATH. (default is 'tasks')",
314
+ lambda { |value| options.rakelib = value.split(':') }
315
+ ],
316
+ ['--require', '-r MODULE', "Require MODULE before executing rakefile.",
317
+ lambda { |value|
318
+ begin
319
+ require value
320
+ rescue LoadError => ex
321
+ begin
322
+ rake_require value
323
+ rescue LoadError => ex2
324
+ raise ex
325
+ end
326
+ end
327
+ }
328
+ ],
329
+ ['--rules', "Trace the rules resolution.",
330
+ lambda { |value| options.trace_rules = true }
331
+ ],
332
+ ['--no-search', '--nosearch', '-N', "Do not search parent directories for the Rakefile.",
333
+ lambda { |value| options.nosearch = true }
334
+ ],
335
+ ['--silent', '-s', "Like --quiet, but also suppresses the 'in directory' announcement.",
336
+ lambda { |value|
337
+ verbose(false)
338
+ options.silent = true
339
+ }
340
+ ],
341
+ ['--tasks', '-T [PATTERN]', "Display the tasks (matching optional PATTERN) with descriptions, then exit.",
342
+ lambda { |value|
343
+ options.show_tasks = true
344
+ options.show_task_pattern = Regexp.new(value || '')
345
+ options.full_description = false
346
+ }
347
+ ],
348
+ ['--trace', '-t', "Turn on invoke/execute tracing, enable full backtrace.",
349
+ lambda { |value|
350
+ options.trace = true
351
+ verbose(true)
352
+ }
353
+ ],
354
+ ['--verbose', '-v', "Log message to standard output (default).",
355
+ lambda { |value| verbose(true) }
356
+ ],
357
+ ['--version', '-V', "Display the program version.",
358
+ lambda { |value|
359
+ puts "Buildr #{Buildr::VERSION} #{RUBY_PLATFORM[/java/] && '(JRuby '+JRUBY_VERSION+')'}"
360
+ exit
361
+ }
362
+ ]
363
+ ]
364
+ end
365
+
366
+ def find_buildfile
367
+ buildfile, location = find_rakefile_location || (tty_output? && ask_generate_buildfile)
368
+ fail "No Buildfile found (looking for: #{@rakefiles.join(', ')})" if buildfile.nil?
369
+ @rakefile = buildfile
370
+ Dir.chdir(location)
371
+ end
372
+
373
+ def ask_generate_buildfile
374
+ source = choose do |menu|
375
+ menu.header = "To use Buildr you need a buildfile. Do you want me to create one?"
376
+ menu.choice("From Maven2 POM file") { 'pom.xml' } if File.exist?('pom.xml')
377
+ menu.choice("From directory structure") { Dir.pwd }
378
+ menu.choice("Cancel") { }
379
+ end
380
+ if source
381
+ buildfile = raw_generate_buildfile(source)
382
+ [buildfile, File.dirname(buildfile)]
383
+ end
384
+ end
385
+
386
+ def raw_generate_buildfile(source)
387
+ # We need rakefile to be known, for settings.build to be accessible.
388
+ @rakefile = File.expand_path(DEFAULT_BUILDFILES.first)
389
+ fail "Buildfile already exists" if File.exist?(@rakefile) && !(tty_output? && agree('Buildfile exists, overwrite?'))
390
+ script = File.directory?(source) ? Generate.from_directory(source) : Generate.from_maven2_pom(source)
391
+ File.open @rakefile, 'w' do |file|
392
+ file.puts script
393
+ end
394
+ puts "Created #{@rakefile}" if verbose
395
+ @rakefile
396
+ end
397
+
398
+ def raw_load_buildfile # replaces raw_load_rakefile
399
+ puts "(in #{Dir.pwd}, #{environment})" unless options.silent
400
+ load File.expand_path(@rakefile) if @rakefile && @rakefile != ''
401
+ options.rakelib.each do |rlib|
402
+ glob("#{rlib}/*.rake") do |name|
403
+ add_import name
404
+ end
405
+ end
406
+ load_imports
407
+ Buildr.projects
408
+ end
409
+
240
410
  # Load/install all Gems specified in build.yaml file.
241
411
  def load_gems #:nodoc:
242
412
  missing_deps, installed = listed_gems.partition { |gem| gem.is_a?(Gem::Dependency) }
@@ -259,42 +429,37 @@ module Buildr
259
429
  @gems = installed
260
430
  end
261
431
 
262
- def find_buildfile #:nodoc:
263
- here = original_dir
264
- Dir.chdir(here) unless Dir.pwd == here
265
- while ! have_rakefile
266
- Dir.chdir('..')
267
- if Dir.pwd == here || options.nosearch
268
- error = "No Buildfile found (looking for: #{@rakefiles.join(', ')})"
269
- if STDIN.isatty
270
- chdir(original_dir) { task('generate').invoke }
271
- exit 1
272
- else
273
- raise error
274
- end
275
- end
276
- here = Dir.pwd
432
+ # Returns Gem::Specification for every listed and installed Gem, Gem::Dependency
433
+ # for listed and uninstalled Gem, which is the installed before loading the buildfile.
434
+ def listed_gems #:nodoc:
435
+ Array(settings.build['gems']).map do |dep|
436
+ name, trail = dep.scan(/^\s*(\S*)\s*(.*)\s*$/).first
437
+ versions = trail.scan(/[=><~!]{0,2}\s*[\d\.]+/)
438
+ versions = ['>= 0'] if versions.empty?
439
+ dep = Gem::Dependency.new(name, versions)
440
+ Gem::SourceIndex.from_installed_gems.search(dep).last || dep
277
441
  end
278
442
  end
279
443
 
280
- def load_buildfile #:nodoc:
281
- info "(in #{Dir.pwd}, #{environment})"
282
- load File.expand_path(@rakefile) if @rakefile != ''
283
- buildfile.enhance @requires.select { |f| File.file?(f) }.map{ |f| File.expand_path(f) }
284
- end
285
-
286
- def load_requires #:nodoc:
287
- @requires.each { |name| require name }
444
+ # Load artifact specs from the build.yaml file, making them available
445
+ # by name ( ruby symbols ).
446
+ def load_artifact_ns #:nodoc:
447
+ hash = settings.build['artifacts']
448
+ return unless hash
449
+ raise "Expected 'artifacts' element to be a hash" unless Hash === hash
450
+ # Currently we only use one artifact namespace to rule them all. (the root NS)
451
+ Buildr::ArtifactNamespace.load(:root => hash)
288
452
  end
289
-
453
+
290
454
  # Loads buildr.rb files from users home directory and project directory.
291
455
  # Loads custom tasks from .rake files in tasks directory.
292
456
  def load_tasks #:nodoc:
457
+ # TODO: this might need to be split up, look for deprecated features, better method name.
293
458
  files = [ File.expand_path('buildr.rb', ENV['HOME']), 'buildr.rb' ].select { |file| File.exist?(file) }
294
459
  files += [ File.expand_path('buildr.rake', ENV['HOME']), File.expand_path('buildr.rake') ].
295
460
  select { |file| File.exist?(file) }.each { |file| warn "Please use '#{file.ext('rb')}' instead of '#{file}'" }
296
461
  #Load local tasks that can be used in the Buildfile.
297
- files += Dir[File.expand_path('tasks/*.rake', original_dir)]
462
+ files += Dir[File.expand_path('tasks/*.rake')]
298
463
  files.each do |file|
299
464
  unless $LOADED_FEATURES.include?(file)
300
465
  load file
@@ -305,42 +470,61 @@ module Buildr
305
470
  true
306
471
  end
307
472
 
308
- def display_prerequisites
309
- invoke_task('buildr:initialize')
310
- tasks.each do |task|
311
- if task.name =~ options.show_task_pattern
312
- puts "buildr #{task.name}"
313
- task.prerequisites.each { |prereq| puts " #{prereq}" }
473
+ def display_tasks_and_comments
474
+ displayable_tasks = tasks.select { |t| t.comment && t.name =~ options.show_task_pattern }
475
+ if options.full_description
476
+ displayable_tasks.each do |t|
477
+ puts "buildr #{t.name_with_args}"
478
+ t.full_comment.split("\n").each do |line|
479
+ puts " #{line}"
480
+ end
481
+ puts
482
+ end
483
+ else
484
+ width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10
485
+ max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil
486
+ displayable_tasks.each do |t|
487
+ printf "#{name} %-#{width}s # %s\n",
488
+ t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment
314
489
  end
315
490
  end
316
491
  end
317
-
318
- # Provide standard execption handling for the given block.
319
- def standard_exception_handling
492
+
493
+ def display_prerequisites
494
+ displayable_tasks = tasks.select { |t| t.name =~ options.show_task_pattern }
495
+ displayable_tasks.each do |t|
496
+ puts "buildr #{t.name}"
497
+ t.prerequisites.each { |pre| puts " #{pre}" }
498
+ end
499
+ end
500
+
501
+ def standard_exception_handling # adds on_failure hook
320
502
  begin
321
503
  yield
322
504
  rescue SystemExit => ex
323
505
  # Exit silently with current status
324
506
  exit(ex.status)
325
- rescue SystemExit, GetoptLong::InvalidOption => ex
326
- # Exit silently
507
+ rescue OptionParser::ParseError => ex
508
+ $stderr.puts $terminal.color(ex.message, :red)
327
509
  exit(1)
328
510
  rescue Exception => ex
329
- title, message = 'Your build failed with an error', "#{Dir.pwd}:\n#{ex.message}"
330
- @on_failure.each { |block| block.call(title, message, ex) rescue nil }
511
+ title, message = "Your build failed with an error", "#{Dir.pwd}:\n#{ex.message}"
512
+ @on_failure.each do |block|
513
+ block.call(title, message, ex) rescue nil
514
+ end
331
515
  # Exit with error message
332
- $stderr.puts "buildr aborted!"
516
+ $stderr.puts "Buildr aborted!"
333
517
  $stderr.puts $terminal.color(ex.message, :red)
334
518
  if options.trace
335
519
  $stderr.puts ex.backtrace.join("\n")
336
520
  else
337
- $stderr.puts ex.backtrace.select { |str| str =~ /#{buildfile}/ }.map { |line| $terminal.color(line, :red) }.join("\n")
521
+ $stderr.puts ex.backtrace.select { |str| str =~ /#{rakefile}/ }.map { |line| $terminal.color(line, :red) }.join("\n") if rakefile
338
522
  $stderr.puts "(See full trace by running task with --trace)"
339
523
  end
340
524
  exit(1)
341
525
  end
342
526
  end
343
-
527
+
344
528
  end
345
529
 
346
530
 
@@ -357,10 +541,6 @@ module Buildr
357
541
 
358
542
  class << self
359
543
 
360
- task 'buildr:initialize' do
361
- Buildr.load_tasks_and_local_files
362
- end
363
-
364
544
  # Returns the Buildr::Application object.
365
545
  def application
366
546
  Rake.application
@@ -399,38 +579,6 @@ else
399
579
  end
400
580
 
401
581
 
402
- # Let's see if we can use Growl. We do this at the very end, loading Ruby Cocoa
403
- # could slow the build down, so later is better. We only do this when running
404
- # from the console in verbose mode.
405
- if $stdout.isatty && verbose && RUBY_PLATFORM =~ /darwin/
406
- begin
407
- require 'osx/cocoa'
408
- icon = OSX::NSApplication.sharedApplication.applicationIconImage
409
- icon = OSX::NSImage.alloc.initWithContentsOfFile(File.join(File.dirname(__FILE__), '../resources/buildr.icns'))
410
-
411
- # Register with Growl, that way you can turn notifications on/off from system preferences.
412
- OSX::NSDistributedNotificationCenter.defaultCenter.
413
- postNotificationName_object_userInfo_deliverImmediately(:GrowlApplicationRegistrationNotification, nil,
414
- { :ApplicationName=>'Buildr', :AllNotifications=>['Completed', 'Failed'],
415
- :ApplicationIcon=>icon.TIFFRepresentation }, true)
416
-
417
- notify = lambda do |type, title, message|
418
- OSX::NSDistributedNotificationCenter.defaultCenter.
419
- postNotificationName_object_userInfo_deliverImmediately(:GrowlNotification, nil,
420
- { :ApplicationName=>'Buildr', :NotificationName=>type,
421
- :NotificationTitle=>title, :NotificationDescription=>message }, true)
422
- end
423
- Buildr.application.on_completion { |title, message| notify['Completed', title, message] }
424
- Buildr.application.on_failure { |title, message, ex| notify['Failed', title, message] }
425
- rescue Exception # No growl
426
- end
427
- elsif $stdout.isatty && verbose
428
- notify = lambda { |type, title, message| $stdout.puts "[#{type}] #{title}: #{message}" }
429
- Buildr.application.on_completion { |title, message| notify['Completed', title, message] }
430
- Buildr.application.on_failure { |title, message, ex| notify['Failed', title, message] }
431
- end
432
-
433
-
434
582
  alias :warn_without_color :warn
435
583
 
436
584
  # Show warning message.
@@ -457,6 +605,13 @@ end
457
605
 
458
606
 
459
607
  module Rake #:nodoc
608
+ # Rake's circular dependency checks (InvocationChain) only applies to task prerequisites,
609
+ # all other cases result in the non too-descriptive thread sleeping error. This change can
610
+ # deal with circular dependencies that occur from direct task invocation, e.g:
611
+ # task 'foo'=>'bar'
612
+ # task 'bar' do
613
+ # task('foo').invoke
614
+ # end
460
615
  class Task #:nodoc:
461
616
  def invoke(*args)
462
617
  task_args = TaskArguments.new(arg_names, args)
@@ -486,4 +641,4 @@ module Rake #:nodoc
486
641
  end
487
642
  end
488
643
  end
489
- end
644
+ end