assaf-buildr 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. data/CHANGELOG +887 -0
  2. data/DISCLAIMER +7 -0
  3. data/LICENSE +176 -0
  4. data/NOTICE +26 -0
  5. data/README.rdoc +146 -0
  6. data/Rakefile +62 -0
  7. data/_buildr +38 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/cobertura.rb +236 -0
  10. data/addon/buildr/emma.rb +238 -0
  11. data/addon/buildr/hibernate.rb +142 -0
  12. data/addon/buildr/javacc.rb +85 -0
  13. data/addon/buildr/jdepend.rb +60 -0
  14. data/addon/buildr/jetty.rb +248 -0
  15. data/addon/buildr/jibx.rb +86 -0
  16. data/addon/buildr/nailgun.rb +817 -0
  17. data/addon/buildr/openjpa.rb +90 -0
  18. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  19. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  20. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  21. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  22. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  23. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  25. data/addon/buildr/xmlbeans.rb +93 -0
  26. data/bin/buildr +28 -0
  27. data/buildr.buildfile +53 -0
  28. data/buildr.gemspec +58 -0
  29. data/doc/css/default.css +228 -0
  30. data/doc/css/print.css +100 -0
  31. data/doc/css/syntax.css +52 -0
  32. data/doc/images/apache-incubator-logo.png +0 -0
  33. data/doc/images/buildr-hires.png +0 -0
  34. data/doc/images/buildr.png +0 -0
  35. data/doc/images/favicon.png +0 -0
  36. data/doc/images/growl-icon.tiff +0 -0
  37. data/doc/images/note.png +0 -0
  38. data/doc/images/project-structure.png +0 -0
  39. data/doc/images/tip.png +0 -0
  40. data/doc/images/zbuildr.tif +0 -0
  41. data/doc/pages/artifacts.textile +207 -0
  42. data/doc/pages/building.textile +240 -0
  43. data/doc/pages/contributing.textile +208 -0
  44. data/doc/pages/download.textile +62 -0
  45. data/doc/pages/extending.textile +175 -0
  46. data/doc/pages/getting_started.textile +273 -0
  47. data/doc/pages/index.textile +42 -0
  48. data/doc/pages/languages.textile +407 -0
  49. data/doc/pages/mailing_lists.textile +17 -0
  50. data/doc/pages/more_stuff.textile +286 -0
  51. data/doc/pages/packaging.textile +427 -0
  52. data/doc/pages/projects.textile +274 -0
  53. data/doc/pages/recipes.textile +103 -0
  54. data/doc/pages/settings_profiles.textile +274 -0
  55. data/doc/pages/testing.textile +212 -0
  56. data/doc/pages/troubleshooting.textile +103 -0
  57. data/doc/pages/whats_new.textile +323 -0
  58. data/doc/print.haml +51 -0
  59. data/doc/print.toc.yaml +29 -0
  60. data/doc/scripts/buildr-git.rb +412 -0
  61. data/doc/scripts/install-jruby.sh +44 -0
  62. data/doc/scripts/install-linux.sh +64 -0
  63. data/doc/scripts/install-osx.sh +52 -0
  64. data/doc/site.haml +56 -0
  65. data/doc/site.toc.yaml +47 -0
  66. data/etc/KEYS +151 -0
  67. data/etc/git-svn-authors +16 -0
  68. data/lib/buildr.rb +35 -0
  69. data/lib/buildr/core.rb +27 -0
  70. data/lib/buildr/core/application.rb +489 -0
  71. data/lib/buildr/core/application_cli.rb +139 -0
  72. data/lib/buildr/core/build.rb +311 -0
  73. data/lib/buildr/core/checks.rb +382 -0
  74. data/lib/buildr/core/common.rb +154 -0
  75. data/lib/buildr/core/compile.rb +596 -0
  76. data/lib/buildr/core/environment.rb +120 -0
  77. data/lib/buildr/core/filter.rb +362 -0
  78. data/lib/buildr/core/generate.rb +195 -0
  79. data/lib/buildr/core/help.rb +118 -0
  80. data/lib/buildr/core/progressbar.rb +156 -0
  81. data/lib/buildr/core/project.rb +892 -0
  82. data/lib/buildr/core/test.rb +715 -0
  83. data/lib/buildr/core/transports.rb +558 -0
  84. data/lib/buildr/core/util.rb +289 -0
  85. data/lib/buildr/groovy.rb +18 -0
  86. data/lib/buildr/groovy/bdd.rb +105 -0
  87. data/lib/buildr/groovy/compiler.rb +138 -0
  88. data/lib/buildr/ide.rb +19 -0
  89. data/lib/buildr/ide/eclipse.rb +212 -0
  90. data/lib/buildr/ide/idea.ipr.template +300 -0
  91. data/lib/buildr/ide/idea.rb +189 -0
  92. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  93. data/lib/buildr/ide/idea7x.rb +210 -0
  94. data/lib/buildr/java.rb +23 -0
  95. data/lib/buildr/java/ant.rb +92 -0
  96. data/lib/buildr/java/bdd.rb +449 -0
  97. data/lib/buildr/java/commands.rb +211 -0
  98. data/lib/buildr/java/compiler.rb +348 -0
  99. data/lib/buildr/java/deprecated.rb +141 -0
  100. data/lib/buildr/java/jruby.rb +117 -0
  101. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  102. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  103. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +119 -0
  104. data/lib/buildr/java/packaging.rb +713 -0
  105. data/lib/buildr/java/pom.rb +178 -0
  106. data/lib/buildr/java/rjb.rb +155 -0
  107. data/lib/buildr/java/test_result.rb +308 -0
  108. data/lib/buildr/java/tests.rb +324 -0
  109. data/lib/buildr/java/version_requirement.rb +172 -0
  110. data/lib/buildr/packaging.rb +21 -0
  111. data/lib/buildr/packaging/artifact.rb +730 -0
  112. data/lib/buildr/packaging/artifact_namespace.rb +972 -0
  113. data/lib/buildr/packaging/artifact_search.rb +140 -0
  114. data/lib/buildr/packaging/gems.rb +102 -0
  115. data/lib/buildr/packaging/package.rb +233 -0
  116. data/lib/buildr/packaging/tar.rb +104 -0
  117. data/lib/buildr/packaging/zip.rb +722 -0
  118. data/lib/buildr/resources/buildr.icns +0 -0
  119. data/lib/buildr/scala.rb +19 -0
  120. data/lib/buildr/scala/compiler.rb +109 -0
  121. data/lib/buildr/scala/tests.rb +203 -0
  122. data/rakelib/apache.rake +191 -0
  123. data/rakelib/changelog.rake +57 -0
  124. data/rakelib/doc.rake +103 -0
  125. data/rakelib/package.rake +73 -0
  126. data/rakelib/release.rake +65 -0
  127. data/rakelib/rspec.rake +83 -0
  128. data/rakelib/rubyforge.rake +53 -0
  129. data/rakelib/scm.rake +49 -0
  130. data/rakelib/setup.rake +86 -0
  131. data/rakelib/stage.rake +48 -0
  132. data/spec/addon/cobertura_spec.rb +77 -0
  133. data/spec/addon/emma_spec.rb +120 -0
  134. data/spec/addon/test_coverage_spec.rb +255 -0
  135. data/spec/core/application_spec.rb +412 -0
  136. data/spec/core/artifact_namespace_spec.rb +646 -0
  137. data/spec/core/build_spec.rb +415 -0
  138. data/spec/core/checks_spec.rb +537 -0
  139. data/spec/core/common_spec.rb +664 -0
  140. data/spec/core/compile_spec.rb +566 -0
  141. data/spec/core/generate_spec.rb +33 -0
  142. data/spec/core/project_spec.rb +754 -0
  143. data/spec/core/test_spec.rb +1091 -0
  144. data/spec/core/transport_spec.rb +500 -0
  145. data/spec/groovy/bdd_spec.rb +80 -0
  146. data/spec/groovy/compiler_spec.rb +239 -0
  147. data/spec/ide/eclipse_spec.rb +243 -0
  148. data/spec/java/ant.rb +28 -0
  149. data/spec/java/bdd_spec.rb +358 -0
  150. data/spec/java/compiler_spec.rb +446 -0
  151. data/spec/java/java_spec.rb +88 -0
  152. data/spec/java/packaging_spec.rb +1103 -0
  153. data/spec/java/tests_spec.rb +466 -0
  154. data/spec/packaging/archive_spec.rb +503 -0
  155. data/spec/packaging/artifact_spec.rb +754 -0
  156. data/spec/packaging/packaging_helper.rb +63 -0
  157. data/spec/packaging/packaging_spec.rb +589 -0
  158. data/spec/sandbox.rb +137 -0
  159. data/spec/scala/compiler_spec.rb +228 -0
  160. data/spec/scala/tests_spec.rb +215 -0
  161. data/spec/spec_helpers.rb +304 -0
  162. data/spec/version_requirement_spec.rb +123 -0
  163. metadata +369 -0
