buildr 1.3.4-java → 1.3.5-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. data/CHANGELOG +35 -0
  2. data/README.rdoc +1 -1
  3. data/Rakefile +3 -3
  4. data/buildr.buildfile +6 -1
  5. data/buildr.gemspec +10 -9
  6. data/doc/_config.yml +1 -0
  7. data/doc/_layouts/default.html +25 -19
  8. data/doc/artifacts.textile +0 -36
  9. data/doc/building.textile +0 -38
  10. data/doc/contributing.textile +51 -15
  11. data/doc/css/default.css +11 -4
  12. data/doc/css/print.css +32 -24
  13. data/doc/download.textile +33 -22
  14. data/doc/extending.textile +10 -20
  15. data/doc/images/1442160941-frontcover.jpg +0 -0
  16. data/doc/images/asf-logo.png +0 -0
  17. data/doc/images/note.png +0 -0
  18. data/doc/images/project-structure.png +0 -0
  19. data/doc/images/tip.png +0 -0
  20. data/doc/images/zbuildr.png +0 -0
  21. data/doc/index.textile +39 -17
  22. data/doc/{getting_started.textile → installing.textile} +3 -80
  23. data/doc/languages.textile +50 -52
  24. data/doc/more_stuff.textile +154 -62
  25. data/doc/packaging.textile +0 -82
  26. data/doc/preface.textile +41 -15
  27. data/doc/projects.textile +0 -18
  28. data/doc/quick_start.textile +210 -0
  29. data/doc/scripts/install-linux.sh +10 -2
  30. data/doc/settings_profiles.textile +1 -33
  31. data/doc/testing.textile +6 -32
  32. data/lib/buildr.rb +2 -1
  33. data/lib/buildr/core.rb +6 -0
  34. data/lib/buildr/core/application.rb +2 -5
  35. data/lib/buildr/core/build.rb +29 -19
  36. data/lib/buildr/core/compile.rb +22 -4
  37. data/lib/buildr/core/filter.rb +2 -4
  38. data/lib/buildr/core/project.rb +5 -4
  39. data/lib/buildr/core/shell.rb +198 -0
  40. data/lib/buildr/core/test.rb +2 -0
  41. data/lib/buildr/core/transports.rb +18 -19
  42. data/lib/buildr/core/util.rb +178 -9
  43. data/lib/buildr/groovy.rb +1 -0
  44. data/lib/buildr/groovy/bdd.rb +5 -5
  45. data/lib/buildr/groovy/shell.rb +48 -0
  46. data/lib/buildr/ide/eclipse.rb +148 -36
  47. data/lib/buildr/ide/eclipse/java.rb +53 -0
  48. data/lib/buildr/ide/eclipse/plugin.rb +68 -0
  49. data/lib/buildr/ide/eclipse/scala.rb +66 -0
  50. data/lib/buildr/java/bdd.rb +16 -8
  51. data/lib/buildr/java/cobertura.rb +44 -13
  52. data/lib/buildr/java/commands.rb +5 -3
  53. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  54. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +18 -0
  55. data/lib/buildr/java/packaging.rb +2 -2
  56. data/lib/buildr/java/rjb.rb +1 -1
  57. data/lib/buildr/java/test_result.rb +48 -1
  58. data/lib/buildr/java/tests.rb +8 -5
  59. data/lib/buildr/packaging/artifact_namespace.rb +1 -1
  60. data/lib/buildr/packaging/package.rb +6 -2
  61. data/lib/buildr/packaging/zip.rb +10 -1
  62. data/lib/buildr/packaging/ziptask.rb +5 -2
  63. data/lib/buildr/scala.rb +1 -0
  64. data/lib/buildr/scala/bdd.rb +17 -8
  65. data/lib/buildr/scala/compiler.rb +66 -21
  66. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  67. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  68. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
  69. data/lib/buildr/scala/shell.rb +55 -0
  70. data/lib/buildr/scala/tests.rb +6 -5
  71. data/lib/buildr/shell.rb +180 -0
  72. data/rakelib/doc.rake +2 -3
  73. data/rakelib/jekylltask.rb +42 -32
  74. data/rakelib/package.rake +4 -2
  75. data/rakelib/release.rake +8 -8
  76. data/rakelib/rspec.rake +3 -3
  77. data/rakelib/setup.rake +7 -1
  78. data/rakelib/stage.rake +9 -2
  79. data/rakelib/stage.rake~ +213 -0
  80. data/spec/core/application_spec.rb +84 -1
  81. data/spec/core/build_spec.rb +54 -2
  82. data/spec/core/common_spec.rb +1 -1
  83. data/spec/core/compile_spec.rb +2 -1
  84. data/spec/core/extension_spec.rb +93 -0
  85. data/spec/core/test_spec.rb +2 -2
  86. data/spec/core/transport_spec.rb +1 -1
  87. data/spec/groovy/bdd_spec.rb +6 -6
  88. data/spec/groovy/compiler_spec.rb +1 -0
  89. data/spec/ide/eclipse_spec.rb +262 -72
  90. data/spec/java/{ant.rb → ant_spec.rb} +0 -0
  91. data/spec/java/bdd_spec.rb +15 -0
  92. data/spec/java/cobertura_spec.rb +9 -1
  93. data/spec/java/emma_spec.rb +1 -1
  94. data/spec/java/java_spec.rb +26 -0
  95. data/spec/java/packaging_spec.rb +9 -7
  96. data/spec/java/{test_coverage_spec.rb → test_coverage_helper.rb} +6 -4
  97. data/spec/java/tests_spec.rb +22 -0
  98. data/spec/packaging/archive_spec.rb +14 -0
  99. data/spec/packaging/artifact_spec.rb +2 -2
  100. data/spec/packaging/packaging_spec.rb +97 -2
  101. data/spec/sandbox.rb +3 -1
  102. data/spec/scala/bdd_spec.rb +17 -48
  103. data/spec/scala/compiler_spec.rb +31 -2
  104. data/spec/scala/tests_spec.rb +1 -0
  105. data/spec/spec_helpers.rb +12 -0
  106. metadata +145 -148
