buildr 1.3.5 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. data/CHANGELOG +153 -8
  2. data/README.rdoc +1 -1
  3. data/addon/buildr/antlr.rb +5 -5
  4. data/addon/buildr/drb.rb +18 -18
  5. data/addon/buildr/hibernate.rb +18 -14
  6. data/addon/buildr/javacc.rb +4 -4
  7. data/addon/buildr/jetty.rb +5 -5
  8. data/addon/buildr/nailgun.rb +23 -23
  9. data/addon/buildr/openjpa.rb +1 -1
  10. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  11. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  12. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  13. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  14. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  15. data/addon/buildr/protobuf.rb +75 -0
  16. data/addon/buildr/xmlbeans.rb +5 -5
  17. data/buildr.buildfile +2 -2
  18. data/buildr.gemspec +8 -7
  19. data/doc/_layouts/default.html +2 -2
  20. data/doc/artifacts.textile +4 -4
  21. data/doc/building.textile +35 -3
  22. data/doc/contributing.textile +5 -0
  23. data/doc/download.textile +16 -5
  24. data/doc/extending.textile +38 -12
  25. data/doc/installing.textile +6 -5
  26. data/doc/languages.textile +182 -42
  27. data/doc/more_stuff.textile +2 -2
  28. data/doc/packaging.textile +14 -15
  29. data/doc/projects.textile +7 -2
  30. data/doc/quick_start.textile +4 -4
  31. data/doc/scripts/buildr-git.rb +63 -63
  32. data/doc/scripts/gitflow.rb +21 -21
  33. data/doc/settings_profiles.textile +9 -2
  34. data/doc/testing.textile +16 -5
  35. data/etc/KEYS +38 -0
  36. data/lib/buildr/core/application.rb +33 -27
  37. data/lib/buildr/core/build.rb +41 -28
  38. data/lib/buildr/core/cc.rb +172 -0
  39. data/lib/buildr/core/checks.rb +1 -1
  40. data/lib/buildr/core/common.rb +7 -6
  41. data/lib/buildr/core/compile.rb +7 -8
  42. data/lib/buildr/core/doc.rb +263 -0
  43. data/lib/buildr/core/environment.rb +6 -6
  44. data/lib/buildr/core/filter.rb +77 -35
  45. data/lib/buildr/core/generate.rb +7 -7
  46. data/lib/buildr/core/help.rb +1 -1
  47. data/lib/buildr/core/osx.rb +6 -6
  48. data/lib/buildr/core/progressbar.rb +4 -4
  49. data/lib/buildr/core/project.rb +144 -36
  50. data/lib/buildr/core/shell.rb +34 -34
  51. data/lib/buildr/core/test.rb +89 -20
  52. data/lib/buildr/core/transports.rb +8 -7
  53. data/lib/buildr/core/util.rb +77 -23
  54. data/lib/buildr/core.rb +1 -0
  55. data/lib/buildr/groovy/bdd.rb +5 -5
  56. data/lib/buildr/groovy/compiler.rb +19 -15
  57. data/lib/buildr/groovy/shell.rb +6 -6
  58. data/lib/buildr/ide/eclipse/java.rb +3 -3
  59. data/lib/buildr/ide/eclipse/plugin.rb +8 -5
  60. data/lib/buildr/ide/eclipse/scala.rb +4 -2
  61. data/lib/buildr/ide/eclipse.rb +148 -75
  62. data/lib/buildr/ide/idea.rb +2 -2
  63. data/lib/buildr/ide/idea7x.rb +23 -4
  64. data/lib/buildr/java/ant.rb +4 -4
  65. data/lib/buildr/java/bdd.rb +51 -54
  66. data/lib/buildr/java/cobertura.rb +57 -35
  67. data/lib/buildr/java/commands.rb +14 -5
  68. data/lib/buildr/java/compiler.rb +3 -217
  69. data/lib/buildr/java/deprecated.rb +4 -4
  70. data/lib/buildr/java/doc.rb +70 -0
  71. data/lib/buildr/java/emma.rb +22 -22
  72. data/lib/buildr/java/jruby.rb +4 -4
  73. data/lib/buildr/java/jtestr_runner.rb.erb +27 -25
  74. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  75. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +8 -3
  76. data/lib/buildr/java/packaging.rb +30 -29
  77. data/lib/buildr/java/pom.rb +4 -4
  78. data/lib/buildr/java/rjb.rb +6 -6
  79. data/lib/buildr/java/test_result.rb +61 -85
  80. data/lib/buildr/java/tests.rb +44 -27
  81. data/lib/buildr/java/version_requirement.rb +8 -8
  82. data/lib/buildr/java.rb +1 -0
  83. data/lib/buildr/packaging/archive.rb +55 -22
  84. data/lib/buildr/packaging/artifact.rb +75 -36
  85. data/lib/buildr/packaging/artifact_namespace.rb +90 -78
  86. data/lib/buildr/packaging/artifact_search.rb +5 -5
  87. data/lib/buildr/packaging/gems.rb +11 -7
  88. data/lib/buildr/packaging/package.rb +10 -7
  89. data/lib/buildr/packaging/tar.rb +14 -14
  90. data/lib/buildr/packaging/version_requirement.rb +30 -10
  91. data/lib/buildr/packaging/ziptask.rb +51 -13
  92. data/lib/buildr/scala/bdd.rb +25 -20
  93. data/lib/buildr/scala/compiler.rb +87 -40
  94. data/lib/buildr/scala/doc.rb +106 -0
  95. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  96. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
  97. data/lib/buildr/scala/shell.rb +14 -9
  98. data/lib/buildr/scala/tests.rb +33 -26
  99. data/lib/buildr/scala.rb +1 -0
  100. data/lib/buildr/shell.rb +33 -33
  101. data/lib/buildr.rb +1 -1
  102. data/rakelib/all-in-one.rake +113 -0
  103. data/rakelib/checks.rake +1 -1
  104. data/rakelib/doc.rake +7 -0
  105. data/rakelib/package.rake +1 -1
  106. data/rakelib/release.rake +9 -6
  107. data/rakelib/rspec.rake +26 -7
  108. data/rakelib/setup.rake +15 -3
  109. data/rakelib/stage.rake +18 -11
  110. data/spec/addon/drb_spec.rb +25 -25
  111. data/spec/core/application_spec.rb +111 -21
  112. data/spec/core/build_spec.rb +16 -15
  113. data/spec/core/cc_spec.rb +174 -0
  114. data/spec/core/checks_spec.rb +34 -34
  115. data/spec/core/common_spec.rb +51 -5
  116. data/spec/core/compile_spec.rb +89 -14
  117. data/spec/core/extension_spec.rb +127 -19
  118. data/spec/core/generate_spec.rb +2 -2
  119. data/spec/core/project_spec.rb +10 -10
  120. data/spec/core/test_spec.rb +144 -35
  121. data/spec/core/transport_spec.rb +8 -8
  122. data/spec/core/util_spec.rb +63 -5
  123. data/spec/groovy/bdd_spec.rb +5 -5
  124. data/spec/groovy/compiler_spec.rb +29 -18
  125. data/spec/ide/eclipse_spec.rb +185 -9
  126. data/spec/ide/idea7x_spec.rb +22 -10
  127. data/spec/java/ant_spec.rb +9 -5
  128. data/spec/java/bdd_spec.rb +29 -37
  129. data/spec/java/cobertura_spec.rb +12 -12
  130. data/spec/java/commands_spec.rb +34 -0
  131. data/spec/java/compiler_spec.rb +53 -53
  132. data/spec/java/emma_spec.rb +11 -11
  133. data/spec/java/java_spec.rb +10 -10
  134. data/spec/java/packaging_spec.rb +67 -20
  135. data/spec/java/test_coverage_helper.rb +18 -18
  136. data/spec/java/tests_spec.rb +13 -9
  137. data/spec/packaging/archive_spec.rb +187 -20
  138. data/spec/packaging/artifact_namespace_spec.rb +172 -83
  139. data/spec/packaging/artifact_spec.rb +83 -18
  140. data/spec/packaging/packaging_spec.rb +41 -14
  141. data/spec/sandbox.rb +23 -12
  142. data/spec/scala/bdd_spec.rb +13 -8
  143. data/spec/scala/compiler_spec.rb +18 -13
  144. data/spec/scala/scala.rb +3 -3
  145. data/spec/scala/tests_spec.rb +46 -24
  146. data/spec/spec_helpers.rb +28 -10
  147. data/spec/version_requirement_spec.rb +25 -11
  148. metadata +149 -133
  149. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  150. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +0 -35
  151. data/rakelib/stage.rake~ +0 -213
