buildr 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. data/CHANGELOG +66 -4
  2. data/{README → README.rdoc} +29 -16
  3. data/Rakefile +16 -20
  4. data/_buildr +38 -0
  5. data/addon/buildr/cobertura.rb +49 -45
  6. data/addon/buildr/emma.rb +238 -0
  7. data/addon/buildr/jetty.rb +1 -1
  8. data/addon/buildr/nailgun.rb +585 -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/bin/buildr +9 -2
  13. data/buildr.buildfile +53 -0
  14. data/buildr.gemspec +21 -14
  15. data/doc/css/default.css +51 -48
  16. data/doc/css/print.css +60 -55
  17. data/doc/images/favicon.png +0 -0
  18. data/doc/images/growl-icon.tiff +0 -0
  19. data/doc/images/project-structure.png +0 -0
  20. data/doc/pages/artifacts.textile +46 -156
  21. data/doc/pages/building.textile +63 -323
  22. data/doc/pages/contributing.textile +112 -102
  23. data/doc/pages/download.textile +19 -27
  24. data/doc/pages/extending.textile +27 -81
  25. data/doc/pages/getting_started.textile +44 -119
  26. data/doc/pages/index.textile +26 -47
  27. data/doc/pages/languages.textile +407 -0
  28. data/doc/pages/more_stuff.textile +92 -173
  29. data/doc/pages/packaging.textile +71 -239
  30. data/doc/pages/projects.textile +58 -233
  31. data/doc/pages/recipes.textile +19 -43
  32. data/doc/pages/settings_profiles.textile +39 -104
  33. data/doc/pages/testing.textile +41 -304
  34. data/doc/pages/troubleshooting.textile +29 -47
  35. data/doc/pages/whats_new.textile +69 -167
  36. data/doc/print.haml +0 -1
  37. data/doc/print.toc.yaml +1 -0
  38. data/doc/scripts/buildr-git.rb +1 -1
  39. data/doc/site.haml +1 -0
  40. data/doc/site.toc.yaml +8 -5
  41. data/{KEYS → etc/KEYS} +0 -0
  42. data/etc/git-svn-authors +16 -0
  43. data/lib/buildr.rb +2 -5
  44. data/lib/buildr/core/application.rb +192 -98
  45. data/lib/buildr/core/build.rb +140 -91
  46. data/lib/buildr/core/checks.rb +5 -5
  47. data/lib/buildr/core/common.rb +1 -1
  48. data/lib/buildr/core/compile.rb +12 -10
  49. data/lib/buildr/core/filter.rb +151 -46
  50. data/lib/buildr/core/generate.rb +9 -9
  51. data/lib/buildr/core/progressbar.rb +1 -1
  52. data/lib/buildr/core/project.rb +8 -7
  53. data/lib/buildr/core/test.rb +51 -26
  54. data/lib/buildr/core/transports.rb +22 -38
  55. data/lib/buildr/core/util.rb +78 -26
  56. data/lib/buildr/groovy.rb +18 -0
  57. data/lib/buildr/groovy/bdd.rb +105 -0
  58. data/lib/buildr/groovy/compiler.rb +138 -0
  59. data/lib/buildr/ide/eclipse.rb +102 -71
  60. data/lib/buildr/ide/idea.rb +7 -12
  61. data/lib/buildr/ide/idea7x.rb +7 -8
  62. data/lib/buildr/java.rb +4 -7
  63. data/lib/buildr/java/ant.rb +26 -5
  64. data/lib/buildr/java/bdd.rb +449 -0
  65. data/lib/buildr/java/commands.rb +9 -9
  66. data/lib/buildr/java/{compilers.rb → compiler.rb} +8 -90
  67. data/lib/buildr/java/jruby.rb +29 -11
  68. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  69. data/lib/buildr/java/packaging.rb +23 -16
  70. data/lib/buildr/java/pom.rb +1 -1
  71. data/lib/buildr/java/rjb.rb +21 -8
  72. data/lib/buildr/java/test_result.rb +308 -0
  73. data/lib/buildr/java/tests.rb +324 -0
  74. data/lib/buildr/packaging/artifact.rb +12 -11
  75. data/lib/buildr/packaging/artifact_namespace.rb +7 -4
  76. data/lib/buildr/packaging/gems.rb +3 -3
  77. data/lib/buildr/packaging/zip.rb +13 -10
  78. data/lib/buildr/resources/buildr.icns +0 -0
  79. data/lib/buildr/scala.rb +19 -0
  80. data/lib/buildr/scala/compiler.rb +109 -0
  81. data/lib/buildr/scala/tests.rb +203 -0
  82. data/rakelib/apache.rake +71 -45
  83. data/rakelib/doc.rake +2 -2
  84. data/rakelib/package.rake +3 -2
  85. data/rakelib/rspec.rake +23 -21
  86. data/rakelib/setup.rake +34 -9
  87. data/rakelib/stage.rake +4 -1
  88. data/spec/addon/cobertura_spec.rb +77 -0
  89. data/spec/addon/emma_spec.rb +120 -0
  90. data/spec/addon/test_coverage_spec.rb +255 -0
  91. data/spec/{application_spec.rb → core/application_spec.rb} +82 -4
  92. data/spec/{artifact_namespace_spec.rb → core/artifact_namespace_spec.rb} +12 -1
  93. data/spec/core/build_spec.rb +415 -0
  94. data/spec/{checks_spec.rb → core/checks_spec.rb} +2 -2
  95. data/spec/{common_spec.rb → core/common_spec.rb} +119 -30
  96. data/spec/{compile_spec.rb → core/compile_spec.rb} +17 -13
  97. data/spec/core/generate_spec.rb +33 -0
  98. data/spec/{project_spec.rb → core/project_spec.rb} +9 -6
  99. data/spec/{test_spec.rb → core/test_spec.rb} +222 -28
  100. data/spec/{transport_spec.rb → core/transport_spec.rb} +5 -9
  101. data/spec/groovy/bdd_spec.rb +80 -0
  102. data/spec/{groovy_compilers_spec.rb → groovy/compiler_spec.rb} +1 -1
  103. data/spec/ide/eclipse_spec.rb +243 -0
  104. data/spec/{java_spec.rb → java/ant.rb} +7 -17
  105. data/spec/java/bdd_spec.rb +358 -0
  106. data/spec/{java_compilers_spec.rb → java/compiler_spec.rb} +1 -1
  107. data/spec/java/java_spec.rb +88 -0
  108. data/spec/{java_packaging_spec.rb → java/packaging_spec.rb} +65 -4
  109. data/spec/{java_test_frameworks_spec.rb → java/tests_spec.rb} +31 -10
  110. data/spec/{archive_spec.rb → packaging/archive_spec.rb} +12 -2
  111. data/spec/{artifact_spec.rb → packaging/artifact_spec.rb} +12 -5
  112. data/spec/{packaging_helper.rb → packaging/packaging_helper.rb} +0 -0
  113. data/spec/{packaging_spec.rb → packaging/packaging_spec.rb} +1 -1
  114. data/spec/sandbox.rb +22 -5
  115. data/spec/{scala_compilers_spec.rb → scala/compiler_spec.rb} +1 -1
  116. data/spec/{scala_test_frameworks_spec.rb → scala/tests_spec.rb} +11 -12
  117. data/spec/spec_helpers.rb +38 -17
  118. metadata +103 -70
  119. data/lib/buildr/java/bdd_frameworks.rb +0 -265
  120. data/lib/buildr/java/groovyc.rb +0 -137
  121. data/lib/buildr/java/test_frameworks.rb +0 -450
  122. data/spec/build_spec.rb +0 -193
  123. data/spec/java_bdd_frameworks_spec.rb +0 -238
  124. data/spec/spec.opts +0 -6