data/CHANGELOG CHANGED
@@ -1,3 +1,37 @@
1
+ 1.3.5 (2009-10-05)
2
+ * Added: Interactive shell (REPL) support
3
+ * Added: BeanShell as default shell for java projects, bsh is small and it's
4
+ syntax provides the closest to an interpreted java. The BeanShell
5
+ console includes a graphical class browser. Shell is named :bsh
6
+ * Added: Mandriva (urpmi) installation support (with help from Franck Villaume).
7
+ * Added: BUILDR-56 Download Scala artifacts if not available locally
8
+ * Added: BUILDR-163 cobertura:check (Marko Sibakov, Daniel Spiewak).
9
+ * Added: BUILDR-295 Eclipse task: make 'M2_REPO' repository variable configurable
10
+ * Added: BUILDR-300 Make Eclipse task more configurable (Antoine Toulme, Alex Boisvert)
11
+ * Change: Upgraded to rubyforge-1.0.5 and net-ssh 2.0.15
12
+ * Change: Monkey-Patched FileUtils::sh on JRuby to use POSIX `system`
13
+ * Change: Updated to Rake 0.8.7, RSpec 1.2.8 and JRuby-openssl 0.5.2.
14
+ * Change: Updated to easyb 0.9 (Joel Muzzerall)
15
+ * Change: Updated to TestNG 5.10
16
+ * Change: Updated to JRuby 1.3.1
17
+ * Fixed: BUILDR-23 Support for setting file mode when packaging (Ittay Dror).
18
+ * Fixed: BUILDR-278 tasks/*.rake files are loaded after the buildfile (Rhett Sutphin)
19
+ * Fixed: BUILDR-282 release goal should not strip leading '0' digits from version numbers.
20
+ * Fixed: BUILDR-289 Improved error message when JAVA_HOME points to an invalid JRE/JDK installation
21
+ * Fixed: BUILDR-290 Dependencies cannot be downloaded over SSL.
22
+ * Fixed: BUILDR-291 Local tasks do not support arguments (Ittay Dror).
23
+ * Fixed: BUILDR-292 Workaround for JRUBY-3381 on FileUtils.mv
24
+ * Fixed: BUILDR-301 TestNG doesn't report failure if more than one test fails
25
+ * Fixed: BUILDR-307 Failures are not reported correctly for ScalaTest (Jeremie Lenfant-Engelmann)
26
+ * Fixed: BUILDR-313 Prevent release with uncommitted_files on Git 1.4.3+ (Alexis Midon)
27
+ * Fixed: BUILDR-315 Fix Eclipse .classpath for local libraries (Mat Schaffer)
28
+ * Fixed: BUILDR-304 Referencing an existing package task using the package
29
+ method fails if the package has a custom filename (Rhett Sutphin)
30
+ * Fixed: BUILDR-322 When specifying files (instead of directories) as sources for compile task,
31
+ Buildr uses target directory timestamp only (not compiled output timestamp)
32
+ * Fixed: BUILDR-324: Regression - baseDir system property is not set when executing tests [Alexis Midon]
33
+ * Fixed: BUILDR-325: Overriding package spec with classifer doesn't work (Antoine Toulme)
34
+
1
35
  1.3.4 (2009-04-21)
2
36
  * Added: BUILDR-93 Add specs for ScalaCheck integration
3
37
  * Added: BUILDR-94 Add specs for Scala Specs integration
@@ -32,6 +66,7 @@
32
66
  * Change: Buildr now uses Jekyll to generate Web site/documentation:
33
67
  http://github.com/mojombo/jekyll/ This replaces Docter so less code to
34
68
  maintain and the same Textile/Liquid mechanism as when using Github pages.
69
+ * Change: To access Release object (e.g. to set tag_name) use Release.find.
35
70
  * Fixed: Removed double complete/fail messages showing up on console.
36
71
  * Fixed: BUILDR-140 Get rid of const_defined? all across the board.
37
72
  * Fixed: BUILDR-158 Nailgun is now a delegate for buildr/drb (a pure-ruby dRuby server)
@@ -27,7 +27,7 @@ http://buildr.apache.org/
27
27
 
28
28
  === RTFM
29
29
 
30
- * Buildr documentation: http://buildr.apache.org/
30
+ * Buildr documentation: http://buildr.apache.org
31
31
  * More about Rake: http://docs.rubyrake.org
32
32
  * Antwrap documentation: http://antwrap.rubyforge.org
33
33
 
data/Rakefile CHANGED
@@ -28,9 +28,9 @@ end
28
28
 
29
29
  # Load the Gem specification for the current platform (Ruby or JRuby).
30
30
  def spec(platform = RUBY_PLATFORM[/java/] || 'ruby')
31
- @specs ||= ['ruby', 'java'].inject({}) { |hash, platform|
32
- $platform = platform
33
- hash.update(platform=>Gem::Specification.load('buildr.gemspec'))
31
+ @specs ||= ['ruby', 'java', 'x86-mswin32'].inject({}) { |hash, spec_platform|
32
+ $platform = spec_platform
33
+ hash.update(spec_platform=>Gem::Specification.load('buildr.gemspec'))
34
34
  }
35
35
  @specs[platform]
36
36
  end
@@ -16,6 +16,7 @@
16
16
  $LOADED_FEATURES << 'jruby' unless RUBY_PLATFORM =~ /java/ # Pretend to have JRuby, keeps Nailgun happy.
17
17
  require 'buildr/jetty'
18
18
  require 'buildr/nailgun'
19
+ require 'buildr/scala'
19
20
  repositories.remote << 'http://repo1.maven.org/maven2'
20
21
  repositories.remote << 'http://scala-tools.org/repo-releases/'
21
22
 
@@ -23,10 +24,14 @@ repositories.remote << 'http://scala-tools.org/repo-releases/'
23
24
  define 'buildr' do
24
25
  compile.using :source=>'1.4', :target=>'1.4', :debug=>false
25
26
 
26
- define 'java' do
27
+ define 'java' do
27
28
  compile.using(:javac).from(FileList['lib/buildr/java/**/*.java']).into('lib/buildr/java')