@@ -0,0 +1,75 @@
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
+ module Buildr
18
+ # Provides Protocol buffer code generation tasks. Require explicitly using <code>require "buildr/protobuf"</code>.
19
+ module Protobuf
20
+ class << self
21
+ def protoc(*args)
22
+ options = Hash === args.last ? args.pop : {}
23
+ rake_check_options options, :output, :lang, :include
24
+
25
+ options[:lang] ||= :java
26
+ options[:output] ||= File.expand_path "target/generated/protoc"
27
+ options[:include] ||= []
28
+
29
+ command_line = []
30
+
31
+ command_line << "--#{options[:lang]}_out=#{options[:output]}" if options[:output]
32
+
33
+ (paths_from_sources(*args) + options[:include]).each { |i| command_line << "-I#{i}" }
34
+
35
+ command_line += files_from_sources(*args)
36
+
37
+ mkdir_p( options[:output] )
38
+
39
+ system protoc_path, *command_line
40
+ end
41
+
42
+ def protoc_path
43
+ ENV['PROTOC'] || "protoc"
44
+ end
45
+
46
+ def files_from_sources(*args)
47
+ args.flatten.map(&:to_s).collect { |f| File.directory?(f) ? FileList[f + "/**/*.proto"] : f }.flatten
48
+ end
49
+
50
+ def paths_from_sources(*args)
51
+ args.flatten.map(&:to_s).collect { |f| File.directory?(f) ? f : File.dirname(f) }
52
+ end
53
+ end
54
+
55
+ def protoc(*args)
56
+ if Hash === args.last
57
+ options = args.pop
58
+ else
59
+ options = {}
60
+ end
61
+
62
+ options[:output] ||= path_to(:target, :generated, :protoc)
63
+ options[:lang] ||= compile.language if compile.language
64
+
65
+ file(options[:output]=>Protobuf.files_from_sources(*args)) do |task|
66
+ Protobuf.protoc task.prerequisites, options
67
+ end
68
+ end
69
+
70
+ end
71
+
72
+ class Project
73
+ include Protobuf
74
+ end
75
+ end
@@ -23,12 +23,12 @@ module Buildr
23
23
  # Provides XMLBeans schema compiler. Require explicitly using <code>require "buildr/xmlbeans"</code>.
