vic-buildr 1.3.1 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. data/CHANGELOG +90 -8
  2. data/{README → README.rdoc} +29 -16
  3. data/Rakefile +17 -19
  4. data/_buildr +50 -0
  5. data/addon/buildr/cobertura.rb +47 -44
  6. data/addon/buildr/emma.rb +237 -0
  7. data/addon/buildr/jetty.rb +1 -1
  8. data/addon/buildr/nailgun.rb +581 -661
  9. data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail$Main.class +0 -0
  10. data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.class +0 -0
  11. data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.java +0 -0
  12. data/addon/buildr/xmlbeans.rb +1 -1
  13. data/bin/buildr +9 -2
  14. data/buildr.buildfile +53 -0
  15. data/buildr.gemspec +23 -15
  16. data/doc/css/default.css +51 -48
  17. data/doc/css/print.css +60 -55
  18. data/doc/css/syntax.css +40 -31
  19. data/doc/images/growl-icon.tiff +0 -0
  20. data/doc/images/project-structure.png +0 -0
  21. data/doc/pages/artifacts.textile +46 -156
  22. data/doc/pages/building.textile +63 -324
  23. data/doc/pages/contributing.textile +116 -88
  24. data/doc/pages/download.textile +20 -15
  25. data/doc/pages/extending.textile +27 -81
  26. data/doc/pages/getting_started.textile +47 -111
  27. data/doc/pages/index.textile +19 -37
  28. data/doc/pages/languages.textile +407 -0
  29. data/doc/pages/more_stuff.textile +92 -173
  30. data/doc/pages/packaging.textile +72 -237
  31. data/doc/pages/projects.textile +58 -233
  32. data/doc/pages/recipes.textile +19 -43
  33. data/doc/pages/settings_profiles.textile +39 -104
  34. data/doc/pages/testing.textile +41 -304
  35. data/doc/pages/troubleshooting.textile +29 -47
  36. data/doc/pages/whats_new.textile +66 -157
  37. data/doc/print.haml +0 -1
  38. data/doc/print.toc.yaml +1 -0
  39. data/doc/scripts/buildr-git.rb +1 -1
  40. data/doc/scripts/install-jruby.sh +1 -1
  41. data/doc/scripts/install-linux.sh +4 -4
  42. data/doc/site.toc.yaml +8 -5
  43. data/{KEYS → etc/KEYS} +0 -0
  44. data/etc/git-svn-authors +16 -0
  45. data/lib/buildr.rb +2 -13
  46. data/lib/buildr/core/application.rb +200 -95
  47. data/lib/buildr/core/application_cli.rb +6 -1
  48. data/lib/buildr/core/build.rb +140 -91
  49. data/lib/buildr/core/checks.rb +5 -5
  50. data/lib/buildr/core/common.rb +1 -1
  51. data/lib/buildr/core/compile.rb +14 -12
  52. data/lib/buildr/core/filter.rb +151 -46
  53. data/lib/buildr/core/generate.rb +9 -7
  54. data/lib/buildr/core/progressbar.rb +1 -1
  55. data/lib/buildr/core/project.rb +8 -7
  56. data/lib/buildr/core/test.rb +54 -29
  57. data/lib/buildr/core/transports.rb +25 -20
  58. data/lib/buildr/core/util.rb +80 -26
  59. data/lib/buildr/groovy.rb +18 -0
  60. data/lib/buildr/groovy/bdd.rb +105 -0
  61. data/lib/buildr/groovy/compiler.rb +138 -0
  62. data/lib/buildr/ide/eclipse.rb +102 -71
  63. data/lib/buildr/ide/idea.rb +7 -12
  64. data/lib/buildr/ide/idea7x.rb +20 -20
  65. data/lib/buildr/java.rb +4 -7
  66. data/lib/buildr/java/ant.rb +26 -5
  67. data/lib/buildr/java/bdd.rb +447 -0
  68. data/lib/buildr/java/commands.rb +8 -9
  69. data/lib/buildr/java/{compilers.rb → compiler.rb} +8 -90
  70. data/lib/buildr/java/jruby.rb +29 -11
  71. data/lib/buildr/java/jtestr_runner.rb.erb +114 -0
  72. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  73. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +4 -1
  74. data/lib/buildr/java/packaging.rb +23 -16
  75. data/lib/buildr/java/pom.rb +1 -1
  76. data/lib/buildr/java/rjb.rb +21 -8
  77. data/lib/buildr/java/test_result.rb +277 -0
  78. data/lib/buildr/java/{test_frameworks.rb → tests.rb} +121 -88
  79. data/lib/buildr/packaging/artifact.rb +12 -11
  80. data/lib/buildr/packaging/artifact_namespace.rb +7 -4
  81. data/lib/buildr/packaging/gems.rb +3 -3
  82. data/lib/buildr/packaging/zip.rb +13 -10
  83. data/lib/buildr/resources/buildr.icns +0 -0
  84. data/lib/buildr/scala.rb +19 -0
  85. data/lib/buildr/scala/compiler.rb +109 -0
  86. data/lib/buildr/scala/tests.rb +203 -0
  87. data/rakelib/apache.rake +31 -41
  88. data/rakelib/doc.rake +2 -2
  89. data/rakelib/package.rake +31 -2
  90. data/rakelib/rspec.rake +22 -20
  91. data/rakelib/rubyforge.rake +1 -0
  92. data/rakelib/setup.rake +34 -9
  93. data/spec/addon/cobertura_spec.rb +77 -0
  94. data/spec/addon/emma_spec.rb +120 -0
  95. data/spec/addon/test_coverage_spec.rb +249 -0
  96. data/spec/{application_spec.rb → core/application_spec.rb} +82 -4
  97. data/spec/{artifact_namespace_spec.rb → core/artifact_namespace_spec.rb} +12 -1
  98. data/spec/core/build_spec.rb +415 -0
  99. data/spec/{checks_spec.rb → core/checks_spec.rb} +1 -1
  100. data/spec/{common_spec.rb → core/common_spec.rb} +119 -30
  101. data/spec/{compile_spec.rb → core/compile_spec.rb} +17 -13
  102. data/spec/{project_spec.rb → core/project_spec.rb} +9 -6
  103. data/spec/{test_spec.rb → core/test_spec.rb} +226 -32
  104. data/spec/{transport_spec.rb → core/transport_spec.rb} +35 -23
  105. data/spec/groovy/bdd_spec.rb +80 -0
  106. data/spec/{groovy_compilers_spec.rb → groovy/compiler_spec.rb} +1 -1
  107. data/spec/ide/eclipse_spec.rb +243 -0
  108. data/spec/{java_spec.rb → java/ant.rb} +7 -17
  109. data/spec/java/bdd_spec.rb +358 -0
  110. data/spec/{java_compilers_spec.rb → java/compiler_spec.rb} +1 -1
  111. data/spec/java/java_spec.rb +88 -0
  112. data/spec/{java_packaging_spec.rb → java/packaging_spec.rb} +65 -4
  113. data/spec/{java_test_frameworks_spec.rb → java/tests_spec.rb} +50 -10
  114. data/spec/{archive_spec.rb → packaging/archive_spec.rb} +12 -2
  115. data/spec/{artifact_spec.rb → packaging/artifact_spec.rb} +10 -3
  116. data/spec/{packaging_helper.rb → packaging/packaging_helper.rb} +0 -0
  117. data/spec/{packaging_spec.rb → packaging/packaging_spec.rb} +1 -1
  118. data/spec/sandbox.rb +25 -4
  119. data/spec/{scala_compilers_spec.rb → scala/compiler_spec.rb} +1 -1
  120. data/spec/scala/tests_spec.rb +215 -0
  121. data/spec/spec_helpers.rb +38 -17
  122. metadata +119 -69
  123. data/lib/buildr/java/bdd_frameworks.rb +0 -265
  124. data/lib/buildr/java/groovyc.rb +0 -137
  125. data/spec/build_spec.rb +0 -193
  126. data/spec/java_bdd_frameworks_spec.rb +0 -238
  127. data/spec/spec.opts +0 -6