28
29
  end
29
30
 
31
+ define 'scala' do
32
+ compile.using(:scalac).from(FileList['lib/buildr/scala/**/*.scala']).into('lib/buildr/scala')
33
+ end
34
+
30
35
  desc 'Buildr extra packages (Antlr, Cobertura, Hibernate, Javacc, JDepend, Jetty, OpenJPA, XmlBeans)'
31
36
  define 'extra', :version=>'1.0' do
32
37
  compile.using(:javac).from(FileList['addon/buildr/**/*.java']).into('addon/buildr').with(Buildr::Jetty::REQUIRES, Buildr::Nailgun::ARTIFACT_SPEC)
@@ -16,7 +16,7 @@
16
16
 
17
17
  Gem::Specification.new do |spec|
18
18
  spec.name = 'buildr'
19
- spec.version = '1.3.4'
19
+ spec.version = '1.3.5'
20
20
  spec.author = 'Apache Buildr'
21
21
  spec.email = "users@buildr.apache.org"
22
22
  spec.homepage = "http://buildr.apache.org/"
@@ -47,18 +47,19 @@ for those one-off tasks, with a language that's a joy to use.
47
47
  spec.post_install_message = "To get started run buildr --help"
48
48
 
49
49
  # Tested against these dependencies.
50
- spec.add_dependency 'rake', '0.8.4'
50
+ spec.add_dependency 'rake', '0.8.7'
51
51
  spec.add_dependency 'builder', '2.1.2'
52
- spec.add_dependency 'net-ssh', '2.0.11'
52
+ spec.add_dependency 'net-ssh', '2.0.15'
53
53
  spec.add_dependency 'net-sftp', '2.0.2'
54
54
  spec.add_dependency 'rubyzip', '0.9.1'
55
- spec.add_dependency 'highline', '1.5.0'
56
- spec.add_dependency 'rubyforge', '1.0.3'
57
- spec.add_dependency 'hoe', '1.11.0'
58
- spec.add_dependency 'rjb', '1.1.6' if spec.platform.to_s == 'ruby'
55
+ spec.add_dependency 'highline', '1.5.1'
56
+ spec.add_dependency 'rubyforge', '1.0.5'
57
+ 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
60
  spec.add_dependency 'Antwrap', '0.7.0'
60
- spec.add_dependency 'rspec', '1.2.2'
61
+ spec.add_dependency 'rspec', '1.2.8'
61
62
  spec.add_dependency 'xml-simple', '1.0.12'
62
63
  spec.add_dependency 'archive-tar-minitar', '0.5.2'
63
- spec.add_dependency 'jruby-openssl', '0.3' if spec.platform.to_s == 'java'
64
+ spec.add_dependency 'jruby-openssl', '0.5.2' if spec.platform.to_s == 'java'
64
65
  end
@@ -0,0 +1 @@
1
+ pygments: true
@@ -1,6 +1,6 @@
1
1
  <html>
2
2
  <head>
3
- <meta content='text/html;charset=UTF-8' http-equiv='Content-Type' />
3
+ <meta content='text/html;charset=UTF-8' http-equiv='Content-Type'>
4
4
  <title>buildr &mdash; {{ page.title }}</title>
5
5
  <style type='text/css'>
6
6
  @import 'css/default.css';
@@ -9,30 +9,28 @@
9
9
  <style media='print' type='text/css'>
10
10
  @import 'css/print.css';
11
11
  </style>