24
24
  #
25
25
  # require 'buildr/xmlbeans'
26
- # define 'some_proj' do
26
+ # define 'some_proj' do
27
27
  # compile_xml_beans _(:source, :main, :xsd) # the directory with *.xsd
28
28
  # end
29
29
  module XMLBeans
30
30
 
31
- # You can use ArtifactNamespace to customize the versions of
31
+ # You can use ArtifactNamespace to customize the versions of
32
32
  # <code>:xmlbeans</code> or <code>:stax</code> used by this module:
33
33
  #
34
34
  # require 'buildr/xmlbeans'
@@ -37,7 +37,7 @@ module Buildr
37
37
  ns.xmlbeans! 'org.apache.xmlbeans:xmlbeans:jar:2.3.0', '>2'
38
38
  ns.stax_api! 'stax:stax-api:jar:>=1.0.1'
39
39
  end
40
-
40
+
41
41
  class << self
42
42
 
43
43
  def compile(*args)
@@ -48,7 +48,7 @@ module Buildr
48
48
  Buildr.ant "xmlbeans" do |ant|
49
49
  ant.taskdef :name=>"xmlbeans", :classname=>"org.apache.xmlbeans.impl.tool.XMLBean",
50
50
  :classpath=>requires.join(File::PATH_SEPARATOR)
51
- ant.xmlbeans :srconly=>"true", :srcgendir=>options[:output].to_s, :classgendir=>options[:output].to_s,
51
+ ant.xmlbeans :srconly=>"true", :srcgendir=>options[:output].to_s, :classgendir=>options[:output].to_s,
52
52
  :javasource=>options[:javasource] do
53
53
  args.flatten.each { |file| ant.fileset File.directory?(file) ? { :dir=>file } : { :file=>file } }
54
54
  end
@@ -58,7 +58,7 @@ module Buildr
58
58
  end
59
59
 
60
60
  def requires()
61
- @requires ||= REQUIRES.artifacts.each(&:invoke).map(&:to_s)
61
+ @requires ||= REQUIRES.artifacts
62
62
  end
63
63
  end
64
64
 
data/buildr.buildfile CHANGED
@@ -22,14 +22,14 @@ repositories.remote << 'http://scala-tools.org/repo-releases/'
22
22
 
23
23
 
24
24
  define 'buildr' do
25
- compile.using :source=>'1.4', :target=>'1.4', :debug=>false
25
+ compile.using :source=>'1.5', :target=>'1.5', :debug=>false
26
26
 
27
27
  define 'java' do
28
28
  compile.using(:javac).from(FileList['lib/buildr/java/**/*.java']).into('lib/buildr/java')
29
29
  end
30
30
 
31
31
  define 'scala' do
32
- compile.using(:scalac).from(FileList['lib/buildr/scala/**/*.scala']).into('lib/buildr/scala')
32
+ compile.using(:javac).from(FileList['lib/buildr/scala/**/*.java']).into('lib/buildr/scala')
33
33
  end
34
34
 
35
35
  desc 'Buildr extra packages (Antlr, Cobertura, Hibernate, Javacc, JDepend, Jetty, OpenJPA, XmlBeans)'
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.5'
19
+ spec.version = '1.4.0'
20
20
  spec.author = 'Apache Buildr'
21
21
  spec.email = "users@buildr.apache.org"
22
22
  spec.homepage = "http://buildr.apache.org/"
23
- spec.summary = "A build system that doesn't suck"
23
+ spec.summary = "Build like you code"
24
24
  spec.description = <<-TEXT
25
25
  Apache Buildr is a build system for Java-based applications, including support
26
26
  for Scala, Groovy and a growing number of JVM languages and tools. We wanted
@@ -33,7 +33,7 @@ for those one-off tasks, with a language that's a joy to use.
33
33
  # Rakefile needs to create spec for both platforms (ruby and java), using the
34
34
  # $platform global variable. In all other cases, we figure it out from RUBY_PLATFORM.
35
35
  spec.platform = $platform || RUBY_PLATFORM[/java/] || 'ruby'
36
-
36
+
37
37
  spec.files = Dir['{addon,bin,doc,etc,lib,rakelib,spec}/**/*', '*.{gemspec,buildfile}'] +
38
38
  ['LICENSE', 'NOTICE', 'CHANGELOG', 'README.rdoc', 'Rakefile', '_buildr', '_jbuildr']
39
39
  spec.require_paths = 'lib', 'addon'
@@ -53,12 +53,13 @@ for those one-off tasks, with a language that's a joy to use.
53
53
  spec.add_dependency 'net-sftp', '2.0.2'
54
54
  spec.add_dependency 'rubyzip', '0.9.1'
55
55
  spec.add_dependency 'highline', '1.5.1'
56
- spec.add_dependency 'rubyforge', '1.0.5'
56
+ spec.add_dependency 'json_pure', '1.4.0'
57
+ spec.add_dependency 'rubyforge', '2.0.3'
57
58
  spec.add_dependency 'hoe', '2.3.3'