data/CHANGELOG CHANGED
@@ -1,3 +1,64 @@
1
+ 1.3.3 (2008-10-08)
2
+ * Added: JtestR support. Implemented pending jtestr specs.
3
+ * Added: Growl notifications (OS X only).
4
+ * Added: error, info and trace methods.
5
+ * Added: Release task support for alternative SVN repository layout
6
+ (e.g., http://my.repo.org/trunk/foo).
7
+ * Added: BUILDR-128 Emma support
8
+ * Added: BUILDR-135. Extracted reusable replacement logic into Filter::Mapper
9
+ * Added: BUILDR-148 It is now possible to set the version of various 3rd
10
+ party libraries from the build.yml file. Supported libraries
11
+ include Ant and the various test and BDD frameworks.
12
+ * Change: Error reporting now shows 'buildr aborted!' (used to say rake),
13
+ more of the stack trace without running --trace, and when running
14
+ with supported terminal, error message is red.
15
+ * Change: Eclipse task updated to documented Scala plugin requirements
16
+ (http://www.scala-lang.org/node/94)
17
+ * Change: Buildr.application.buildfile returns a task instead of a String.
18
+ * Change: BUILDR-104 Buildr::group has :under and :version, but not :type.
19
+ Now it has :type too (Lacton).
20
+ * Change: BUILDR-139 Incremental test run.
21
+ * Change: BUILDR-141 Removed NEXT_VERSION from release task.
22
+ * Change: BUILDR-148 ant-junit no longer included in root classpath, but
23
+ specified during taskdef.
24
+ * Change: BUILDR-153 To customize the SVN tag used by the release task, set
25
+ Release.tag_name to either the tag value or a proc that takes the
26
+ version number and return the desired tag.
27
+ * Fixed: Should not display "(in `pwd`, development)" when using --quiet.
28
+ * Fixed: Release task's regexp to find either THIS_VERSION and VERSION_NUMBER.
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-116: TestTask should include the main compile target in its
40
+ dependencies, even when using non standard directories (Lacton).
41
+ * Fixed: BUILDR-117 Shared directory for both code and resources produces
42
+ duplicate Eclipse classpath entries (Nathan Hamblen)
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: BUILDR-129. Modifying a project manifest should not alter it's
52
+ parent project manifest.
53
+ * Fixed: BUILDR-137 JRuby 1.1.3 and Buildr 1.3.2 don't appear to work
54
+ (on Windows).
55
+ * Fixed: BUILDR-138 ScalaTest premature use of Buildr::Repositories
56
+ inconsistent with customizing locations.
57
+ * Fixed: BUILDR-152 Project.task fails when task name starts with a colon.
58
+ * Fixed: BUILDR-157 Tasks library not loaded from a submodule.
59
+ * Docs: BUILDR-111 Troubleshoot tip when Buildr's bin directory shows up in
60
+ RUBYLIB (Geoffrey Ruscoe).
61
+
1
62
  1.3.2 (2008-07-18)
2
63
  * Added: --prereqs command line argument to show all tasks and their
3
64
  dependencies. You can also follow with regular expression to narrow down the
@@ -18,7 +79,8 @@ load Pageant DLLs when running on JRuby/Windows.
18
79
  * Fixed: BUILDR-89 JUnit (and all other Java frameworks) no longer include
19
80
  abstract classes.
20
81
  * 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
82
+ * Fixed: BUILDR-91 When doing a release, buildr should spawn the same version
83
+ of buildr
22
84
  * Fixed: BUILDR-92 IDEA 7x: add resources directories to classpath.
23
85
  * Fixed: BUILDR-95: Only download Scala test framework artifacts when required
24
86
  * Fixed: BUILDR-100 Directory structure documentation needs updating.
@@ -398,7 +460,7 @@ will come in due time (and it's not always necessary anyway).
398
460
  buildr/jdepend)
399
461
  * Added: Cobertura test coverage tasks, reporting both html and xml. (Requires
400
462
  buildr/cobertura)
401
- * Changed: tools_jar now returns empty array on OS/X, part of the ongoing
463
+ * Changed: tools_jar now returns empty array on OS X, part of the ongoing
402
464
  Write Once/Test Everywere effort. (Credit Paul Brown)
403
465
  * Fixed: Work around keep_alive bug in Net::HTTP.
404
466
  (http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/10818)
@@ -408,7 +470,7 @@ Write Once/Test Everywere effort. (Credit Paul Brown)
408
470
  TestSuite.
409
471
  * Changed: You can now run rake test:{foo,bar} to match against either foo or
410
472
  bar (requires \{..\} on UNIX).
411
- * Changed: JAVA_HOME now required on all platforms, along with more OS/X
473
+ * Changed: JAVA_HOME now required on all platforms, along with more OS X
412
474
  fixes. (Credit Paul Brown)
413
475
  * Fixed: You can now run rake test:<name> from any directory, and it will find
414
476
  just the right test cases.
@@ -436,7 +498,7 @@ projects on a project instead.
436
498
  * Fixed: Local directory tasks now work from any directory in the project.
437
499
  * Fixed: Artifacts no longer created with timestamp from server.
438
500
  * Fixed: Buildr no longer fails when run without tools.jar or JAVA_HOME
439
- (OS/X). (Credit Lyle Johnson)
501
+ (OS X). (Credit Lyle Johnson)
440
502
  * Fixed: Manifest gets EOL to keep EOF company. (Credit Tommy Knowlton)
441
503
  * Fixed: Compile tasks clean after themselves when target directory changed.
442
504
  (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.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,10 +43,10 @@ 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( ..not ASL.. )
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')
@@ -63,4 +54,9 @@ task 'spec:check' do
63
54
  puts 'OK'
64
55
  end
65
56
 
66
-
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,38 @@
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
+ start = Time.now
23
+ require 'rubygems'
24
+ $LOAD_PATH << File.join(File.dirname(__FILE__), 'lib') << File.join(File.dirname(__FILE__), 'addon')
25
+ spec = Gem::Specification.load(File.join(File.dirname(__FILE__), 'buildr.gemspec'))
26
+ spec.dependencies.each do |dep|
27
+ gem dep.name, dep.version_requirements.to_s
28
+ end
29
+ require 'buildr'
30
+ Buildr.application.run
31
+ if verbose
32
+ elapsed = Time.now - start
33
+ real = []
34
+ real << ("%ih" % (elapsed / 3600)) if elapsed >= 3600
35
+ real << ("%im" % ((elapsed / 60) % 60)) if elapsed >= 60
36
+ real << ("%.3fs" % (elapsed % 60))
37
+ puts $terminal.color("Completed in #{real.join}", :green)
38
+ end
@@ -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
@@ -199,7 +202,8 @@ module Buildr
199
202
  Buildr.projects.each do |project|
200
203
  project.cobertura.data_file = data_file
201
204
  project.test.options[:properties]["net.sourceforge.cobertura.datafile"] = data_file
202
- project.task('cobertura:instrument').invoke
205
+ instrument_task ="#{project.name}:cobertura:instrument"
206
+ task(instrument_task).invoke if Rake::Task.task_defined?(instrument_task)
203
207
  end
204
208
  end
205
209
 
@@ -207,7 +211,7 @@ module Buildr
207
211
  report_target = report_to(format)
208
212
  desc "Run the test cases and produce code coverage reports in #{report_target}"
209
213
  task format => ["instrument", "test"] do
210
- puts "Creating test coverage reports in #{report_target}"
214
+ info "Creating test coverage reports in #{report_target}"
211
215
  Buildr.ant "cobertura" do |ant|
212
216
  ant.taskdef :classpath=>requires.join(File::PATH_SEPARATOR), :resource=>"tasks.properties"
213
217
  ant.send "cobertura-report", :destdir=>report_target, :format=>format, :datafile=>data_file do
@@ -0,0 +1,238 @@
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
+ [project.emma.metadata_file, project.emma.coverage_file].each do |data_file|
211
+ ant.fileset :file=>data_file if File.exist?(data_file)
212
+ end
213
+ end
214
+ end
215
+ ant.report do
216
+ ant.infileset :file=>data_file
217
+ ant.send format, :outfile=>File.join(report_to(format), "coverage.#{format}")
218
+ ant.sourcepath do
219
+ Buildr.projects.map(&:emma).map(&:sources).flatten.map(&:to_s).each do |src|
220
+ ant.dirset :dir=>src if File.exist?(src)
221
+ end
222
+ end
223
+ end
224
+ end
225
+ end
226
+ end
227
+
228
+ task :clean do
229
+ rm_rf [report_to, data_file], :verbose=>false
230
+ end
231
+ end
232
+
233
+ task :clean do
234
+ task('emma:clean').invoke if Dir.pwd == Rake.application.original_dir
235
+ end
236
+
237
+ end
238
+ end