12
- <meta content='Official Buildr documentation from the people in the know' name='subject' />
13
- <link href='images/favicon.png' rel='shortcut icon' />
12
+ <meta content='Official Buildr documentation from the people in the know' name='subject'>
13
+ <link href='images/favicon.png' rel='shortcut icon'>
14
14
  </head>
15
15
  <body>
16
16
  <div id='wrap'>
17
17
  <div id='header'>
18
- <a href='http://buildr.apache.org/'>
19
- <img alt='buildr' src='images/buildr.png' />
20
- </a>
21
- <div class='tagline'></div>
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>
22
20
  </div>
23
21
  <div id='pages'>
24
22
  <ol class='toc'>
25
23
  <li>Start Here
26
24
  <ol class="toc">
27
25
  <li><a href='index.html'>Welcome</a></li>
28
- <li><a href='download.html'>Download</a></li>
29
- <li><a href='buildr.pdf'>User Guide (PDF)</a></li>
26
+ <li><a href='quick_start.html'>Quick Start</a></li>
27
+ <li><a href='installing.html'>Installing & Running</a></li>
30
28
  <li><a href='http://cwiki.apache.org/confluence/display/BUILDR/Index'>Community Wiki</a></li>
31
29
  </ol>
32
30
  </li>
33
31
  <li>Using Buildr
34
32
  <ol class="toc">
35
- <li><a href='getting_started.html'>Getting Started</a></li>
33
+ <li><a href='buildr.pdf'>This Guide (PDF)</a></li>
36
34
  <li><a href='projects.html'>Projects</a></li>
37
35
  <li><a href='building.html'>Building</a></li>
38
36
  <li><a href='artifacts.html'>Artifacts</a></li>
@@ -46,7 +44,7 @@
46
44
  </ol>
47
45
  </li>
48
46
  <li>Reference
49
- <ol class="toc">
47
+ <ol class="toc">
50
48
  <li><a href='rdoc'>API</a></li>
51
49
  <li><a href='http://docs.rubyrake.org'>Rake</a></li>
52
50
  <li><a href='http://antwrap.rubyforge.org'>Antwrap</a></li>
@@ -54,7 +52,8 @@
54
52
  </ol>
55
53
  </li>
56
54
  <li>Get Involved
57
- <ol class="toc">
55
+ <ol class="toc">
56
+ <li><a href='download.html'>Download</a></li>
58
57
  <li><a href='mailing_lists.html'>Mailing Lists</a></li>
59
58
  <li><a href='http://issues.apache.org/jira/browse/Buildr'>Issues/Bugs</a></li>
60
59
  <li><a href='contributing.html'>Contributing</a></li>
@@ -62,14 +61,21 @@
62
61
  <li><a href='coverage/index.html'>Coverage</a></li>
63
62
  </ol>
64
63
  </li>
64
+ <li>
65
+ <form action='http://www.google.com/cse' id='searchbox_003673095760649043902:ogcgrzu0l2y'>
66
+ <input name='cx' type='hidden' value='003673095760649043902:ogcgrzu0l2y'>
67
+ <input name='cof' type='hidden' value='FORID:0'>
68
+ <input name='q' size='20' type='text'>
69
+ <input name='sa' type='submit' value='Search'>
70
+ <img alt='Google Custom Search' src='http://www.google.com/coop/images/google_custom_search_smnar.gif'>
71
+ </form>
72
+ </li>
73
+ <li>The Buildr Book
74
+ <p><a href='http://www.amazon.com/Buildr/dp/1442160942/'><img src='images/1442160941-frontcover.jpg' style='width:120px'></a></p>
75
+ <p>Based on the Buildr documentation, available from <a href='http://www.amazon.com/Buildr/dp/1442160942/'>Amazon</a> and
76
+ <a href='http://www.createspace.com/3382199'>CreateSpace</a></p>
77
+ </li>
65
78
  </ol>
66
- <form action='http://www.google.com/cse' id='searchbox_003673095760649043902:ogcgrzu0l2y'>
67
- <input name='cx' type='hidden' value='003673095760649043902:ogcgrzu0l2y' />
68
- <input name='cof' type='hidden' value='FORID:0' />
69
- <input name='q' size='20' type='text' />
70
- <input name='sa' type='submit' value='Search' />
71
- <img alt='Google Custom Search' src='http://www.google.com/coop/images/google_custom_search_smnar.gif' />
72
- </form>
73
79
  </div>
74
80
  <div id='content'>
75
81
  <h1 id='{{ page.title | downcase | replace(' ', '_') }}'>{{ page.title }}</h1>
@@ -10,12 +10,10 @@ Artifacts. We designed Buildr to work as a drop-in replacement for Maven 2.0, an
10
10
 
11
11
  We'll get into all of that in a second, but first, let's introduce the artifact specification. It's a simple string that takes one of two forms:
12
12
 
13
- <notextile>
14
13
  {% highlight text %}
15
14
  group:id:type:version
16
15
  group:id:type:classifier:version
17
16
  {% endhighlight %}
18
- </notextile>
19
17
 
20
18
  For example, @'org.apache.axis2:axis2:jar:1.2'@ refers to an artifact with group identifier org.apache.axis2, artifact identifier axis2, a JAR file with version 1.2. Classifiers are typically used to distinguish between similar file types, for example, a source distribution and a binary distribution that otherwise have the same identifier and are both ZIP files.