data/CHANGELOG CHANGED
@@ -1,8 +1,90 @@
1
- 1.3.2 (Pending)
2
- * Fixed: BUILDR-77: Layout feature not working.
3
- * Fixed: BUILDR-76: Added more specs and fixes to compile task.
4
- * Fixed: BUILDR-80: Fix reference to Util#timestamp method on nailgun addon.
5
- * Fixed: BUILDR-79: Remove :source option for Scala compiler
1
+ 1.3.3 (Pending)
2
+ * Added: JtestR support. Implemented pending jtestr specs.
3
+ * Added: Growl notifications (OS X only).
4
+ * Added: error, info and trace methods.
5
+ * Added: BUILDR-128 Emma support
6
+ * Added: Release task support for alternative SVN repository layout
7
+ (e.g., http://my.repo.org/trunk/foo).
8
+ * Added: BUILDR-148 It is now possible to set the version of various 3rd
9
+ party libraries from the build.yml file. Supported libraries
10
+ include Ant and the various test and BDD frameworks.
11
+ * Change: Error reporting now shows 'buildr aborted!' (used to say rake),
12
+ more of the stack trace without running --trace, and when running
13
+ with supported terminal, error message is red.
14
+ * Change: BUILDR-104 Buildr::group has :under and :version, but not :type.
15
+ Now it has :type too (Lacton).
16
+ * Change: Eclipse task updated to documented Scala plugin requirements
17
+ (http://www.scala-lang.org/node/94)
18
+ * Change: Buildr.application.buildfile returns a task instead of a String.
19
+ * Change: BUILDR-139 Incremental test run.
20
+ * Change: BUILDR-141 Removed NEXT_VERSION from release task.
21
+ * Change: BUILDR-148 ant-junit no longer included in root classpath, but
22
+ specified during taskdef.
23
+ * Change: BUILDR-153 To customize the SVN tag used by the release task, set
24
+ Release.tag_name to either the tag value or a proc that takes the
25
+ version number and return the desired tag.
26
+ * Fixed: BUILDR-135. Extracted reusable replacement logic into Filter::Mapper
27
+ * Fixed: BUILDR-129. Modifying a project manifest should not alter it's
28
+ parent project manifest.
29
+ * Fixed: BUILDR-106 download(artifact(...)=>url) broken in certain cases
30
+ (Lacton).
31
+ * Fixed: BUILDR-108 Trace to explain why a compile is done (Lacton).
32
+ * Fixed: BUILDR-109 Failure of "Buildr::Filter should respond to :include and
33
+ use these inclusion patterns" (Lacton).
34
+ * Fixed: BUILDR-110 Error creating buildfile from POM when missing plugin
35
+ configuration (Geoffrey Ruscoe).
36
+ * Fixed: BUILDR-112 Using a user gem repository with 'rake setup' (Lacton).
37
+ * Fixed: BUILDR-114 Hash.from_java_properties does not behave
38
+ like java.util.Properties (Lacton).
39
+ * Fixed: BUILDR-117 Shared directory for both code and resources produces
40
+ duplicate Eclipse classpath entries (Nathan Hamblen)
41
+ * Fixed: BUILDR-116: TestTask should include the main compile target in its
42
+ dependencies, even when using non standard directories (Lacton).
43
+ * Fixed: BUILDR-119 Eclipse task does not accept test resource folders
44
+ (Lacton)
45
+ * Fixed: BUILDR-122: eclipse task should not check for directory existence
46
+ * Fixed: BUILDR-123: eclipse task should honor ResourceTask's target directory
47
+ * Fixed: BUILDR-124 unzip(...).from_path does not work correctly without
48
+ include (Rhett Sutphin).
49
+ * Fixed: BUILDR-126 Tests options are shared between unrelated projects when
50
+ using #options instead of #using (Lacton).
51
+ * Fixed: Should not display "(in `pwd`, development)" when using --quiet.
52
+ * Fixed: Release task's regexp to find either THIS_VERSION and VERSION_NUMBER.
53
+ * Fixed: BUILDR-138 ScalaTest premature use of Buildr::Repositories
54
+ inconsistent with customizing locations.
55
+ * Fixed: BUILDR-152 Project.task fails when task name starts with a colon.
56
+ * Docs: BUILDR-111 Troubleshoot tip when Buildr's bin directory shows up in
57
+ RUBYLIB (Geoffrey Ruscoe).
58
+
59
+ 1.3.2 (2008-07-18)
60
+ * Added: --prereqs command line argument to show all tasks and their
61
+ dependencies. You can also follow with regular expression to narrow down the
62
+ list of tasks.
63
+ * Changed: Upgraded to Rubyforge 1.0.0.
64
+ * Changed: BUILDR-86 Use newest versions of net-ssh and net-sftp gems.
65
+ * Changed: BUILDR-88 Test classes/resources should come before compile
66
+ classes/resources so they load up earlier in java classpath.
67
+ * Changed: BUILDR-102 Update JUnit Version to 4.4.
68
+ * Fixed: BUILDR-73 idea7x task incorrect adds target/resources to the sources
69
+ paths.
70
+ * Fixed: BUILDR-76 Added more specs and fixes to compile task.
71
+ * Fixed: BUILDR-77 Layout feature not working.
72
+ * Fixed: BUILDR-79 Remove :source option for Scala compiler
73
+ * Fixed: BUILDR-80 Fix reference to Util#timestamp method on nailgun addon.
74
+ * Fixed: BUILDR-82 Temporary work around for Net::SSH 2.0.2 attempting to
75
+ load Pageant DLLs when running on JRuby/Windows.
76
+ * Fixed: BUILDR-89 JUnit (and all other Java frameworks) no longer include
77
+ abstract classes.
78
+ * Fixed: BUILDR-90 Installing from source doesn't work with JRuby.
79
+ * Fixed: BUILDR-91 When doing a release, buildr should spawn the same version
80
+ of buildr
81
+ * Fixed: BUILDR-92 IDEA 7x: add resources directories to classpath.
82
+ * Fixed: BUILDR-95: Only download Scala test framework artifacts when required
83
+ * Fixed: BUILDR-100 Directory structure documentation needs updating.
84
+ * Fixed: Installation instructions updated for RubyGems 1.2.0.
85
+
86
+ 1.3.1.1 (2008-06-04)
87
+ * Fixed: BUILDR-78 Broken dependency on Rubyforge Gem.
6
88
 
7
89
  1.3.1 (2008-05-19)
8
90
  * Added: Downloading files from SFTP server, uploading to HTTP.
@@ -375,7 +457,7 @@ will come in due time (and it's not always necessary anyway).
375
457
  buildr/jdepend)
376
458
  * Added: Cobertura test coverage tasks, reporting both html and xml. (Requires
377
459
  buildr/cobertura)
378
- * Changed: tools_jar now returns empty array on OS/X, part of the ongoing
460
+ * Changed: tools_jar now returns empty array on OS X, part of the ongoing
379
461
  Write Once/Test Everywere effort. (Credit Paul Brown)
380
462
  * Fixed: Work around keep_alive bug in Net::HTTP.
381
463
  (http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/10818)
@@ -385,7 +467,7 @@ Write Once/Test Everywere effort. (Credit Paul Brown)
385
467
  TestSuite.
386
468
  * Changed: You can now run rake test:{foo,bar} to match against either foo or
387
469
  bar (requires \{..\} on UNIX).
388
- * Changed: JAVA_HOME now required on all platforms, along with more OS/X
470
+ * Changed: JAVA_HOME now required on all platforms, along with more OS X
389
471
  fixes. (Credit Paul Brown)
390
472
  * Fixed: You can now run rake test:<name> from any directory, and it will find
391
473
  just the right test cases.
@@ -413,7 +495,7 @@ projects on a project instead.
413
495
  * Fixed: Local directory tasks now work from any directory in the project.
414
496
  * Fixed: Artifacts no longer created with timestamp from server.
415
497
  * Fixed: Buildr no longer fails when run without tools.jar or JAVA_HOME
416
- (OS/X). (Credit Lyle Johnson)
498
+ (OS X). (Credit Lyle Johnson)
417
499
  * Fixed: Manifest gets EOL to keep EOF company. (Credit Tommy Knowlton)
418
500
  * Fixed: Compile tasks clean after themselves when target directory changed.
419
501
  (Credit Lyle Johnson)
@@ -20,7 +20,7 @@ Make sure to set JAVA_HOME environment variable first, then:
20
20
 
21
21
  gem install buildr
22
22
 
23
- (Use sudo for Linux and OS/X)
23
+ (Use sudo for Linux and OS X)
24
24
 
25
25
  More installation and setup instructions available online
26
26
  http://incubator.apache.org/buildr/
@@ -35,13 +35,9 @@ http://incubator.apache.org/buildr/
35
35
 
36
36
  === Mailing list
37
37
 
38
- * Users: buildr-user@incubator.apache.org (subscribe:
39
- buildr-user-subscribe@incubator.apache.org, archive:
40
- http://mail-archives.apache.org/mod_mbox/incubator-buildr-user/
38
+ Users: http://mail-archives.apache.org/mod_mbox/incubator-buildr-user/
41
39
 
42
- * Developers: buildr-dev@incubator.apache.org (subscribe:
43
- buildr-dev-subscribe@incubator.apache.org, archive:
44
- http://mail-archives.apache.org/mod_mbox/incubator-buildr-dev/
40
+ Developers: http://mail-archives.apache.org/mod_mbox/incubator-buildr-dev/
45
41
 
46
42
  Create your own Buildfile and start living the life!
47
43
 
@@ -83,7 +79,7 @@ point to your JDK distribution. Next, use Ruby Gem to install Buildr:
83
79
 
84
80
  When prompted for a platform, select ruby.
85
81
 
86
- === OS/X
82
+ === OS X
87
83
 
88
84
  Leopard includes the latest version of Ruby, if you are using Tiger or an older
89
85
  release, we recommend re-installing the latest:
@@ -106,6 +102,10 @@ You can check the latest sources from SVN:
106
102
  Or browse the SVN repository online:
107
103
  http://svn.apache.org/repos/asf/incubator/buildr
108
104
 
105
+ If you prefer Git, a Git fork is available from http://github.com/vic/buildr/tree/master:
106
+
107
+ git clone git://github.com/vic/buildr.git
108
+
109
109
  To install Buildr locally from source:
110
110
 
111
111
  cd buildr
@@ -117,17 +117,30 @@ which changes might have broken your build. To run all the test cases:
117
117
  rake spec
118
118
 
119
119
 
120
- == Disclaimer
121
-
122
- :include:DISCLAIMER
123
-
124
-
125
120
  == License
126
121
 
127
- :include:LICENSE
122
+ Licensed to the Apache Software Foundation (ASF) under one or more
123
+ contributor license agreements. See the NOTICE file distributed with this
124
+ work for additional information regarding copyright ownership. The ASF
125
+ licenses this file to you under the Apache License, Version 2.0 (the
126
+ "License"); you may not use this file except in compliance with the License.
127
+ You may obtain a copy of the License at
128
128
 
129
+ http://www.apache.org/licenses/LICENSE-2.0
129
130
 
130
- == Notice
131
+ Unless required by applicable law or agreed to in writing, software
132
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
133
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
134
+ License for the specific language governing permissions and limitations under
135
+ the License.
131
136
 
132
- :include:NOTICE
133
137
 
138
+ == Disclaimer
139
+
140
+ Apache Buildr is an effort undergoing incubation at The Apache Software
141
+ Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of
142
+ all newly accepted projects until a further review indicates that the
143
+ infrastructure, communications, and decision making process have stabilized in
144
+ a manner consistent with other successful ASF projects. While incubation status
145
+ is not necessarily a reflection of the completeness or stability of the code,
146
+ it does indicate that the project has yet to be fully endorsed by the ASF.
data/Rakefile CHANGED
@@ -16,28 +16,19 @@
16
16
 
17
17
  require 'rake/gempackagetask'
18
18
 
19
- def spec(platform = nil)
20
- @specs ||= {}
21
- platform ||= RUBY_PLATFORM =~ /java/ ? 'java' : 'ruby'
22
- @specs[platform] ||= begin
23
- spec = Gem::Specification.load(File.join(File.dirname(__FILE__), 'buildr.gemspec'))
24
- spec.platform = platform
25
- if platform =~ /java/
26
- spec.add_dependency 'jruby-openssl', '0.2'
27
- spec.add_dependency 'ci_reporter', '1.5.1' # must come after builder dependency
28
- else
29
- # Place first on the dependency list, otherwise AntWrap picks the latest RJB.
30
- spec.dependencies.unshift Gem::Dependency.new('rjb', ['>=1.1.0', '<= 1.1.2'])
31
- end
32
- spec
33
- end
19
+ def spec(platform = RUBY_PLATFORM[/java/] || 'ruby')
20
+ @specs ||= ['ruby', 'java'].inject({}) { |hash, platform|
21
+ $platform = platform
22
+ hash.update(platform=>Gem::Specification.load('buildr.gemspec'))
23
+ }
24
+ @specs[platform]
34
25
  end
35
26
 
36
27
 
37
28
  desc 'Compile Java libraries used by Buildr'
38
29
  task 'compile' do
39
30
  puts 'Compiling Java libraries ...'
40
- sh Config::CONFIG['ruby_install_name'], '-Ilib', '-Iaddon', 'bin/buildr', 'compile'
31
+ sh File.expand_path('_buildr'), '--buildfile=buildr.buildfile', 'compile'
41
32
  puts 'OK'
42
33
  end
43
34
  file Rake::GemPackageTask.new(spec).package_dir=>'compile'
@@ -52,13 +43,20 @@ end
52
43
  ENV['incubating'] = 'true'
53
44
  ENV['staging'] = "people.apache.org:~/public_html/#{spec.name}/#{spec.version}"
54
45
 
55
- task 'apache:license'=>spec.files
56
- task('apache:license').prerequisites.exclude('doc/css/syntax.css')
46
+ task('apache:license').enhance FileList[spec.files].exclude('.class', '.png', '.jar', '.tif', '.textile', '.icns',
47
+ 'README', 'LICENSE', 'CHANGELOG', 'DISCLAIMER', 'NOTICE', 'etc/KEYS', 'etc/git-svn-authors')
57
48
 
58
- task 'spec:check' do
49
+ task 'stage:check' do
59
50
  print 'Checking that we have JRuby, Scala and Groovy available ... '
60
51
  fail 'Full testing requires JRuby!' unless which('jruby')
61
52
  fail 'Full testing requires Scala!' unless which('scala')
62
53
  fail 'Full testing requires Groovy!' unless which('groovy')
63
54
  puts 'OK'
64
55
  end
56
+
57
+ task 'stage:check' do
58
+ # Dependency check for the other platform, i.e. if making a release with Ruby,
59
+ # run dependency checks with JRuby. (Also, good opportunity to upgrade other
60
+ # platform's dependencies)
61
+ sh RUBY_PLATFORM =~ /java/ ? 'ruby' : 'jruby', '-S', 'rake', 'setup dependency'
62
+ end
data/_buildr ADDED
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env ruby
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with this
4
+ # work for additional information regarding copyright ownership. The ASF
5
+ # licenses this file to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ # License for the specific language governing permissions and limitations under
15
+ # the License.
16
+
17
+ # Run buildr from source, specifically for testing stuff without doing a rake install.
18
+ # The _BUILDR_RB environment variable can be used to set the path to the ruby/jruby executable.
19
+ # For example to use jruby:
20
+ # export _BUILDR_RB=/path/to/jruby
21
+
22
+ buildr_root = File.dirname(__FILE__)
23
+ buildr_ruby = ENV['_BUILDR_RB'] || 'ruby'
24
+
25
+ cmd = [
26
+ buildr_ruby,
27
+ "-I"+File.join(buildr_root, 'lib'),
28
+ "-I"+File.join(buildr_root, 'addon'),
29
+ ]
30
+
31
+ cmd.push '-e', %q{
32
+ start = Time.now
33
+ require 'rubygems'
34
+ gem 'rake', '0.8.1' # Required since Buildr won't run with 0.8.2 for now.
35
+ require 'buildr'
36
+ Buildr.application.run
37
+ if verbose
38
+ elapsed = Time.now - start
39
+ real = []
40
+ real << ("%ih" % (elapsed / 3600)) if elapsed >= 3600
41
+ real << ("%im" % ((elapsed / 60) % 60)) if elapsed >= 60
42
+ real << ("%.3fs" % (elapsed % 60))
43
+ puts $terminal.color("Completed in #{real.join}", :green)
44
+ end
45
+ }
46
+
47
+ cmd.push '--' # The following args are for Buildr
48
+ cmd.push *ARGV
49
+ exec *cmd
50
+
@@ -42,7 +42,7 @@ module Buildr
42
42
  class << self
43
43
 
44
44
  REQUIRES = ["net.sourceforge.cobertura:cobertura:jar:1.9", "log4j:log4j:jar:1.2.9",
45
- "asm:asm:jar:2.2.1", "asm:asm-tree:jar:2.2.1", "oro:oro:jar:2.0.8"]
45
+ "asm:asm:jar:2.2.1", "asm:asm-tree:jar:2.2.1", "oro:oro:jar:2.0.8"] unless const_defined?('REQUIRES')
46
46
 
47
47
  def requires()
48
48
  @requires ||= Buildr.artifacts(REQUIRES).each(&:invoke).map(&:to_s)
@@ -125,47 +125,57 @@ module Buildr
125
125
  cobertura = project.cobertura
126
126
 
127
127
  namespace 'cobertura' do
128
- # Instrumented bytecode goes in a different directory. This task creates before running the test
129
- # cases and monitors for changes in the generate bytecode.
130
- instrumented = project.file(cobertura.instrumented_dir => file(project.compile.target)) do |task|
131
- mkdir_p task.to_s, :verbose => false
132
- unless project.compile.sources.empty?
133
- puts "Instrumenting classes with cobertura data file #{cobertura.data_file}"
134
- Buildr.ant "cobertura" do |ant|
135
- ant.taskdef :classpath=>Cobertura.requires.join(File::PATH_SEPARATOR), :resource=>"tasks.properties"
136
- ant.send "cobertura-instrument", :todir=>task.to_s, :datafile=>cobertura.data_file do
137
- includes, excludes = cobertura.includes, cobertura.excludes
138
-
139
- classes_dir = project.compile.target.to_s
140
- if includes.empty? && excludes.empty?
141
- ant.fileset :dir => classes_dir do
142
- ant.include :name => "**/*.class"
143
- end
144
- else
145
- includes = [//] if includes.empty?
146
- Dir.glob(File.join(classes_dir, "**/*.class")) do |cls|
147
- cls_name = cls.gsub(/#{classes_dir}\/?|\.class$/, '').gsub('/', '.')
148
- if includes.any? { |p| p === cls_name } && !excludes.any? { |p| p === cls_name }
149
- ant.fileset :file => cls
128
+ unless project.compile.target.nil?
129
+ # Instrumented bytecode goes in a different directory. This task creates before running the test
130
+ # cases and monitors for changes in the generate bytecode.
131
+ instrumented = project.file(cobertura.instrumented_dir => project.compile.target) do |task|
132
+ mkdir_p task.to_s, :verbose => false
133
+ unless project.compile.sources.empty?
134
+ info "Instrumenting classes with cobertura data file #{cobertura.data_file}"
135
+ Buildr.ant "cobertura" do |ant|
136
+ ant.taskdef :classpath=>Cobertura.requires.join(File::PATH_SEPARATOR), :resource=>"tasks.properties"
137
+ ant.send "cobertura-instrument", :todir=>task.to_s, :datafile=>cobertura.data_file do
138
+ includes, excludes = cobertura.includes, cobertura.excludes
139
+
140
+ classes_dir = project.compile.target.to_s
141
+ if includes.empty? && excludes.empty?
142
+ ant.fileset :dir => classes_dir do
143
+ ant.include :name => "**/*.class"
144
+ end
145
+ else
146
+ includes = [//] if includes.empty?
147
+ Dir.glob(File.join(classes_dir, "**/*.class")) do |cls|
148
+ cls_name = cls.gsub(/#{classes_dir}\/?|\.class$/, '').gsub('/', '.')
149
+ if includes.any? { |p| p === cls_name } && !excludes.any? { |p| p === cls_name }
150
+ ant.fileset :file => cls
151
+ end
150
152
  end
151
153
  end
152
154
  end
153
155
  end
154
156
  end
157
+ touch task.to_s, :verbose=>false
155
158
  end
156
- touch task.to_s, :verbose=>false
157
- end
158
-
159
- task 'instrument' => instrumented
160
- [:xml, :html].each do |format|
161
- task format => ['instrument', 'test'] do
162
- puts "Creating test coverage reports in #{cobertura.report_to(format)}"
163
- Buildr.ant "cobertura" do |ant|
164
- ant.taskdef :classpath=>Cobertura.requires.join(File::PATH_SEPARATOR), :resource=>"tasks.properties"
165
- ant.send "cobertura-report", :format=>format,
166
- :destdir=>cobertura.report_to(format), :datafile=>cobertura.data_file do
167
- cobertura.sources.flatten.each do |src|
168
- ant.fileset(:dir=>src.to_s) if File.exist?(src.to_s)
159
+
160
+ task 'instrument' => instrumented
161
+
162
+ # We now have two target directories with bytecode. It would make sense to remove compile.target
163
+ # and add instrumented instead, but apparently Cobertura only creates some of the classes, so
164
+ # we need both directories and instrumented must come first.
165
+ project.test.dependencies.unshift cobertura.instrumented_dir
166
+ project.test.with Cobertura.requires
167
+ project.test.options[:properties]["net.sourceforge.cobertura.datafile"] = cobertura.data_file
168
+
169
+ [:xml, :html].each do |format|
170
+ task format => ['instrument', 'test'] do
171
+ info "Creating test coverage reports in #{cobertura.report_to(format)}"
172
+ Buildr.ant "cobertura" do |ant|
173
+ ant.taskdef :classpath=>Cobertura.requires.join(File::PATH_SEPARATOR), :resource=>"tasks.properties"
174
+ ant.send "cobertura-report", :format=>format,
175
+ :destdir=>cobertura.report_to(format), :datafile=>cobertura.data_file do
176
+ cobertura.sources.flatten.each do |src|
177
+ ant.fileset(:dir=>src.to_s) if File.exist?(src.to_s)
178
+ end
169
179
  end
170
180
  end
171
181
  end
@@ -174,13 +184,6 @@ module Buildr
174
184
 
175
185
  end
176
186
 
177
- # We now have two target directories with bytecode. It would make sense to remove compile.target
178
- # and add instrumented instead, but apparently Cobertura only creates some of the classes, so
179
- # we need both directories and instrumented must come first.
180
- project.test.dependencies.unshift cobertura.instrumented_dir
181
- project.test.with Cobertura.requires
182
- project.test.options[:properties]["net.sourceforge.cobertura.datafile"] = cobertura.data_file
183
-
184
187
  project.clean do
185
188
  rm_rf [cobertura.report_to, cobertura.data_file, cobertura.instrumented_dir], :verbose=>false
186
189
  end
@@ -207,7 +210,7 @@ module Buildr
207
210
  report_target = report_to(format)
208
211
  desc "Run the test cases and produce code coverage reports in #{report_target}"
209
212
  task format => ["instrument", "test"] do
210
- puts "Creating test coverage reports in #{report_target}"
213
+ info "Creating test coverage reports in #{report_target}"
211
214
  Buildr.ant "cobertura" do |ant|
212
215
  ant.taskdef :classpath=>requires.join(File::PATH_SEPARATOR), :resource=>"tasks.properties"
213
216
  ant.send "cobertura-report", :destdir=>report_target, :format=>format, :datafile=>data_file do
@@ -0,0 +1,237 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ require 'buildr/java'
18
+
19
+
20
+ module Buildr
21
+
22
+ # Provides the <code>emma:html</code> and <code>emma:xml</code> tasks.
23
+ # Require explicitly using <code>require "buildr/emma"</code>.
24
+ #
25
+ # You can generate emma reports for a single project
26
+ # using the project name as prefix:
27
+ #
28
+ # project_name:emma:html
29
+ #
30
+ # You can also specify which classes to include/exclude from instrumentation by
31
+ # passing a class name regexp to the <code>emma.include</code> or
32
+ # <code>emma.exclude</code> methods.
33
+ #
34
+ # define 'someModule' do
35
+ # emma.include 'some.package.*'
36
+ # emma.exclude 'some.foo.util.SimpleUtil'
37
+ # end
38
+ module Emma
39
+
40
+ class << self
41
+
42
+ REQUIRES = ['emma:emma_ant:jar:2.0.5312', 'emma:emma:jar:2.0.5312'] unless const_defined?('REQUIRES')
43
+
44
+ def requires()
45
+ @requires ||= Buildr.artifacts(REQUIRES).each(&:invoke).map(&:to_s)
46
+ end
47
+
48
+ def report_to format=nil
49
+ File.expand_path('reports/emma')
50
+ end
51
+
52
+ def data_file()
53
+ File.join(report_to, 'coverage.es')
54
+ end
55
+
56
+ def ant
57
+ Buildr.ant 'emma' do |ant|
58
+ ant.taskdef :classpath=>requires.join(File::PATH_SEPARATOR), :resource=>'emma_ant.properties'
59
+ ant.emma :verbosity=>(Buildr.application.options.trace ? 'verbose' : 'warning') do
60
+ yield ant
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ class EmmaConfig # :nodoc:
67
+
68
+ def initialize(project)
69
+ @project = project
70
+ end
71
+
72
+ attr_reader :project
73
+ private :project
74
+
75
+ attr_writer :metadata_file, :coverage_file, :instrumented_dir, :report_dir
76
+
77
+ def coverage_file
78
+ @coverage_file ||= File.join(report_dir, 'coverage.ec')
79
+ end
80
+
81
+ def metadata_file
82
+ @metadata_file ||= File.join(report_dir, 'coverage.em')
83
+ end
84
+
85
+ def instrumented_dir
86
+ @instrumented_dir ||= project.path_to(:target, :instrumented, :classes)
87
+ end
88
+
89
+ def report_dir
90
+ @report_dir ||= project.path_to(:reports, :emma)
91
+ end
92
+
93
+ def report_to format
94
+ report_dir
95
+ end
96
+
97
+ # :call-seq:
98
+ # project.emma.include(*classPatterns)
99
+ #
100
+ def include(*classPatterns)
101
+ includes.push(*classPatterns)
102
+ self
103
+ end
104
+
105
+ def includes
106
+ @includeClasses ||= []
107
+ end
108
+
109
+ # :call-seq:
110
+ # project.emma.exclude(*classPatterns)
111
+ #
112
+ def exclude(*classPatterns)
113
+ excludes.push(*classPatterns)
114
+ self
115
+ end
116
+
117
+ def excludes
118
+ @excludeClasses ||= []
119
+ end
120
+
121
+ def sources
122
+ project.compile.sources
123
+ end
124
+ end
125
+
126
+ module EmmaExtension # :nodoc:
127
+ include Buildr::Extension
128
+
129
+ def emma
130
+ @emma_config ||= EmmaConfig.new(self)
131
+ end
132
+
133
+ after_define do |project|
134
+ emma = project.emma
135
+
136
+ namespace 'emma' do
137
+ unless project.compile.target.nil?
138
+ # Instrumented bytecode goes in a different directory. This task creates before running the test
139
+ # cases and monitors for changes in the generate bytecode.
140
+ instrumented = project.file(emma.instrumented_dir => project.compile.target) do |task|
141
+ unless project.compile.sources.empty?
142
+ info "Instrumenting classes with emma metadata file #{emma.metadata_file}"
143
+ Emma.ant do |ant|
144
+ ant.instr :instrpath=>project.compile.target.to_s, :destdir=>task.to_s, :metadatafile=>emma.metadata_file do
145
+ ant.filter :includes=>emma.includes.join(', ') unless emma.includes.empty?
146
+ ant.filter :excludes=>emma.excludes.join(', ') unless emma.excludes.empty?
147
+ end
148
+ end
149
+ touch task.to_s, :verbose=>false
150
+ end
151
+ end
152
+
153
+ task 'instrument' => instrumented
154
+
155
+ # We now have two target directories with bytecode.
156
+ project.test.dependencies.unshift emma.instrumented_dir
157
+ project.test.with Emma.requires
158
+ project.test.options[:properties]["emma.coverage.out.file"] = emma.coverage_file
159
+
160
+ [:xml, :html].each do |format|
161
+ task format => ['instrument', 'test'] do
162
+ missing_required_files = [emma.metadata_file, emma.coverage_file].reject { |f| File.exist?(f) }
163
+ if missing_required_files.empty?
164
+ info "Creating test coverage reports in #{emma.report_dir}"
165
+ mkdir_p emma.report_dir, :verbose=>false
166
+ Emma.ant do |ant|
167
+ ant.report do
168
+ ant.infileset :file=>emma.metadata_file
169
+ ant.infileset :file=>emma.coverage_file
170
+ ant.send format, :outfile=>File.join(emma.report_to(format),"coverage.#{format}")
171
+ ant.sourcepath do
172
+ emma.sources.flatten.each do |src|
173
+ ant.dirset(:dir=>src.to_s) if File.exist?(src.to_s)
174
+ end
175
+ end
176
+ end
177
+ end
178
+ else
179
+ info "No test coverage report for #{project}. Missing: #{missing_required_files.join(', ')}"
180
+ end
181
+ end
182
+ end
183
+ end
184
+ end
185
+
186
+ project.clean do
187
+ rm_rf [emma.report_dir, emma.coverage_file, emma.metadata_file, emma.instrumented_dir], :verbose=>false
188
+ end
189
+
190
+ end
191
+
192
+ end
193
+
194
+ class Buildr::Project
195
+ include EmmaExtension
196
+ end
197
+
198
+ namespace "emma" do
199
+
200
+ Project.local_task('instrument') { |name| "Instrumenting #{name}" }
201
+
202
+ [:xml, :html].each do |format|
203
+ desc "Run the test cases and produce code coverage reports in #{format}"
204
+ task format => ['instrument', 'test'] do
205
+ info "Creating test coverage reports in #{format}"
206
+ mkdir_p report_to(format), :verbose=>false
207
+ Emma.ant do |ant|
208
+ ant.merge :outfile=>data_file do
209
+ Buildr.projects.each do |project|
210
+ ant.fileset :file=>project.emma.metadata_file
211
+ ant.fileset :file=>project.emma.coverage_file
212
+ end
213
+ end
214
+ ant.report do
215
+ ant.infileset :file=>data_file
216
+ ant.send format, :outfile=>File.join(report_to(format), "coverage.#{format}")
217
+ ant.sourcepath do
218
+ Buildr.projects.map(&:emma).map(&:sources).flatten.map(&:to_s).each do |src|
219
+ ant.dirset :dir=>src if File.exist?(src)
220
+ end
221
+ end
222
+ end
223
+ end
224
+ end
225
+ end
226
+
227
+ task :clean do
228
+ rm_rf [report_to, data_file], :verbose=>false
229
+ end
230
+ end
231
+
232
+ task :clean do
233
+ task('emma:clean').invoke if Dir.pwd == Rake.application.original_dir
234
+ end
235
+
236
+ end
237
+ end