58
- spec.add_dependency 'rjb', '1.1.9' if spec.platform.to_s == 'ruby'
59
- spec.add_dependency 'rjb', '1.1.6' if spec.platform.to_s == 'x86-mswin32'
59
+ spec.add_dependency 'rjb', '1.2.5' if spec.platform.to_s == 'ruby'
60
+ spec.add_dependency 'rjb', '1.2.5' if spec.platform.to_s == 'x86-mswin32'
60
61
  spec.add_dependency 'Antwrap', '0.7.0'
61
- spec.add_dependency 'rspec', '1.2.8'
62
+ spec.add_dependency 'rspec', '>= 1.2.9'
62
63
  spec.add_dependency 'xml-simple', '1.0.12'
63
64
  spec.add_dependency 'archive-tar-minitar', '0.5.2'
64
65
  spec.add_dependency 'jruby-openssl', '0.5.2' if spec.platform.to_s == 'java'
@@ -15,8 +15,8 @@
15
15
  <body>
16
16
  <div id='wrap'>
17
17
  <div id='header'>
18
- <a href='http://buildr.apache.org/' title="The build system that doesn't suck"><img alt='buildr' src='images/buildr.png'></a>
19
- <div class='tagline'>The build system that doesn't suck</div>
18
+ <a href='http://buildr.apache.org/' title="Build like you code"><img alt='buildr' src='images/buildr.png'></a>
19
+ <div class='tagline'>Build like you code</div>
20
20
  </div>
21
21
  <div id='pages'>
22
22
  <ol class='toc'>
@@ -52,7 +52,7 @@ p(note). Buildr projects also define a @group@ attribute which can lead to some
52
52
  If you have several artifacts you always use together, consider placing them in an array. Methods that accept lists of artifacts also accept arrays. For example:
53
53
 
54
54
  {% highlight ruby %}