21
19
 
@@ -26,40 +24,33 @@ If your Buildfile spells out @'org.apache.axis2:axis2:jar:1.2'@ more than once,
26
24
 
27
25
  You can use Ruby's syntax to do simple string substitution, for example:
28
26
 
29
- <notextile>
30
27
  {% highlight ruby %}
31
28
  AXIS_VERSION = '1.2'
32
29
 
33
30
  compile.with "org.apache.axis2:axis2:jar:#{AXIS_VERSION}"
34
31
  {% endhighlight %}
35
- </notextile>
36
32
 
37
33
  Better yet, you can define all your artifacts at the top of the Buildfile and use constants to reference them in your project definition. For example:
38
34
 
39
- <notextile>
40
35
  {% highlight ruby %}
41
36
  AXIS2 = 'org.apache.axis2:axis2:jar:1.2'
42
37
 
43
38
  compile.with AXIS2
44
39
  {% endhighlight %}
45
- </notextile>
46
40
 
47
41
  Note that we're not using a separate constant for the version number. In our experience, it's unnecessary. The version number intentionally appears at the end of the string, where it stands out easily.
48
42
 
49
43
  If you have a set of artifacts that belong to the same group and version, and that's quite common, you can use the @group@ shortcut:
50
44
 
51
- <notextile>
52
45
  {% highlight ruby %}
53
46
  AXIOM = group('axiom-api', 'axiom-impl', 'axiom-dom',
54
47
  :under=>'org.apache.ws.commons.axiom', :version=>'1.2.4')
55
48
  {% endhighlight %}
56
- </notextile>
57
49
 
58
50
  p(note). Buildr projects also define a @group@ attribute which can lead to some confusion. If you want to define an artifact group within a project definition, you should use the explicit qualifier @Buildr::group@.
59
51
 
60
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:
61
53
 
62
- <notextile>
63
54
  {% highlight ruby %}
64
55
  OPENJPA = ['org.apache.openjpa:openjpa-all:jar:0.9.7',
65
56
  'net.sourceforge.serp:serp:jar:1.12.0']
@@ -67,11 +58,9 @@ AXIS_OF_WS = [AXIS2, AXIOM]
67
58
 
68
59
  compile.with OPENJPA, AXIS_OF_WS
69
60
  {% endhighlight %}
70
- </notextile>
71
61
 
72
62
  Another way to group related artifacts together and access them individually is using the @struct@ shortcut. For example:
73
63
 
74
- <notextile>
75
64
  {% highlight ruby %}