@@ -0,0 +1,212 @@
1
+ h1. Testing
2
+
3
+ Untested code is broken code, so we take testing seriously. Off the bat you get to use either JUnit or TestNG for writing unit tests and integration tests. And you can also add your own framework, or even script tests using Ruby. But= first, let's start with the basics.
4
+
5
+
6
+ h2. Writing Tests
7
+
8
+ Each project has a @TestTask@ that you can access using the @test@ method. @TestTask@ reflects on the fact that each project has one task responsible for getting the tests to run and acting on the results. But in fact there are several tasks that do all the work, and a @test@ task coordinates all of that.
9
+
10
+ The first two tasks to execute are @test.compile@ and @test.resources@. They work similar to @compile@ and @resources@, but uses a different set of directories. For example, Java tests compile from the @src/test/java@ directory into the @target/test/classes@ directory, while resources are copied from @src/test/resources@ into @target/test/resources@.
11
+
12
+ The @test.compile@ task will run the @compile@ task first, then use the same dependencies to compile the test classes. That much you already assumed. It also adds the test framework (e.g. JUnit, TestNG) and JMock to the dependency list. Less work for you.
13
+
14
+ If you need more dependencies, the best way to add them is by calling @test.with@. This method adds dependencies to both @compile.dependencies@ (for compiling) and @test.dependencies@ (for running). You can manage these two dependency lists separately, but using @test.with@ is good enough in more cases.
15
+
16
+ Once compiled, the @test@ task runs all the tests.
17
+
18
+ Different languages use different test frameworks. You can find out more about available test frameworks in the "Languages":languages.html section.
19
+
20
+
21
+ h2. Excluding Tests and Ignoring Failures
22
+
23
+ If you have a lot of tests that are failing or just hanging there collecting dusts, you can tell Buildr to ignore them. You can either tell Buildr to only run specific tests, for example:
24
+
25
+ {{{!ruby
26
+ test.include 'com.acme.tests.passing.*'
27
+ }}}
28
+
29
+ Or tell it to exclude specific tests, for example:
30
+
31
+ {{{!ruby
32
+ test.exclude '*FailingTest', '*FailingWorseTest'
33
+ }}}
34
+
35
+ Note that we're always using the package qualified class name, and you can use star (@*@) to substitute for any set of characters.
36
+
37
+ When tests fail, Buildr fails the @test@ task. This is usually a good thing, but you can also tell Buildr to ignore failures by resetting the @:fail_on_failure@ option:
38
+
39
+ {{{!ruby
40
+ test.using :fail_on_failure=>false
41
+ }}}
42
+
43
+ Besides giving you a free pass to ignore failures, you can use it for other causes, for example, to be somewhat forgiving:
44
+
45
+ {{{!ruby
46
+ test do
47
+ fail 'More than 3 tests failed!' if test.failed_tests.size > 3
48
+ end
49
+ }}}
50
+
51
+ The @failed_tests@ collection holds the names of all classes with failed tests. And there's @classes@, which holds the names of all test classes. Ruby arithmetic allows you to get the name of all passed test classes with a simple @test.classes – test.failed_tests@. We'll let you imagine creative use for these two.
52
+
53
+
54
+ h2. Running Tests
55
+
56
+ It's a good idea to run tests every time you change the source code, so we wired the @build@ task to run the @test@ task at the end of the build. And conveniently enough, the @build@ task is the default task, so another way to build changes in your code and run your tests:
57
+
58
+ {{{!sh
59
+ $ buildr
60
+ }}}
61
+
62
+ That only works with the local @build@ task and any local task that depends on it, like @package@, @install@ and @upload@. Each project also has its own @build@ task that does not invoke the @test@ task, so @buildr build@ will run the tests cases, but @buildr foo:build@ will not.
63
+
64
+ While it's a good idea to always run your tests, it's not always possible. There are two ways you can get @build@ to not run the @test@ task. You can set the environment variable @test@ to @no@ (but @skip@ and @off@ will also work). You can do that when running Buildr:
65
+
66
+ {{{!sh
67
+ $ buildr test=no
68
+ }}}
69
+
70
+ Or set it once in your environment:
71
+
72
+ {{{!sh
73
+ $ export TEST=no
74
+ $ buildr
75
+ }}}
76
+
77
+ If you're feeling really adventurous, you can also disable tests from your Buildfile or @buildr.rb@ file, by setting @options.test = false@. We didn't say it's a good idea, we're just giving you the option.
78
+
79
+ The @test@ task is just smart enough to run all the tests it finds, but will accept include/exclude patterns. Often enough you're only working on one broken test and you only want to run that one test. Better than changing your Buildfile, you can run the @test@ task with a pattern. For example:
80
+
81
+ {{{!sh
82
+ $ buildr test:KillerAppTest
83
+ }}}
84
+
85
+ Buildr will then run only tests that match the pattern @KillerAppTest@. It uses pattern matching, so @test:Foo@ will run @com.acme.FooTest@ and @com.acme.FooBarTest@. With Java, you can use this to pick a class name, or a package name to run all tests in that package, or any such combination. In fact, you can specify several patterns separated with commas. For example:
86
+
87
+ {{{!sh
88
+ $ buildr test:FooTest,BarTest
89
+ }}}
90
+
91
+ As you probably noticed, Buildr will stop your build at the first test that fails. We think it's a good idea, except when it's not. If you're using a continuous build system, you'll want a report of all the failed tests without stopping at the first failure. To make that happen, set the environment variable @test@ to "all", or the Buildr @options.test@ option to @:all@. For example:
92
+
93
+ {{{!sh
94
+ $ buildr package test=all
95
+ }}}
96
+
97
+ We're using @package@ and not @build@ above. When using a continuous build system, you want to make sure that packages are created, contain the right files, and also run the integration tests.
98
+
99
+
100
+ h2. Integration Tests
101
+
102
+ So far we talked about unit tests. Unit tests are run in isolation on the specific project they test, in an isolated environment, generally with minimal setup and teardown. You get a sense of that when we told you tests run after the @build@ task, and include JMock in the dependency list.
103
+
104
+ In contrast, integration tests are run with a number of components, in an environment that resembles production, often with more complicates setup and teardown procedures. In this section we'll talk about the differences between running unit and integration tests.
105
+
106
+ You write integration tests much the same way as you write unit tests, using @test.compile@ and @test.resources@. However, you need to tell Buildr that your tests will execute during integration test. To do so, add the following line in your project definition:
107
+
108
+ {{{!ruby
109
+ test.using :integration
110
+ }}}
111
+
112
+ Typically you'll use unit tests in projects that create internal modules, such as JARs, and integration tests in projects that create components, such as WARs and EARs. You only need to use the @:integration@ option with the later.
113
+
114
+ To run integration tests on the current project:
115
+
116
+ {{{!sh
117
+ $ buildr integration
118
+ }}}
119
+
120
+ You can also run specific tests cases, for example:
121
+
122
+ {{{!sh
123
+ $ buildr integration:ClientTest
124
+ }}}
125
+
126
+ If you run the @package@ task (or any task that depends on it, like @install@ and @upload@), Buildr will first run the @build@ task and all its unit tests, and then create the packages and run the integration tests. That gives you full coverage for your tests and ready to release packages. As with unit tests, you can set the environment variable @test@ to "no" to skip integration tests, or "all" to ignore failures.
127
+
128
+
129
+ h2. Using Setup and Teardown
130
+
131
+ Some tests need you to setup an environment before they run, and tear it down afterwards. The test frameworks (JUnit, TestNG) allow you to do that for each test. Buildr provides two additional mechanisms for dealing with more complicated setup and teardown procedures.
132
+
133
+ Integration tests run a setup task before the tests, and a teardown task afterwards. You can use this task to setup a Web server for testing your Web components, or a database server for testing persistence. You can access either task by calling @integration.setup@ and @integration.teardown@. For example:
134
+
135
+ {{{!ruby
136
+ integration.setup { server.start ; server.deploy }
137
+ integration.teardown { server.stop }
138
+ }}}
139
+
140
+ Depending on your build, you may want to enhance the setup/teardown tasks from within a project, for example, to populate the database with data used by that project's test, or from outside the project definition, for example, to start and stop the Web server.
141
+
142
+ Likewise, each project has its own setup and teardown tasks that are run before and after tests for that specific project. You can access these tasks using @test.setup@ and @test.teardown@.
143
+
144
+
145
+ h2. Testing Your Build
146
+
147
+ So you got the build running and all the tests pass, binaries are shipping when you find out some glaring omissions. The license file is empty, the localized messages for Japanese are missing, the CSS files are not where you expect them to be. The fact is, some errors slip by unit and integration tests. So how do we make sure the same mistake doesn't happen again?
148
+
149
+ Each project has a @check@ task that runs just after packaging. You can use this task to verify that your build created the files you wanted it to create. And to make it extremely convenient, we introduced the notion of expectations.
150
+
151
+ You use the @check@ method to express and expectation. Buildr will then run all these expectations against your project, and fail at the first expectation that doesn't match. An expectation says three things. Let's look at a few examples:
152
+
153
+ {{{!ruby
154
+ check package(:war), 'should exist' do
155
+ it.should exist
156
+ end
157
+ check package(:war), 'should contain a manifest' do
158
+ it.should contain('META-INF/MANIFEST.MF')
159
+ end
160
+ check package(:war).path('WEB-INF'), 'should contain files' do
161
+ it.should_not be_empty
162
+ end
163
+ check package(:war).path('WEB-INF/classes'), 'should contain classes' do
164
+ it.should contain('**/*.class')
165
+ end
166
+ check package(:war).entry('META-INF/MANIFEST'), 'should have license' do
167
+ it.should contain(/Copyright (C) 2007/)
168
+ end
169
+ check file('target/classes'), 'should contain class files' do
170
+ it.should contain('**/*.class')
171
+ end
172
+ check file('target/classes/killerapp/Code.class'), 'should exist' do
173
+ it.should exist
174
+ end
175
+ }}}
176
+
177
+ The first argument is the subject, or the project if you skip the first argument. The second argument is the description, optional, but we recommend using it. The method @it@ returns the subject.
178
+
179
+ You can also write the first expectation like this:
180
+
181
+ {{{!ruby
182
+ check do
183
+ package(:jar).should exist
184
+ end
185
+ }}}
186
+
187
+ We recommend using the subject and description, they make your build easier to read and maintain, and produce better error messages.
188
+
189
+ There are two methods you can call on just about any object, called @should@ and @should_not@. Each method takes an argument, a matcher, and executes that matcher. If the matcher returns false, @should@ fails. You can figure out what @should_not@ does in the same case.
190
+
191
+ Buildr provides the following matchers:
192
+
193
+ |_. Method |_. Checks that ... |
194
+ | @exist@ | Given a file task checks that the file (or directory) exists. |
195
+ | @empty@ | Given a file task checks that the file (or directory) is empty. |
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
+
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.
199
+
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
+
202
+ Buildr expectations are based on RSpec. "RSpec":http://rspec.info/ is the behavior-driven development framework we use to test Buildr itself. Check the RSpec documentation if want to see all the supported matchers, or want to write your own.
203
+
204
+
205
+ h2. Behaviour-Driven Development
206
+
207
+ Buildr supports several Behaviour-Driven Development(BDD) frameworks for testing your projects. Buildr follows each framework naming conventions, searching for files under the @src/spec/{lang}@ directory.
208
+
209
+ You can learn more about each BDD framework in the "Languages":languages.html section.
210
+
211
+
212
+ Next, let's talk about "customizing your environment and using profiles":settings_profiles.html
@@ -0,0 +1,103 @@
1
+ h1. Troubleshooting
2
+
3
+ Common troubleshooting tips collected from the mailing list.
4
+
5
+
6
+ h2. Running out of heap space
7
+
8
+ You can give the JVM more heap space by setting the @JAVA_OPTS@ environment variables. This environment variable provides arguments for staring the JVM. For example, to set the heap space to 1GB:
9
+
10
+ {{{!sh
11
+ $ export "JAVA_OPTS=-Xms1g -Xmx1g"
12
+ $ buildr compile
13
+ }}}
14
+
15
+ If you're sharing the build with other developers, you'll want to specify these options in the Buildfile itself. You can set the environment variable within the Buildfile, but make sure to do so at the very top of the Buildfile.
16
+
17
+ For example:
18
+
19
+ {{{!ruby
20
+ ENV['JAVA_OPTS'] = '-Xms1g -Xmx1g'
21
+ }}}
22
+
23
+
24
+ h2. RJB fails to compile
25
+
26
+ On Linux, BSD and Cygwin, RJB locates the JDK headers files -- which it uses to compile a native C extension -- based on the @JAVA_HOME@ environment variable. Make sure @JAVA_HOME@ points to the JDK, not JRE.
27
+
28
+ If you are using @sudo gem install@, note that some environments do not pass the @JAVA_HOME@ environment variable over to @sudo@. To get around this, run @gem@ with the @env JAVA_HOME=$JAVA_HOME@ option:
29
+
30
+ {{{!sh
31
+ $ sudo env JAVA_HOME=$JAVA_HOME gem install buildr
32
+ }}}
33
+
34
+
35
+ h2. Segmentation Fault when running Java code
36
+
37
+ This is most likely a JVM inconsistency, for example, when part of the RJB library uses JDK 1.6, the other part uses JDK 1.5.
38
+
39
+ During installation RJB builds a native C extension using header files supplied by the JVM, and compiles a Java bridge class using the Javac. It is possible for RJB to use two different versions of the JVM, for example, if @JAVA_HOME@ points to JDK 1.5, but @/usr/bin/javac@ points to JDK 1.6.
40
+
41
+ Make sure @JAVA_HOME@ and @/usr/bin/javac@ both point to the same JDK:
42
+
43
+ {{{!sh
44
+ echo $JAVA_HOME
45
+ ls -l /usr/bin/javac
46
+ }}}
47
+
48
+ *Note:* It seems that RJB works with Java 6, except when it doesn't, and for a few people it doesn't. In that case, either switch to Java 1.5, or simply run Buildr on JRuby using Java 6.
49
+
50
+
51
+ h2. Bugs resulting from a dangling comma or period
52
+
53
+ Ruby statements don't need a delimiter and can span multiple lines, which can lead to bugs resulting from dangling commas and periods left at the end of the line. For example:
54
+
55
+ {{{!ruby
56
+ compile.with 'org.apache.axis2:axis2:jar:1.2',
57
+ test.with 'log4j:log4j:jar:1.1'
58
+ }}}
59
+
60
+ This is actually a single method call with two arguments, separated by a comma. The second argument is the result of calling @test.with@, and makes the test task a pre-requisite of the compile task, leading to a circular dependency.
61
+
62
+ As you can imagine this happens usually after editing, specifically for commas and periods which are small enough that you won't notice them from a cursory glance at the code, so if all else fails, search for lines that end with one of these characters.
63
+
64
+
65
+ h2. Missing POM breaks transitive dependencies
66
+
67
+ Occasionally, artifacts are deployed to remote repositories with missing or broken POMs. Buildr will fail when attempting to resolve transitive dependencies with broken or missing POMs.
68
+
69
+ In this particular case, failing is doing the right thing. There's no way for Buildr to tell whether the POM is nowhere to be found, or just a temporary problem accessing the remote server.
70
+
71
+ If you can determine that the POM file is missing you can work around the problem in three ways. If you published the artifact, make the release again, getting it to upload the missing files.
72
+
73
+ If the source repository is not under your control, but you are also using your own repository for the project, you can always create a dummy POM in your own repository. Buildr will attempt to download the file from either repository, using the first file it finds.
74
+
75
+ Alternatively, you can make Buildr create a dummy POM file in the local repository, instead of downloading it from a remote repository. This example creates a dummy POM for Axis JAX-RPC:
76
+
77
+ {{{!ruby
78
+ artifact 'axis:axis-jaxrpc:pom:1.3' do |task|
79
+ write task.name, <<-POM
80
+ <project>
81
+ <modelVersion>4.0.0</modelVersion>
82
+ <groupId>axis</groupId>
83
+ <artifactId>axis-jaxrpc</artifactId>
84
+ <version>1.4</version>
85
+ </project>
86
+ POM
87
+ end
88
+ }}}
89
+
90
+
91
+ h2. Buildr fails to run after install with a "stack level too deep (SystemStackError)" error
92
+
93
+ A particular quirk of an existing Ruby setup can cause problems when running Buildr. If a system already has several Ruby directories that are in the @PATH@, it is often nice (appropriate?) to have them in @RUBYLIB@ as well (to be able to require them). If there are several of them a user may decide that @RUBYLIB=$PATH@ is a good way to handle this (or some less automated method that has the same effect).
94
+
95
+ The culprit is having the Gem's binary directory show up in @RUBYLIB@. For example, Buildr's @bin/buildr@ includes this line:
96
+
97
+ {{{!sh
98
+ require 'buildr'
99
+ }}}
100
+
101
+ Under normal circumstances, this tells RubyGems to load @buildr.rb@ from the Gem's library directory. When @RUBYLIB@ points to the Gem's @bin@ directory, it ends up loading itself repeatedly.
102
+
103
+ To solve this, remove Buildr's @bin@ directory from @RUBYLIB@. Removing all directories that you don't actually need is better (other Gems may have the same problem).
@@ -0,0 +1,323 @@
1
+ h1. What's New
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
+
14
+ h2. Buildr 1.3.2
15
+
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@.
17
+ * Upgraded to latest release of Net::SSH, Net::SFTP, RubyForge and RubyGems.
18
+ * Upgraded to JUnit 4.4 and fixed case where abstract classes extending TestCase would lead to tests failing.
19
+ * The target/test/class and /resources directories now come first in the classpath, ahead of any code compiled code and resources copied over from src/main.
20
+ * Fixed: BUILDR-90 Installing from source doesn't work with JRuby.
21
+ * Fixed: BUILDR-91 When doing a release, buildr should spawn the same version of buildr
22
+ * Fixed: BUILDR-92 IDEA 7x: add resources directories to classpath.
23
+ * Fixed: BUILDR-95: Only download Scala test framework artifacts when required
24
+ * Fixed: BUILDR-100 Directory structure documentation needs updating.
25
+ * Fixed: Installation instructions updated for RubyGems 1.2.0.
26
+
27
+
28
+ h2. Buildr 1.3.1
29
+
30
+ * Fixed to specific Gem dependencies, so should install cleanly on Windows.
31
+ * Buildr now supports publishing files to HTTP server for remote repositories that support HTTP uploads (PUT).
32
+ * Buildr now supports reading files from SFTP server and upgrades to Net::SSH 2.0 and Net::SFTP 2.0.
33
+ * HTTP downloads now accept URLs with query parameters (Tommy Knowlton).
34
+ * On OS X if you are not using the default JDK, you can set the JAVA_HOME environment variable to point to any other JDK (Nathan Hamblen).
35
+ * JUnit properly passes options[:environment] as environment variables to the test case. In addition options[:java_args] are now passed as arguments to the JVM, for example to set heap size, only applicable when forking (the default mode when running JUnit).
36
+ * Fixed BUILDR-75: Filter now runs if there's a target directory, even if there are no source files to copy over, and creates an empty target directory. The previous behavior caused some problems with code that checked if resource.target was nil, but didn't check if there are any resource.sources to process.
37
+ * Added the jibx_bind method to use JiBX for Java<=>XML binding (by David Peterson).
38
+
39
+
40
+ h2. Buildr 1.3
41
+
42
+ h3. Multiple Languages
43
+
44
+ The main focus of this release is supporting multiple languages for compiling and testing.
45
+
46
+ For each project, Buildr will attempt to infer which compiler to use based on the source files it finds, for example, if it finds @.java@ files in the @src/main/java@ directory, it will switch to the javac compiler, if it finds @.scala@ files in the @src/main/scala@ directory, to the scalac compiler and so forth.
47
+
48
+ Different compilers may use different target directory, @target/classes@ is picked for JVM compilers (Java, Scala, Groovy, etc), so resources are not copied to their own directory, @target/resources@. The prepare task has been removed.
49
+
50
+ Not all languages have classpaths, so @compile.classpath@ is now known as @compile.dependencies@, but the old attribute still exists for backward compatibility.
51
+
52
+ Also, for consistency, the test target directories have changed to @target/test/classes@ and @target/test/resources@, respectively.
53
+
54
+ Speaking of tests, you can compile code in one language and use a different language to test it, say, if you're interested in compiling Java code and testing it with Ruby, or compiling Flash and running a Java test suite.
55
+
56
+ As before, you can pick the test framework by calling @test.using(<framework>)@. Buildr will attempt to pick one by default, for example, if the tests are written in Java, it will default to JUnit.
57
+
58
+ And, since not all languages package to JARs, the default packaging is either inferred from the compiler (so @:jar@ when compiling Java code), otherwise to @:zip@. All this defaulting means that @package()@ with no arguments does the right thing in more cases, and most probably won't break anyone's buildfiles.
59
+
60
+ I've tried to keep the compiler API as simple as possible, making it easy to add new compilers; however, I had to change the test framework API to accommodate the new features, so old test frameworks will not work on 1.3.
61
+
62
+
63
+ h3. Scala Support
64
+
65
+ Buildr now supports "Scala":http://www.scala-lang.org/, using both native and fast Scala compiler.
66
+
67
+ Read more about "using Scala":languages.html#scala.
68
+
69
+
70
+ h3. Groovy Support
71
+
72
+ Buildr now supports Groovy, using the Groovyc Ant task.
73
+
74
+ Read more about "using Groovy":languages.html#groovy.
75
+
76
+
77
+ h3. Packaging Files
78
+
79
+ The @package@ method is convenient enough that you can now use it to generate artifacts, an in addition to generate regular file tasks, specifying the file name using the @:file@ attribute. For example:
80
+
81
+ {{{!ruby
82
+ package :zip, :file=>_('target/interesting.zip')
83
+ }}}
84
+
85
+ Since this package is not an artifact and does not have a specification, it will not automatically install itself in the local repository or upload to a remote repository. For these, use the @package@ method as before.
86
+
87
+ Read more about "the package method":packaging.html#specifying_and_referencing_packages.
88
+
89
+
90
+ h3. Packaging EARs
91
+
92
+ EAR packages support four component types:
93
+
94
+ |_. Argument |_. Component |
95
+ | @:war@ | J2EE Web Application (WAR). |
96
+ | @:ejb@ | Enterprise Java Bean (JAR). |
97
+ | @:jar@ | J2EE Application Client (JAR). |
98
+ | @:lib@ | Shared library (JAR). |
99
+
100
+ This example shows two ways for adding components built by other projects:
101
+
102
+ {{{!ruby
103
+ package(:ear) << project('coolWebService').package(:war)
104
+ package(:ear).add project('commonLib') # By default, the JAR package
105
+ }}}
106
+
107
+ EAR packages include an @application.xml@ file in the @META-INF@ directory that describes the application and its component. This file is created for you during packaging, by referencing all the components added to the EAR. There are a couple of things you will typically want to change.
108
+
109
+ * *display-name* -- The application's display name defaults to the project's identifier. You can change that by setting the @display_name@ attribute.
110
+
111
+ * *context-root* -- WAR components specify a context root, based on the package identifier, for example, "cool-web-1.0.war" will have the context root "cool-web". To specify a different context root, add the WAR package with the @context_root@ option.
112
+
113
+ "Read more ...":packaging.html#packaging_ears
114
+
115
+
116
+ h3. JRuby Support
117
+
118
+ We now offer two versions of Buildr, one for Ruby and one for JRuby. They're exactly the same, except the Ruby version will also install RJB (Ruby Java Bridge), the JRuby version obviously can do well without it.
119
+
120
+ "Read more ...":download.html#jruby
121
+
122
+ Buildr provides a "Nailgun":http://www.martiansoftware.com/nailgun/index.html server when running on JRuby. Using the integrated BuildrServer allows for faster task execution and avoid frequent JVM startup overhead.
123
+
124
+ "Read more ...":more_stuff.html#nailgun
125
+
126
+
127
+ h3. Behaviour-Driven Development
128
+
129
+ Given that many languages are now supported by Buildr, the same is true for testing, the convention is to store BDD files under the @src/spec/{lang}@ directory. The following table shows the framework's name you can use to select them for your projects. Buildr follows each framework's naming convention.
130
+
131
+ |_. test.using |_. Test file name convention |
132
+ | @:jbehave@ | @src/spec/java/**/*Behaviour.java@ |
133
+ | @:rspec@ | @src/spec/ruby/**/*_spec.rb@ |
134
+ | @:easyb@ | @src/spec/groovy/**/*{Story,Behavior}.groovy@ |
135
+
136
+ "Read more ...":testing.html#bdd
137
+
138
+
139
+ h3. Profiles
140
+
141
+ Different environments may require different configurations, some you will want to control with code, others you will want to specify in the profiles file.
142
+
143
+ The profiles file is a YAML file called @profiles.yaml@ that you place in the same directory as the Buildfile. We selected YAML because it's easier to read and edit than XML.
144
+
145
+ For example, to support three different database configurations, we could write:
146
+
147
+ {{{!yaml
148
+ # HSQL, don't bother storing to disk.
149
+ development:
150
+ db: hsql
151
+ jdbc: hsqldb:mem:devdb
152
+
153
+ # Make sure we're not messing with bigstrong.
154
+ test:
155
+ db: oracle
156
+ jdbc: oracle:thin:@localhost:1521:test
157
+
158
+ # The real deal.
159
+ production:
160
+ db: oracle
161
+ jdbc: oracle:thin:@bigstrong:1521:mighty
162
+ }}}
163
+
164
+ You can also use profiles to specify default filters for the "@resources@ task":building.html#resources.
165
+
166
+ "Read more ...":settings_profiles.html#profiles
167
+
168
+
169
+ h3. Settings and build YAML files
170
+
171
+ In addition to profiles, we also allow you to specify personal and build settings using two YAML files.
172
+
173
+ Personal settings are placed in the @.buildr/settings.yaml@ file under your home directory. Settings stored there will be applied the same across all builds.
174
+
175
+ For example:
176
+
177
+ {{{!yaml
178
+ # The repositories hash is read automatically by buildr.
179
+ repositories:
180
+
181
+ # customize user local maven2 repository location
182
+ local: some/path/to/my_repo
183
+
184
+ relase_to:
185
+ url: http://intra.net/maven2
186
+ username: john
187
+ password: secret
188
+
189
+ # You can place settings of your own, and reference them
190
+ # on buildfiles.
191
+ im:
192
+ server: jabber.company.com
193
+ usr: notifier@company-jabber.com
194
+ pwd: secret
195
+ }}}
196
+
197
+ "Read more ...":settings_profiles.html#personal_settings
198
+
199
+ Build settings are placed in the @build.yaml@ file located in the same directory that the @buildfile@. Normally this file would be managed by the project revision control system, so settings here are shared between developers.
200
+
201
+ For example:
202
+
203
+ {{{!yaml
204
+ # This project requires the following ruby gems, buildr addons
205
+ gems:
206
+ # Suppose we want to notify developers when testcases fail.
207
+ - buildr-twitter-notifier-addon >=1
208
+ # we test with ruby mock objects
209
+ - mocha
210
+ - ci_reporter
211
+
212
+ # The artifact declarations will be automatically loaded by buildr, so that
213
+ # you can reference artifacts by name (a ruby-symbol) on your buildfile.
214
+ artifacts:
215
+ spring: org.springframework:spring:jar:2.0
216
+ log4j: log4j:log4j:jar:1.0
217
+ j2ee: geronimo-spec:geronimo-spec:j2ee:jar:1.4-rc4
218
+
219
+ # Of course project settings can be defined here
220
+ jira:
221
+ uri: https://jira.corp.org
222
+ }}}
223
+
224
+ "Read more ...":settings_profiles.html#build_settings
225
+
226
+
227
+ h3. Using Gems for extensions and 3rd party libraries
228
+
229
+ "RubyGems":http://rubygems.rubyforge.org provides the @gem@ command line tool that you can use to search, install, upgrade, package and distribute gems. It installs all gems into a local repository that is shared across your builds and all other Ruby applications you may have running. You can install a gem from a local file, or download and install it from any number of remote repositories.
230
+
231
+ If your build depends on other gems, you will want to specify these dependencies as part of your build and check that configuration into source control. That way you can have a specific environment that will guarantee repeatable builds, whether you're building a particular version, moving between branches, or joining an existing project. Buildr will take care of installing all the necessary dependencies, which you can then manage with the @gem@ command.
232
+
233
+ Use the @build.yaml@ file to specify these dependencies (see "Build Settings":settings_profiles.html#build_settings for more information), for example:
234
+
235
+ {{{!yaml
236
+ # This project requires the following gems
237
+ gems:
238
+ # Suppose we want to notify developers when testcases fail.
239
+ - buildr-twitter-notifier-addon >=1
240
+ # we test with ruby mock objects
241
+ - mocha
242
+ - ci_reporter
243
+ }}}
244
+
245
+ "Read more ...":more_stuff.html#using_gems
246
+
247
+
248
+ h3. New API for accessing Java libraries
249
+
250
+ Java classes are accessed as static methods on the @Java@ module, for example:
251
+
252
+ {{{!ruby
253
+ str = Java.java.lang.String.new('hai!')
254
+ str.toUpperCase
255
+ => 'HAI!'
256
+ Java.java.lang.String.isInstance(str)
257
+ => true
258
+ Java.com.sun.tools.javac.Main.compile(args)
259
+ }}}
260
+
261
+ The @classpath@ attribute allows Buildr to add JARs and directories to the classpath, for example, we use it to load Ant and various Ant tasks, code generators, test frameworks, and so forth.
262
+
263
+ For example, Ant is loaded as follows:
264
+
265
+ {{{!ruby
266
+ Java.classpath << 'org.apache.ant:ant:jar:1.7.0'
267
+ }}}
268
+
269
+ Artifacts can only be downloaded after the Buildfile has loaded, giving it a chance to specify which remote repositories to use, so adding to classpath does not by itself load any libraries. You must call @Java.load@ before accessing any Java classes to give Buildr a chance to load the libraries specified in the classpath.
270
+
271
+ "Read more ...":more_stuff.html#using_java_libraries
272
+
273
+
274
+ h3. Creating Extensions
275
+
276
+ 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:
277
+
278
+ {{{!ruby
279
+ class Project
280
+ include MyExtension
281
+ end
282
+ }}}
283
+
284
+ You can also extend a given project instance and only that instance by extending it with the module:
285
+
286
+ {{{!ruby
287
+ define 'foo' do
288
+ extend MyExtension
289
+ end
290
+ }}}
291
+
292
+ Some extensions require tighter integration with the project, specifically for setting up tasks and properties, or for configuring tasks based on the project definition. You can do that by adding callbacks to the process.
293
+
294
+ "Read more ...":extending.html#creating_extensions
295
+
296
+
297
+ h3. Using Alternative Layouts
298
+
299
+ 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.
300
+
301
+ A layout is an object that implements the @expand@ method. The easiest way to define a custom layout is to create a new @Layout@ object and specify mapping between names used by Buildr and actual paths within the project.
302
+
303
+ "Read more ...":extending.html#using_alternative_layouts
304
+
305
+
306
+ h3. Other
307
+
308
+ * Buildr 1.3 upgrades to Rake 0.8, RSpec 1.1, RJB 1.1 and OpenJPA 1.0.1. Buildr no longer includes or uses Facets.
309
+ * JUnit tests now operate on all compiled test classes that extend @junit.framework.TestCase@ or use the @Test@ annotation; TestNG test cases are filtered by annotation. Test cases no longer have to use a specific file name.
310
+ * Remote repositories now support HTTP Basic Authentication.
311
+ * The prepare task has been removed, if you need to, simply add a prerequisite to the compile task.
312
+
313
+
314
+ h3. Documentation
315
+
316
+ * The "What's new?":whats_new.html page (this one, actually), summarizes all the important new features and changes in each release.
317
+ * The "Recipes":recipes.html page (also available in the PDF) lists recipes for using Buildr, collected from the mailing list. Feel free to contribute tips, tricks and techniques.
318
+ * The "Troubleshooting":troubleshooting.html page (also available in the PDF) collects troubleshooting ideas from the mailing list.
319
+ * The "Getting Started":getting_started.html has been rewritten to cover all you need to know about downloading and installing Buildr on Linux, OS X, Windows and with JRuby (1.1 or later).
320
+ * A new "Contributing":contributing.html page has more details on how to file bugs, policy for submitting patches, running Buildr test cases, and helping with the documentation.
321
+ * A new page for "Settings and Profiles":settings_profiles.html.
322
+ * The "Extending Buildr":extending.html page that deals with writing your own tasks, creating extensions and specifying alternative layouts.
323
+ * The site also includes "RSpec report":specs.html which provides the official specification against which we test each release.