55
- OPENJPA = ['org.apache.openjpa:openjpa-all:jar:0.9.7',
55
+ OPENJPA = ['org.apache.openjpa:openjpa:jar:1.2.1',
56
56
  'net.sourceforge.serp:serp:jar:1.12.0']
57
57
  AXIS_OF_WS = [AXIS2, AXIOM]
58
58
 
@@ -125,7 +125,7 @@ You can choose to relocate the local repository by giving it a different path, f
125
125
  repositories.local = '/usr/local/maven/repository'
126
126
  {% endhighlight %}
127
127
 
128
- That's one change you don't want to commit into the Buildfile, so the best place to do it is in your home directory's @buildr.rb@ file.
128
+ That's one change you don't want to commit into the Buildfile, so the best place to do it is in the @buildr.rb@ file in the @.buildr@ directory under your home directory.
129
129
 
130
130
  Buildr downloads artifacts when it needs to use them, for example, to compile a project. You don't need to download artifacts directly. Except when you do, for example, if you want to download all the latest artifacts and then go off-line. It's as simple as:
131
131
 
@@ -139,7 +139,7 @@ h2(#downloading). Downloading Artifacts
139
139
  Within your buildfile you can download artifacts directly by invoking them, for example:
140
140
 
141
141
  {% highlight ruby %}
142
- artifact('org.apache.openjpa:openjpa-all:jar:0.9.7').invoke
142
+ artifact('org.apache.openjpa:openjpa:jar:1.2.1').invoke
143
143
  artifacts(OPENJPA).each(&:invoke)
144
144
  {% endhighlight %}
145
145
 
@@ -208,4 +208,4 @@ upload bean
208
208
  p(tip). Calling the @install@ (and likewise @upload@) method on an artifact run @buildr install@. If you need to download and install an artifact, invoke the task directly with @install(<artifact>).invoke@.
209
209
 
210
210
 
211
- Next we're going to "package some artifacts":packaging.html.
211
+ We'll talk more about installing and uploading in the next chapter, but right now we're going to "package some artifacts":packaging.html.
data/doc/building.textile CHANGED
@@ -25,7 +25,7 @@ Buildr uses file tasks to handle dependencies, but here we're talking about the
25
25
 
26
26
  An easier way to specify dependencies is by calling the @compile.with@ method. It takes a list of arguments and adds them to the dependency list. The @compile.with@ method is easier to use, it accepts several type of dependencies. You can use file names, file tasks, projects, artifacts specifications and even pass arrays of dependencies.
27
27
 
28
- Most dependencies fall into the last three categories. When you pass a project to @compile.with@, it picks up all the packages created by that project. In doing so, it establishes an order of dependency between the two projects (see "Defining the Project":projects.html#defining). For example, if you make a change in project _teh-api_ and build _teh-impl_, Buildr will detect that change, recompile and package _teh-api_ before compiling _teh-impl_. You can also select a specific package using the @package@ or @packages@ methods (see "Packaging":packaging.html).
28
+ Most dependencies fall into the last three categories. When you pass a project to @compile.with@, it picks up all the packages created by that project. In doing so, it establishes an order of dependency between the two projects (see "Defining the Project":projects.html#defining). For example, if you make a change in project _teh-api_ and build _teh-impl_, Buildr will detect that change, recompile and package _teh-api_ before compiling _teh-impl_. You can also select a specific package using the project's @package@ or @packages@ methods (see "Packaging":packaging.html).
29
29
 
30
30
  When you pass an artifact specification to @compile.with@, it creates an @Artifact@ task that will download that artifact from one of the remote repositories, install it in the local repository, and use it in your project. Rake's dependency mechanism is used here to make sure the artifact is downloaded once, when needed. Check the "Artifacts":artifacts.html section for more information about artifact specification and repositories.
31
31
 
@@ -115,7 +115,7 @@ The default source and target directories, compiler settings and other options y
115
115
  h2(#resources). Resources
116
116
 
117
117
 
118
- The @compile@ task comes bundled with a @resources@ task. It copies files from the @src/main/resources@ directory into @target/resources@. Best used for copying files that you want to included in the generated code, like configuration files, i18n messages, images, etc.
118
+ The @compile@ task comes bundled with a @resources@ task. It copies files from the @src/main/resources@ directory into @target/resources@. Best used for copying files that you want to include in the generated code, like configuration files, i18n messages, images, etc.
119
119
 
120
120
  The @resources@ task uses a filter that can change files as it copies them from source to destination. The most common use is by mapping values using a hash. For example, to substitute "${version}" for the project's version number and "${copyright}" for "Acme Inc (C) 2007" :
121
121
 
@@ -140,9 +140,10 @@ test:
140
140
  You can specify a different format by passing it as the first argument. Supported formats include:
141
141
 
142
142
  |_. Format |_. Usage |
143
- | @:ant@ | Map from @key@ to value. |
143
+ | @:ant@ | Map from <code>@key@</code> to value. |
144
144
  | @:maven@ | Map from @${key}@ to value (default). |
145
145
  | @:ruby@ | Map from @#{key}@ to value. |
146
+ | @:erb@ | Map from @<%=key%>@ to value. |
146
147
  | @Regexp@ | Map using the matched value of the regular expression (e.g. @/=(.*?)=/@). |
147
148
 
148
149
  For example, using the @:ruby@ format instead of the default @:maven@ format:
@@ -241,4 +242,35 @@ clean { rm_rf _('staged') }
241
242
 
242
243
  The @rm_rf@ method deletes the directory and all files in it. It's named after UNIX's infamous @rm -rf@. Use it wisely. This is also a good time to introduce you to @FileUtils@, a standard Ruby library that contains convenient methods for creating and deleting directories, copying and moving files, even comparing two files. They're all free of charge when you use Buildr.
243
244
 
245
+
246
+ h2(#continuous-compilation). Continuous Compilation
247
+
248
+ And if all that weren't enough, Buildr also offers a time-saving feature called continuous compilation. This feature, implemented by the @cc@ task, instructs Buildr to loop eternally, polling your project's source directories for changes. Whenever a change is detected, Buildr immediately triggers the appropriate compilation step and goes right back to polling. This allows you to reap many of the benefits of an incrementally compiling IDE like Eclipse without sacrificing your favorite build tool.
249
+
250
+ To get started, simply invoke the @cc@ task at the command prompt:
251
+
252
+ {% highlight sh %}
253
+ $ buildr cc
254
+ {% endhighlight %}
255
+
256
+ This task will immediately invoke the @compile@ and @test:compile@ tasks on your project if necessary. This ensures that your build is completely up to the minute before polling is initiated. After this initial build (if required), Buildr will print a notification indicating which directories are being monitored. By default, these directories will include any source folders (e.g. @src/main/java/@), any test directories (e.g. @src/spec/scala/@) as well as any resources (e.g. @src/main/resources/). The Buildr process will remain running during this time, meaning that in order to test this functionality, we will need to open a new shell:
257
+
258
+ {% highlight sh %}
259
+ $ touch src/main/java/Test.java
260
+ {% endhighlight %}
261
+
262
+ The moment we run this command, Buildr will detect the change and invoke the @compile@ task. It will *not* invoke the @test:compile@ task, since none of the test files were actually changed. This ensures that potentially time-consuming tasks are avoided if possible. Note that, unlike the @build@ task, the continuous compilation also does not actually run any of your tests. Continuous compilation is designed to be a simple daemon which runs forever, quickly recompiling your project as soon as you save or delete a file. We can terminate the continuous compilation task by pressing Ctrl-C. Left to its own devices, the @cc@ task really will loop forever.
263
+
264
+ There are several advantages to continuous compilation. Number one is convenience. Once you invoke the @cc@ task, you can focus exclusively on the code, editing and saving your files in an unbroken workflow. There is no need to break your concentration to invoke Buildr manually unless you need to run the test suite, deploy the application or anything beyond compilation. The second advantage is speed. By using the continuous compilation process, you avoid repeatedly incurring Buildr's startup overhead. While this startup time is kept to a minimum, it is still perceptable, particularly when running on JRuby. Since the @cc@ task runs within a Buildr instance which has already been started, there is no need for repeated, inefficient load times. Again, this allows you to focus more completely on what's really important: the code.
265
+
266
+ By default, the @cc@ task will poll your sources once every 200 milliseconds. We have found that this frequency strikes a nice balance between CPU load (which is insignificant) and nearly-instant detection. However, you may wish to tune this value based on your own needs. To do so, simply use the @cc.frequency@ property in your project definition:
267
+
268
+ {% highlight ruby %}
269
+ project 'foo' do
270
+ cc.frequency 1.5 # poll every one-and-a-half seconds
271
+ end
272
+ {% endhighlight %}
273
+
274
+ If you find that the 200 ms default imposes too much overhead, try changing @cc.frequency@ to a higher value. On the flip side, if you find that you're waiting too long for changes to be caught by the poll, tune the frequency lower.
275
+
244
276
  Now let's "talk about the artifacts":artifacts.html we mentioned before.
@@ -250,3 +250,8 @@ A test-infected developer since 2001, Lacton yearns for a development infrastruc
250
250
  *"Daniel Spiewak":http://www.codecommit.com/blog* (djspiewak at apache.org)
251
251
 
252
252
  Daniel originally came to Buildr in search of a Scala build tool which was better than Ant. He got more than he bargained for. Now, he works to advance Buildr as the absolute best tool for supporting Scala development.
253
+
254
+ *"Antoine Toulme":http://www.lunar-ocean.com/* (toulmean at apache.org)
255
+
256
+ Antoine used Buildr first as an excuse to evade in Ruby land, creating plugins for Debian packaging, GWT compilation, or the NSIS installer. His main area of interest is the resolving of dependencies in the OSGi world. He works on making Buildr a standalone rock solid tool.
257
+
data/doc/download.textile CHANGED
@@ -20,15 +20,26 @@ The source code is included in both source and binary distribution, the Gem dist
20
20
 
21
21
  h2(#dist). Binaries and Source Code
22
22
 
23
+ h3. buildr 1.3.5 (2009-10-05)
24
+
25
+ |_. Package |_. MD5 Checksum |_. PGP |
26
+ | "buildr-1.3.5.gem":http://www.apache.org/dyn/closer.cgi/buildr/1.3.5/buildr-1.3.5.gem | "5a04d8593f98606f15dd589988afe24d":http://www.apache.org/dist/buildr/1.3.5/buildr-1.3.5.gem.md5 | "Sig":http://www.apache.org/dist/buildr/1.3.5/buildr-1.3.5.gem.asc |
27
+ | "buildr-1.3.5-java.gem":http://www.apache.org/dyn/closer.cgi/buildr/1.3.5/buildr-1.3.5-java.gem | "d930c851196cd8f9ea66b7190d324dd4":http://www.apache.org/dist/buildr/1.3.5/buildr-1.3.5-java.gem.md5 | "Sig":http://www.apache.org/dist/buildr/1.3.5/buildr-1.3.5-java.gem.asc |
28
+ | "buildr-1.3.5-x86-mswin32.gem":http://www.apache.org/dyn/closer.cgi/buildr/1.3.5/buildr-1.3.5-x86-mswin32.gem | "a6dfc07b4c22e1902de6269e5776a32c":http://www.apache.org/dist/buildr/1.3.5/buildr-1.3.5-x86-mswin32.gem.md5 | "Sig":http://www.apache.org/dist/buildr/1.3.5/buildr-1.3.5-x86-mswin32.gem.asc |
29
+ | "buildr-1.3.5.tgz":http://www.apache.org/dyn/closer.cgi/buildr/1.3.5/buildr-1.3.5.tgz | "d246b84d70a5934536a3f0cd8de1abf7":http://www.apache.org/dist/buildr/1.3.5/buildr-1.3.5.tgz.md5 | "Sig":http://www.apache.org/dist/buildr/1.3.5/buildr-1.3.5.tgz.asc |
30
+ | "buildr-1.3.5.zip":http://www.apache.org/dyn/closer.cgi/buildr/1.3.5/buildr-1.3.5.zip | "d05f9a24f488318d22964bd2f443a76c":http://www.apache.org/dist/buildr/1.3.5/buildr-1.3.5.zip.md5 | "Sig":http://www.apache.org/dist/buildr/1.3.5/buildr-1.3.5.zip.asc |
31
+
32
+ p>. ("Release signing keys":http://www.apache.org/dist/buildr/1.3.5/KEYS)
33
+
23
34
  h3. buildr 1.3.4 (2009-04-21)
24
35
 
25
36
  |_. Package |_. MD5 Checksum |_. PGP |
26
- | "buildr-1.3.4.gem":http://www.apache.org/dist/buildr/1.3.4/buildr-1.3.4.gem | "34247286f910be1724f63b9e795e75ed":http://www.apache.org/dist/buildr/1.3.4/buildr-1.3.4.gem.md5 | "Sig":http://www.apache.org/dist/buildr/1.3.4/buildr-1.3.4.gem.asc |
27
- | "buildr-1.3.4-java.gem":http://www.apache.org/dist/buildr/1.3.4/buildr-1.3.4-java.gem | "44ed67bf835cf2abdc2b6723b5eceadb":http://www.apache.org/dist/buildr/1.3.4/buildr-1.3.4-java.gem.md5 | "Sig":http://www.apache.org/dist/buildr/1.3.4/buildr-1.3.4-java.gem.asc |
28
- | "buildr-1.3.4.tgz":http://www.apache.org/dist/buildr/1.3.4/buildr-1.3.4.tgz | "7d918b88a3bb8139f28f6ff0b39d003c":http://www.apache.org/dist/buildr/1.3.4/buildr-1.3.4.tgz.md5 | "Sig":http://www.apache.org/dist/buildr/1.3.4/buildr-1.3.4.tgz.asc |
29
- | "buildr-1.3.4.zip":http://www.apache.org/dist/buildr/1.3.4/buildr-1.3.4.zip | "8f4cf84dc6e293aac5fba7e2a9cc0776":http://www.apache.org/dist/buildr/1.3.4/buildr-1.3.4.zip.md5 | "Sig":http://www.apache.org/dist/buildr/1.3.4/buildr-1.3.4.zip.asc |
37
+ | "buildr-1.3.4.gem":http://www.apache.org/dyn/closer.cgi/buildr/1.3.4/buildr-1.3.4.gem | "34247286f910be1724f63b9e795e75ed":http://www.apache.org/dist/buildr/1.3.4/buildr-1.3.4.gem.md5 | "Sig":http://www.apache.org/dist/buildr/1.3.4/buildr-1.3.4.gem.asc |
38
+ | "buildr-1.3.4-java.gem":http://www.apache.org/dyn/closer.cgi/buildr/1.3.4/buildr-1.3.4-java.gem | "44ed67bf835cf2abdc2b6723b5eceadb":http://www.apache.org/dist/buildr/1.3.4/buildr-1.3.4-java.gem.md5 | "Sig":http://www.apache.org/dist/buildr/1.3.4/buildr-1.3.4-java.gem.asc |
39
+ | "buildr-1.3.4.tgz":http://www.apache.org/dyn/closer.cgi/buildr/1.3.4/buildr-1.3.4.tgz | "7d918b88a3bb8139f28f6ff0b39d003c":http://www.apache.org/dist/buildr/1.3.4/buildr-1.3.4.tgz.md5 | "Sig":http://www.apache.org/dist/buildr/1.3.4/buildr-1.3.4.tgz.asc |
40
+ | "buildr-1.3.4.zip":http://www.apache.org/dyn/closer.cgi/buildr/1.3.4/buildr-1.3.4.zip | "8f4cf84dc6e293aac5fba7e2a9cc0776":http://www.apache.org/dist/buildr/1.3.4/buildr-1.3.4.zip.md5 | "Sig":http://www.apache.org/dist/buildr/1.3.4/buildr-1.3.4.zip.asc |
30
41
 
31
- p>. ("Release signing keys":http://www.apache.org/dist/buildr/1.3.4/KEYS)
42
+ p>. ("Release signing keys":http://www.apache.org/dist/buildr/KEYS)
32
43
 
33
44
 
34
45
  h3. buildr 1.3.3-incubating (2008-10-08)
@@ -16,7 +16,7 @@ file('derby.sql') do
16
16
  REQUIRES = [
17
17
  'org.apache.openjpa:openjpa-all:jar:0.9.7-incubating',
18
18
  'commons-collections:commons-collections:jar:3.1',
19
- . . .
19
+ . . .
20
20
  'net.sourceforge.serp:serp:jar:1.11.0' ]
21
21
  ant('openjpa') do |ant|
22
22
  ant.taskdef :name=>'mapping',
@@ -48,20 +48,20 @@ But just using functions is not always enough. You end up with a Buildfile cont
48
48
 
49
49
  If you want to share these pre-canned definitions between projects, you have a few more options. You can share the @tasks@ directory using SVN externals, Git modules, or whichever cross-repository feature your source control system supports. Another mechanism with better version control is to package all these tasks, functions and modules into a "Gem":http://rubygems.org/ and require it from your Buildfile. You can run your own internal Gem server for that.
50
50
 
51
- To summarize, there are several common ways to distribute extensions:
51
+ To summarize, there are several common ways to distribute extensions:
52
52
  * Put them in the same place (e.g. @~/.buildr@) and require them from your
53
53
  @buildfile@
54
54
  * Put them directly in the project, typically under the @tasks@ directory.
55
55
  * Put them in a shared code repository, and link to them from your project's @tasks@ directory
56
56
  * As Ruby gems and specify which gems are used in the settings file
57
57
 
58
- You can also get creative and devise your own way to distribute extensions.
58
+ You can also get creative and devise your own way to distribute extensions.
59
59
  "Sake":http://errtheblog.com/post/6069 is a good example of such initiative that lets you deploy Rake tasks on a system-wide basis.
60
60
 
61
61
  h2(#extensions). Creating Extensions
62
62
 
63
63
  The basic mechanism for extending projects in Buildr are Ruby modules. In fact, base features like compiling and testing are all developed in the form of modules, and then added to the core Project class.
64
-
64
+
65
65
  A module defines instance methods that are then mixed into the project and become instance methods of the project. There are two general ways for extending projects. You can extend all projects by including the module in Project:
66
66
 
67
67
  {% highlight ruby %}
@@ -91,6 +91,7 @@ This example illustrates how to write a simple extension:
91
91
 
92
92
  {% highlight ruby %}
93
93
  module LinesOfCode
94
+
94
95
  include Extension
95
96
 
96
97
  first_time do
@@ -101,33 +102,58 @@ module LinesOfCode
101
102
 
102
103
  before_define do |project|
103
104
  # Define the loc task for this particular project.
104
- define_task 'loc' do |task|
105
- lines = task.prerequisites.map { |path| Dir["#{path}/**/*"] }.flatten.uniq.
106
- inject(0) { |total, file| total + File.readlines(file).count }
105
+ project.recursive_task 'loc' do |task|
106
+ lines = task.prerequisites.map { |path|
107
+ Dir["#{path}/**/*"]
108
+ }.flatten.uniq.inject(0) { |total, file|
109
+ total = 0 if total.nil?
110
+ if File.file? file then
111
+ total + File.readlines(file).count
112
+ end
113
+ }
107
114
  puts "Project #{project.name} has #{lines} lines of code"
108
- end
115
+ end
109
116
  end
110
117
 
111
118
  after_define do |project|
112
119
  # Now that we know all the source directories, add them.
113
- task('loc'=>compile.sources + compile.test.sources)
120
+ task('loc' => project.compile.sources + project.test.sources)
114
121
  end
115
122
 
116
123
  # To use this method in your project:
117
- # loc path_1, path_2
124
+ # loc path_1, path_2
118
125
  def loc(*paths)
119
- task('loc'=>paths)
126
+ task('loc' => paths)
120
127
  end
121
128
 
122
129
  end
123
130
 
124
131
  class Buildr::Project
125
- include LinesOfCode
132
+ include LinesOfCode
126
133
  end
127
134
  {% endhighlight %}
128
135
 
129
136
  You may find interesting that this Extension API is used pervasively inside Buildr itself. Many of the standard tasks such as @compile@, @test@, @package@ are extensions to a very small core.
130
137
 
138
+ Starting with Buildr 1.4, it's possible to define ordering between @before_define@ and @after_define@ code blocks in a way similar to Rake's dependencies. For example, if you wanted to override @project.test.compile.from@ in @after_define@, you could do so by in
139
+
140
+ {% highlight ruby %}
141
+ after_define(:functional_tests) do |project|
142
+ # Change project.test.compile.from if it's not already pointing
143
+ # to a location with Java sources
144
+ if Dir["#{project.test.compile.from}/**/*.java"].size == 0 &&
145
+ Dir["#{project._(:src, 'test-functional', :java)}/**/*.java"].size > 0
146
+ project.test.compile.from project._(:src, 'test-functional', :java)
147
+ end
148
+ end
149
+
150
+ # make sure project.test.compile.from is updated before the
151
+ # compile extension picks up its value
152
+ after_define(:compile => :functional_test)
153
+ {% endhighlight %}
154
+
155
+ Core extensions provide the following named callbacks: @compile@, @test@, @build@, @package@ and @check@.
156
+
131
157
  h2(#layouts). Using Alternative Layouts
132
158
 
133
159
  Buildr follows a common convention for project layouts: Java source files appear in @src/main/java@ and compile to @target/classes@, resources are copied over from @src/main/resources@ and so forth. Not all projects follow this convention, so it's now possible to specify an alternative project layout.
@@ -38,7 +38,7 @@ $ sudo gem update --system
38
38
  On *Ubuntu* you have to install several packages:
39
39
 
40
40
  {% highlight sh %}
41
- $ sudo apt-get install ruby-full ruby1.8-dev libopenssl-ruby build-essential
41
+ $ sudo apt-get install ruby-full ruby1.8-dev libopenssl-ruby build-essential
42
42
  {% endhighlight %}
43
43
 
44
44
  The Debian package for @rubygems@ will not allow you to install Buildr, so you need to install RubyGems from source:
@@ -70,6 +70,8 @@ h2(#osx). Installing on OS X
70
70
 
71
71
  *The easy way:* Use this script to "install Buildr on OS X":scripts/install-osx.sh. This script will install the most recent version of Buildr, or if already installed, upgrade to the most recent version. It will also install Ruby 1.8.6 if not already installed (using MacPorts/Fink) and upgrage RubyGems to 1.3.1 or later.
72
72
 
73
+ You need to have the Apple Development Tools installed. They are available on the Mac OSX installation CD.
74
+
73
75
  <br>
74
76
 
75
77
  *In details:* OS X 10.5 (Leopard) comes with a recent version of Ruby 1.8.6. You do not need to install a different version of Ruby when running OS X 10.5.
@@ -104,7 +106,7 @@ $ sudo env JAVA_HOME=$JAVA_HOME gem install buildr -v 1.3.4
104
106
 
105
107
  h2(#windows). Installing on Windows
106
108
 
107
- *The easy way:* The easiest way to install Ruby is using the "one-click installer":http://rubyinstaller.rubyforge.org/. Once installed, set the @JAVA_HOME@ environment variable and run @gem install buildr@.
109
+ *The easy way:* The easiest way to install Ruby is using the "one-click installer":http://rubyinstaller.rubyforge.org/. Be sure to install Ruby 1.8.6; support for Ruby 1.9.x is still a work in progress. Once installed, set the @JAVA_HOME@ environment variable and run @gem install buildr --platform mswin32@.
108
110
 
109
111
  <br>
110
112
 
@@ -117,17 +119,16 @@ h2(#windows). Installing on Windows
117
119
  Before installing Buildr, please set the @JAVA_HOME@ environment variable to point to your JDK distribution. Next, use Ruby Gem to install Buildr:
118
120
 
119
121
  {% highlight sh %}
120
- > gem install buildr
122
+ > gem install buildr --platform mswin32
121
123
  {% endhighlight %}
122
124
 
123
125
  To upgrade to a new version or install a specific version:
124
126
 
125
127
  {% highlight sh %}
126
128
  > gem update buildr
127
- > gem install buildr -v 1.3.4
129
+ > gem install buildr -v 1.3.4 --platform mswin32
128
130
  {% endhighlight %}
129
131
 
130
-
131
132
  h2(#jruby). Installing for JRuby
132
133
 
133
134
  *The easy way:* Use this bash script to "install Buildr on JRuby":scripts/install-jruby.sh. This script will install the most recent version of Buildr, or if already installed, upgrade to the most recent version. If necessary, it will also install JRuby 1.1.6 in @/opt/jruby@ and update the @PATH@ variable in @~/.bash_profile@ or @~/.profile@.