76
65
  JAVAX = struct(
77
66
  :activation =>'javax.activation:activation:jar:1.1',
@@ -81,23 +70,19 @@ JAVAX = struct(
81
70
 
82
71
  compile.with JAVAX.persistence, OPENJPA
83
72
  {% endhighlight %}
84
- </notextile>
85
73
 
86
74
  In our experience, using constants in this manner makes your Buildfile much easier to write and maintain.
87
75
 
88
76
  And, of course, you can always place your artifact specifications in a separate file and require it into your Buildfile. For example, if you're working on several different projects that all share the same artifacts:
89
77
 
90
- <notextile>
91
78
  {% highlight ruby %}
92
79
  require '../shared/artifacts'
93
80
  {% endhighlight %}
94
- </notextile>
95
81
 
96
82
  When you use @require@, Ruby always looks for a filename with the @.rb@ extension, so in this case it expects to find @artifacts.rb@ in the @shared@ directory.
97
83
 
98
84
  One last thing. You can also treat artifact specifications as hashes. For example:
99
85
 
100
- <notextile>
101
86
  {% highlight ruby %}
102
87
  AXIS = { :group=>'org.apache.axis2', :id=>'axis2', :version=>'1.2' }
103
88
  compile.with AXIS
@@ -105,7 +90,6 @@ puts compile.dependencies.first.to_hash
105
90
  => { :group=>'org.apache.axis2', :id=>'axis2',
106
91
  :version=>'1.2', :type=>:jar }
107
92
  {% endhighlight %}
108
- </notextile>
109
93
 
110
94
 
111
95
  h2(#repositories). Specifying Repositories
@@ -114,62 +98,50 @@ Buildr can download artifacts for you, but only if you tell it where to find the
114
98
 
115
99
  When you call @repositories.remote@, you get an array of URLs for the various remote repositories. Initially, it's an empty array, to which you can add new repositories. For example:
116
100
 
117
- <notextile>
118
101
  {% highlight ruby %}
119
102
  repositories.remote << 'http://www.ibiblio.org/maven2/'
120
103
  {% endhighlight %}
121
- </notextile>
122
104
 
123
105
  If you need to use a proxy server to access remote repositories, you can set the environment variable @HTTP_PROXY@ to the proxy server URL (use @HTTPS_PROXY@ for proxying HTTPS connections). You can also work without a proxy for certain hosts by specifying the @NO_PROXY@ environment variable. For example:
124
106
 
125
- <notextile>
126
107
  {% highlight sh %}
127
108
  $ export HTTP_PROXY = 'http://myproxy:8080'
128
109
  $ export NO_PROXY = '*.mycompany.com,localhost,special:800'
129
110
  {% endhighlight %}
130
- </notextile>
131
111
 
132
112
  Alternatively you can use the Buildr options @proxy.http@ and @proxy.exclude@:
133
113
 
134
- <notextile>
135
114
  {% highlight ruby %}
136
115
  options.proxy.http = 'http://myproxy:8080'
137
116
  options.proxy.exclude << '*.mycompany.com'
138
117
  options.proxy.exclude << 'localhost'
139
118
  {% endhighlight %}
140
- </notextile>
141
119
 
142
120
  All the artifacts download into the local repository. Since all your projects share the same local repository, you only need to download each artifact once. Buildr was designed to be used alongside Maven 2.0, for example, when migrating projects from Maven 2.0 over to Buildr. By default it will share the same local repository, expecting the repository to be the @.m2/repository@ directory inside your home directory.
143
121
 
144
122
  You can choose to relocate the local repository by giving it a different path, for example:
145
123
 
146
- <notextile>
147
124
  {% highlight ruby %}
148
125
  repositories.local = '/usr/local/maven/repository'
149
126
  {% endhighlight %}
150
- </notextile>
151
127
 
152
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.
153
129
 
154
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:
155
131
 
156
- <notextile>
157
132
  {% highlight sh %}
158
133
  $ buildr artifacts
159
134
  {% endhighlight %}
160
- </notextile>
161
135
 
162
136
 
163
137
  h2(#downloading). Downloading Artifacts
164
138
 
165
139
  Within your buildfile you can download artifacts directly by invoking them, for example:
166
140
 
167
- <notextile>
168
141
  {% highlight ruby %}
169
142
  artifact('org.apache.openjpa:openjpa-all:jar:0.9.7').invoke
170
143
  artifacts(OPENJPA).each(&:invoke)
171
144
  {% endhighlight %}
172
- </notextile>
173
145
 
174
146
  When you let Buildr download artifacts for you, or by invoking the artifact task yourself, it scans through the remote repositories assuming each repository follows the Maven 2 structure. Starting from the root repository URL, it will look for each artifact using the path @group/id/version/id-version.type@ (or ...@/id-version-classifier.type@). The group identifier becomes a path by turning periods (@.@) into slashes (@/@). So to find @org.apache.axis2:axis2:jar:1.2@, we're going to look for @org/apache/axis2/axis2/1.2/axis2-1.2.jar@.
175
147
 
@@ -179,14 +151,12 @@ But there are exceptions to the rule. Say we want to download the Dojo widget l
179
151
 
180
152
  We can still treat Dojo as an artifact, by telling Buildr where to download it from:
181
153
 
182
- <notextile>
183
154
  {% highlight ruby %}
184
155
  DOJO = '0.2.2'
185
156
 
186
157
  url = "http://download.dojotoolkit.org/release-#{DOJO}/dojo-#{DOJO}-widget.zip"
187
158
  download(artifact("dojo:dojo:zip:widget:#{DOJO}")=>url)
188
159
  {% endhighlight %}
189
- </notextile>
190
160
 
191
161
  Explaining how it works is tricky, skip if you don't care for the details. On the other hand, it will give you a better understanding of Buildr/Rake, so if not now, come back and read it later.
192
162
 
@@ -211,22 +181,18 @@ Some artifacts do not fall into either category. In this example we're going to
211
181
 
212
182
  So let's start by creating a task that downloads the ZIP, and another one to extract it and create the JAR file:
213
183
 
214
- <notextile>
215
184
  {% highlight ruby %}
216
185
  app_zip = download('target/app.zip'=>url)
217
186
  bean_jar = file('target/app/bean.jar'=>unzip('target/app'=>app_zip))
218
187
  {% endhighlight %}
219
- </notextile>
220
188
 
221
189
  When you call @artifact@, it returns an @Artifact@ task that points to the artifact file in the local repository, downloading the file if it doesn't already exist. You can override this behavior by enhancing the task and creating the file yourself (you may also want to create a POM file). Or much simpler, call the @from@ method on the artifact and tell it where to find the source file.
222
190
 
223
191
  So the next step is to specify the artifact and tell it to use the extracted JAR file:
224
192
 
225
- <notextile>
226
193
  {% highlight ruby %}
227
194
  bean = artifact('example.com:beans:jar:1.0').from(bean_jar)
228
195
  {% endhighlight %}
229
- </notextile>
230
196
 
231
197
  The artifact still points to the local repository, but when we invoke the task it copies the source file over to the local repository, instead of attempting a download.
232
198
 
@@ -234,12 +200,10 @@ Use the @install@ method if you want the artifact and its POM installed in the l
234
200
 
235
201
  Our example ends by including the artifact in the @install@ and @upload@ tasks:
236
202
 
237
- <notextile>
238
203
  {% highlight ruby %}
239
204
  install bean
240
205
  upload bean
241
206
  {% endhighlight %}
242
- </notextile>
243
207
 
244
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@.
245
209
 
@@ -31,12 +31,10 @@ When you pass an artifact specification to @compile.with@, it creates an @Artifa
31
31
 
32
32
  For now let's just show a simple example:
33
33
 
34
- <notextile>
35
34
  {% highlight ruby %}
36
35
  compile.with 'org.apache.axis2:axis2:jar:1.2',
37
36
  'org.apache.derby:derby:jar:10.1.2.1', projects('teh-api', 'teh-impl')
38
37
  {% endhighlight %}
39
- </notextile>
40
38
 
41
39
  Passing arrays to @compile.with@ is just a convenient for handling multiple dependencies, we'll show more examples of that when we talk about "Artifacts":artifacts.html.
42
40
 
@@ -44,22 +42,18 @@ Likewise, the @compile@ task has an array of file tasks that point at the source
44
42
 
45
43
  For example, let's run the APT tool on our annotated source code before compiling it:
46
44
 
47
- <notextile>
48
45
  {% highlight ruby %}
49
46
  compile.from apt
50
47
  {% endhighlight %}
51
- </notextile>
52
48
 
53
49
  When you call @apt@ on a project, it returns a file task that points to the @target/generated/apt@ directory. This file task executes by running APT, using the same list of source directories, dependencies and compiler options. It then generates new source files in the target directory. Calling @compile.from@ with that file task includes those additional source files in the list of compiled sources.
54
50
 
55
51
  Here's another example:
56
52
 
57
- <notextile>
58
53
  {% highlight ruby %}
59
54
  jjtree = jjtree(_('src/main/jjtree'), :in_package=>'com.acme')
60
55
  compile.from javacc(jjtree, :in_package=>'com.acme'), jjtree
61
56
  {% endhighlight %}
62
- </notextile>
63
57
 
64
58
  This time, the variable @jjtree@ is a file task that reads a JJTree source file from the @src/main/jjtree@ directory, and generates additional source files in the @target/generated/jjtree@ directory. The second line creates another file task that takes those source files, runs JavaCC on them, and generates yet more source files in @target/generated/javacc@. Finally, we include both sets of source files in addition to those already in @src/main/java@, and compile the lot.
65
59
 
@@ -71,12 +65,10 @@ We use method pairs to give you finer control over the compiler, but also a way
71
65
 
72
66
  For example:
73
67
 
74
- <notextile>
75
68
  {% highlight ruby %}
76
69
  compile.from('srcs').with('org.apache.axis2:axis2:jar:1.2').
77
70
  into('classes').using(:target=>'1.4')
78
71
  {% endhighlight %}
79
- </notextile>
80
72
 
81
73
  Buildr uses the method pair and method chaining idiom in many places to make your life easier without sacrificing flexibility.
82
74
 
@@ -84,28 +76,22 @@ Occasionally, you'll need to post-process the generated bytecode. Since you onl
84
76
 
85
77
  For example, to run the OpenJPA bytecode enhancer after compiling the source files:
86
78
 
87
- <notextile>
88
79
  {% highlight ruby %}
89
80
  compile { open_jpa_enhance }
90
81
  {% endhighlight %}
91
- </notextile>
92
82
 
93
83
  You can change various compile options by calling, you guessed, @compile.options@. For example, to set the compiler to VM compatibility with Java 1.5 and turn on all Lint messages:
94
84
 
95
- <notextile>
96
85
  {% highlight ruby %}
97
86
  compile.options.target = '1.5'
98
87
  compile.options.lint = 'all'
99
88
  {% endhighlight %}
100
- </notextile>
101
89
 
102
90
  Or, if you want to chain methods together:
103
91
 
104
- <notextile>
105
92
  {% highlight ruby %}
106
93
  compile.using :target=>'1.5', :lint=>'all'
107
94
  {% endhighlight %}
108
- </notextile>
109
95
 
110
96
 
111
97
  Sub-projects inherit compile options from their parent project, so you only need to change these settings once in the top project. You can do so, even if the top project itself doesn't compile anything.
@@ -114,7 +100,6 @@ The options available to you depend on which compiler you are using for this par
114
100
 
115
101
  Buildr turns the @warning@ option on by default, but turns it off when you run @buildr --silent@. It also sets the @debug@ option on, but turns it off when making a release. You can also control the @debug@ option from the command line, for example:
116
102
 
117
- <notextile>
118
103
  {% highlight ruby %}
119
104
  # When calling buildr
120
105
  $ buildr compile debug=off
@@ -123,7 +108,6 @@ $ buildr compile debug=off
123
108
  $ export DEBUG=off
124
109
  $ buildr compile
125
110
  {% endhighlight %}
126
- </notextile>
127
111
 
128
112
  The default source and target directories, compiler settings and other options you can use depend on the specific language. You can find more information in the "Languages":languages.html section.
129
113
 
@@ -135,16 +119,13 @@ The @compile@ task comes bundled with a @resources@ task. It copies files from
135
119
 
136
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" :
137
121
 
138
- <notextile>
139
122
  {% highlight ruby %}
140
123
  resources.filter.using 'version'=>version,
141
124
  'copyright'=>'Acme Inc (C) 2007'
142
125
  {% endhighlight %}
143
- </notextile>
144
126
 
145
127
  You can also use "profiles":settings_profiles.html#profiles to supply a name/value map that all @resources@ task should default to, by adding a @filter@ element to each of the profiles. The following examples shows a @profiles.yaml@ file that applies the same filter in development and test environments:
146
128
 
147
- <notextile>
148
129
  {% highlight yaml %}
149
130
  filter: &alpha1
150
131
  version: experimental
@@ -155,7 +136,6 @@ development:
155
136
  test:
156
137
  filter: *alpha1
157
138
  {% endhighlight %}
158
- </notextile>
159
139
 
160
140
  You can specify a different format by passing it as the first argument. Supported formats include:
161
141
 
@@ -167,38 +147,30 @@ You can specify a different format by passing it as the first argument. Supporte
167
147
 
168
148
  For example, using the @:ruby@ format instead of the default @:maven@ format:
169
149
 
170
- <notextile>
171
150
  {% highlight ruby %}
172
151
  resources.filter.using :ruby, 'version'=>version,
173
152
  'copyright'=>'Acme Inc (C) 2007'
174
153
  {% endhighlight %}
175
- </notextile>
176
154
 
177
155
  For more complicated mapping you can also pass a method or a proc. The filter will call it once for each file with the file name and content.
178
156
 
179
157
  If you need to copy resource files from other directories, add these source directories by calling the @from@ method, for example:
180
158
 
181
- <notextile>
182
159
  {% highlight ruby %}
183
160
  resources.from _('src/etc')
184
161
  {% endhighlight %}
185
- </notextile>
186
162
 
187
163
  You can select to copy only specific files using common file matching patterns. For example, to include only HTML files:
188
164
 
189
- <notextile>
190
165
  {% highlight ruby %}
191
166
  resources.include '*.html'
192
167
  {% endhighlight %}
193
- </notextile>
194
168
 
195
169
  To include all files, except for files in the @scratch@ directory:
196
170
 
197
- <notextile>
198
171
  {% highlight ruby %}
199
172
  resources.exclude 'scratch/*'
200
173
  {% endhighlight %}
201
- </notextile>
202
174
 
203
175
  The filter always excludes the @CVS@ and @.svn@ directories, and all files ending with @.bak@ or @~@, so no need to worry about these.
204
176
 
@@ -208,12 +180,10 @@ You can use filters elsewhere. The @filter@ method creates a filter, the @into@
208
180
 
209
181
  For example:
210
182
 
211
- <notextile>
212
183
  {% highlight ruby %}
213
184
  filter('src/specs').into('target/specs').
214
185
  using('version'=>version, 'created'=>Time.now).run
215
186
  {% endhighlight %}
216
- </notextile>
217
187
 
218
188
  The @resources@ task is, in fact, just a wrapper around such a filter that automatically adds the @src/main/resources@ directory as one of the source directories.
219
189
 
@@ -226,24 +196,20 @@ You can extend the @build@ task in two ways. You can add more prerequisites tha
226
196
 
227
197
  Let's look at a simple example. Say we want to generate a Derby database from an SQL file and include it in the ZIP package:
228
198
 
229
- <notextile>
230
199
  {% highlight ruby %}
231
200
  db = Derby.create(_('target/derby/db')=>_('src/main/sql/derby.sql'))
232
201
  package(:zip).include db
233
202
  {% endhighlight %}
234
- </notextile>
235
203
 
236
204
  There's nothing fundamentally wrong with this code, if that's what you intend to do. But in practice, you don't always run the @package@ task during development, so you won't notice if something is wrong with this task when you build. For example, if it fails to generate the SQL file. In addition, the @package@ task runs after @build@, so you can't use the database in your test cases.
237
205
 
238
206
  So let's refactor it. We're going to use the variable @db@ to reference the file task that creates the database, and make it a prerequisite of the @build@ task. And use that same variable again to include the database in the ZIP package:
239
207
 
240
- <notextile>
241
208
  {% highlight ruby %}
242
209
  db = Derby.create(_('target/derby/db')=>_('src/main/sql/derby.sql'))
243
210
  build db
244
211
  package(:zip).include db
245
212
  {% endhighlight %}
246
- </notextile>
247
213
 
248
214
  Much better. We're using the same task twice, but since we're using Rake here, it will only execute once. In fact, it will only execute if we don't already have a Derby database, or if it detects a change to the SQL file and needs to recreate the database.
249
215
 
@@ -251,14 +217,12 @@ p(tip). @Derby.create@ is not part of Buildr, you can get "derby.rake":http://sv
251
217
 
252
218
  Here's another example. We want to copy some files over as part of the build, and apply a filter to them. This time, we're going to extend the @build@ task:
253
219
 
254
- <notextile>
255
220
  {% highlight ruby %}
256
221
  build do
257
222
  filter('src/specs').into('target/specs').
258
223
  using('version'=>version, 'created'=>Time.now).run
259
224
  end
260
225
  {% endhighlight %}
261
- </notextile>
262
226
 
263
227
  The @build@ task is recursive, so running @buildr build@ picks the current project and runs its @build@ task, which in turn runs the @build@ task on each of its sub-projects. One @build@ task to rule them all.
264
228
 
@@ -271,11 +235,9 @@ It basically erases the target directories, the one called @target@, and if you
271
235
 
272
236
  For example:
273
237
 
274
- <notextile>
275
238
  {% highlight ruby %}
276
239
  clean { rm_rf _('staged') }
277
240
  {% endhighlight %}
278
- </notextile>
279
241
 
280
242
  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.
281
243