buildr 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ 1.1.2 (5/29/2007)
2
+ * Added: Allow passing :java_args option to the junit task
3
+ * Added: Hibernate XDoclet and SchemaExport tasks. (Requires buildr/hibernate)
4
+ * Added: JDepend UI for seeing depenencies across all projects. (Requires buildr/jdepend)
5
+ * Added: Cobertura test coverage tasks, reporting both html and xml. (Requires buildr/cobertura)
6
+ * Changed: tools_jar now returns empty array on OS/X, part of the ongoing Write Once/Test Everywere effort. (Credit Paul Brown)
7
+ * Fixed: Work around keep_alive bug in Net::HTTP. (http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/10818)
8
+
1
9
  1.1.1 (5/16/2007)
2
10
  * Changed: Test case class names must end with Test, TestCase, Suite or TestSuite.
3
11
  * Changed: You can now run rake test:{foo,bar} to match against either foo or bar (requires \{..\} on UNIX).
data/lib/buildr.rb CHANGED
@@ -32,7 +32,7 @@ end
32
32
 
33
33
 
34
34
  module Buildr
35
- VERSION = "1.1.1"
35
+ VERSION = "1.1.2"
36
36
  end
37
37
 
38
38
  $LOAD_PATH.unshift __DIR__
@@ -0,0 +1,82 @@
1
+ module Buildr
2
+ module Cobertura
3
+
4
+ class << self
5
+
6
+ REQUIRES = ["cobertura:cobertura:jar:1.8", "log4j:log4j:jar:1.2.9", "asm:asm:jar:2.2.1", "oro:oro:jar:2.0.8"]
7
+
8
+ def requires()
9
+ @requires ||= Buildr.artifacts(REQUIRES).each(&:invoke).map(&:to_s)
10
+ end
11
+
12
+ def ant_project()
13
+ @ant_project ||= Buildr::Ant.executable("cobertura") { |ant|
14
+ ant.taskdef(:classpath=>requires.join(File::PATH_SEPARATOR), :resource=>"tasks.properties" ) }
15
+ end
16
+
17
+ def report_to(file = nil)
18
+ File.expand_path(File.join(*["cobertura", file.to_s].compact))
19
+ end
20
+
21
+ def data_file()
22
+ File.expand_path("cobertura.ser")
23
+ end
24
+
25
+ end
26
+
27
+ namespace "cobertura" do
28
+
29
+ task "instrument" do
30
+ Buildr.projects.each do |project|
31
+ unless project.compile.sources.empty?
32
+ # Instrumented bytecode goes in a different directory. This task creates before running the test
33
+ # cases and monitors for changes in the generate bytecode.
34
+ instrumented = project.file(project.path_to(:target, "instrumented")=>project.compile.target) do |task|
35
+ ant_project.send "cobertura-instrument", :todir=>task.to_s, :datafile=>data_file do
36
+ fileset(:dir=>project.compile.target.to_s) { include :name=>"**/*.class" }
37
+ end
38
+ touch task.to_s, :verbose=>false
39
+ end
40
+ # We now have two target directories with bytecode. It would make sense to remove compile.target
41
+ # and add instrumented instead, but apparently Cobertura only creates some of the classes, so
42
+ # we need both directories and instrumented must come first.
43
+ project.test.junit.classpath.unshift file(instrumented)
44
+ project.test.junit.with requires
45
+ project.clean { rm_rf instrumented.to_s, :verbose=>false }
46
+ end
47
+ end
48
+ end
49
+
50
+ desc "Run the test cases and produce code coverage reports in #{report_to(:html)}"
51
+ task "html"=>["instrument", "build"] do
52
+ puts "Creating test coverage reports in #{report_to(:html)}"
53
+ projects = Buildr.projects
54
+ ant_project.send "cobertura-report", :destdir=>report_to(:html), :format=>"html", :datafile=>data_file do
55
+ projects.map(&:compile).map(&:sources).flatten.each do |src|
56
+ fileset(:dir=>src.to_s) { include :name=>"**/*.java" } if File.exist?(src.to_s)
57
+ end
58
+ end
59
+ end
60
+
61
+ desc "Run the test cases and produce code coverage reports in #{report_to(:xml)}"
62
+ task "xml"=>["instrument", "build"] do
63
+ puts "Creating test coverage reports in #{report_to(:xml)}"
64
+ projects = Buildr.projects
65
+ ant_project.send "cobertura-report", :destdir=>report_to(:xml), :format=>"xml", :datafile=>data_file do
66
+ projects.map(&:compile).map(&:sources).flatten.each do |src|
67
+ fileset :dir=>src.to_s if File.exist?(src.to_s)
68
+ end
69
+ end
70
+ end
71
+
72
+ task "clean" do
73
+ rm_rf [report_to, data_file], :verbose=>false
74
+ end
75
+ end
76
+
77
+ task "clean" do
78
+ task("cobertura:clean").invoke if Dir.pwd == Rake.application.original_dir
79
+ end
80
+
81
+ end
82
+ end
@@ -0,0 +1,123 @@
1
+ require "java/java"
2
+ require "java/ant"
3
+
4
+ module Buildr
5
+ module Hibernate
6
+
7
+ REQUIRES = Buildr.struct(
8
+ :collections => "commons-collections:commons-collections:jar:3.1",
9
+ :logging => "commons-logging:commons-logging:jar:1.0.3",
10
+ :dom4j => "dom4j:dom4j:jar:1.6.1",
11
+ :hibernate => "org.hibernate:hibernate:jar:3.1.2",
12
+ :xdoclet => Buildr.group("xdoclet", "xdoclet-xdoclet-module", "xdoclet-hibernate-module",
13
+ :under=>"xdoclet", :version=>"1.2.3") + ["xdoclet:xjavadoc:jar:1.1-j5"]
14
+ )
15
+
16
+ class << self
17
+ include Buildr::Ant
18
+
19
+ # :call-seq:
20
+ # doclet(options) => AntProject
21
+ #
22
+ # Uses XDoclet to generate HBM files form annotated source files.
23
+ # Options include:
24
+ # * :sources -- Directory (or directories) containing source files.
25
+ # * :target -- The target directory.
26
+ # * :excludetags -- Tags to exclude (see HibernateDocletTask)
27
+ #
28
+ # For example:
29
+ # doclet :sources=>compile.sources, :target=>compile.target, :excludedtags=>"@version,@author,@todo"
30
+ def doclet(options)
31
+ options[:sources].each { |src| file(src).invoke }
32
+ ant("hibernatedoclet") do |doclet|
33
+ doclet.taskdef :name=>"hibernatedoclet", :classname=>"xdoclet.modules.hibernate.HibernateDocletTask", :classpath=>requires
34
+ doclet.hibernatedoclet :destdir=>options[:target].to_s, :excludedtags=>options[:excludedtags], :force=>"true" do
35
+ hibernate :version=>"3.0"
36
+ options[:sources].map(&:to_s).each do |source|
37
+ fileset :dir=>source.to_s, :includes=>"**/*.java"
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ # :call-seq:
44
+ # schemaexport(properties) { ... } => AntProject
45
+ #
46
+ # Runs the Hibernate SchemaExportTask with the specified properties. For example:
47
+ # Buildr::Hibernate.schemaexport(:properties=>properties.to_s, :quiet=>"yes", :text=>"yes", :delimiter=>";",
48
+ # :drop=>"no", :create=>"yes", :output=>target) do
49
+ # fileset :dir=>source.to_s, :includes=>"**/*.hbm.xml"
50
+ # end
51
+ def schemaexport(options = nil, &block)
52
+ ant("schemaexport") do |ant|
53
+ ant.taskdef :name=>"schemaexport", :classname=>"org.hibernate.tool.hbm2ddl.SchemaExportTask", :classpath=>requires
54
+ ant.schemaexport options, &block if options
55
+ end
56
+ end
57
+
58
+ protected
59
+
60
+ # This will download all the required artifacts before returning a classpath, and we want to do this only once.
61
+ def requires()
62
+ @requires ||= Buildr.artifacts(REQUIRES.to_a).each(&:invoke).map(&:to_s).join(File::PATH_SEPARATOR)
63
+ end
64
+
65
+ end
66
+
67
+ # :call-seq:
68
+ # hibernate_doclet(options?) => task
69
+ #
70
+ # Runs the hibernate doclet on the source files and creates HBM files in the target directory.
71
+ # By default runs on all source files, but you can limit it to a given package using the :package
72
+ # options. You can also pass other options to the doclet task.
73
+ #
74
+ # For example:
75
+ # resources hibernate_doclet(:package=>"org.apache.ode.store.hib", :excludedtags=>"@version,@author,@todo")
76
+ def hibernate_doclet(options = {})
77
+ if options[:package]
78
+ depends = compile.sources.map { |src| FileList[File.join(src.to_s, options[:package].gsub(".", "/"), "*.java")] }.flatten
79
+ else
80
+ depends = compile.sources.map { |src| FileList[File.join(src.to_s, "**/*.java")] }.flatten
81
+ end
82
+ file("target/hbm.timestamp"=>depends) do |task|
83
+ Hibernate.doclet({ :sources=>compile.sources, :target=>compile.target }.merge(options))
84
+ write task.name
85
+ end
86
+ end
87
+
88
+ # :call-seq:
89
+ # hibernate_schemaexport(path) => task
90
+ # hibernate_schemaexport(path) { |task, ant| .. } => task
91
+ #
92
+ # Returns an new file task with an accessor (ant) to an AntProject that defines the schemaexport task.
93
+ # If called with a block, the task will yield to the block passing both itself and the Ant project.
94
+ #
95
+ # See #schemaexport.
96
+ #
97
+ # For example:
98
+ # hibernate_schemaexport "derby.sql" do |task, ant|
99
+ # ant.schemaexport :properties=>"derby.properties", :output=>task.name,
100
+ # :delimiter=>";", :drop=>"no", :create=>"yes" do
101
+ # fileset(:dir=>path_to(:java_src_dir)) { include :name=>"**/*.hbm.xml" } }
102
+ # end
103
+ # end
104
+ def hibernate_schemaexport(args, &block)
105
+ path, deps = Rake.application.resolve_args(args)
106
+ unless Rake::Task.task_defined?(path)
107
+ class << file(path) ; attr_accessor :ant ; end
108
+ file(path).enhance { |task| task.ant = Hibernate.schemaexport }
109
+ end
110
+ if block
111
+ file(path).enhance(deps) { |task| block.call task, task.ant }
112
+ else
113
+ file(path).enhance deps
114
+ end
115
+ end
116
+
117
+ end
118
+
119
+ class Project
120
+ include Hibernate
121
+ end
122
+
123
+ end
@@ -0,0 +1,13 @@
1
+ module Buildr
2
+ module Jdepend
3
+
4
+ REQUIRES = ["jdepend:jdepend:jar:2.9.1"]
5
+
6
+ desc "Runs JDepend on all your projects"
7
+ task "jdepend" do
8
+ paths = Project.projects.map(&:compile).each(&:invoke).map(&:target).map(&:to_s).select { |path| File.exist?(path) }
9
+ Buildr.java "jdepend.swingui.JDepend", paths, :classpath=>REQUIRES
10
+ end
11
+
12
+ end
13
+ end
@@ -27,6 +27,21 @@ module Net #:nodoc:all
27
27
  end
28
28
  end
29
29
 
30
+ # Monkeypatching Net::HTTP to solve keep_alive bug, see http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/10818
31
+ module Net
32
+ class HTTP
33
+ def keep_alive?(req, res)
34
+ return false if /close/i =~ req['connection'].to_s
35
+ return false if @seems_1_0_server
36
+ return false if /close/i =~ res['connection'].to_s
37
+ return true if /keep-alive/i =~ res['connection'].to_s
38
+ return false if /close/i =~ res['proxy-connection'].to_s
39
+ return true if /keep-alive/i =~ res['proxy-connection'].to_s
40
+ (@curr_http_version == '1.1')
41
+ end
42
+ end
43
+ end
44
+
30
45
 
31
46
  module Buildr
32
47
 
@@ -74,11 +89,11 @@ module Buildr
74
89
  #
75
90
  # Convenience method for downloading a single file from the specified
76
91
  # URL to the target file.
77
- def download(url, target, options = nil)
92
+ def download(url, target, options = nil, &block)
78
93
  uri = URI.parse(url.to_s)
79
94
  path, uri.path = uri.path, ""
80
95
  const_get(uri.scheme.upcase).perform(uri, options) do |transport|
81
- transport.download(path, target)
96
+ transport.download(path, target, &block)
82
97
  end
83
98
  end
84
99
 
@@ -238,7 +253,9 @@ module Buildr
238
253
  class Digester #:nodoc:
239
254
 
240
255
  def initialize(types)
241
- types ||= [ "md5", "sha1" ]
256
+ # Digests disabled for now, we have a keep-alive problem with Net::HTTP.
257
+ #types ||= [ "md5", "sha1" ]
258
+ types ||= []
242
259
  @digests = types.inject({}) do |hash, type|
243
260
  hash[type.to_s.downcase] = Digest.const_get(type.to_s.upcase).new
244
261
  hash
@@ -304,7 +321,7 @@ module Buildr
304
321
  when Net::HTTPRedirection
305
322
  # Try to download from the new URI, handle relative redirects.
306
323
  puts "Redirected to #{response['Location']}" if Rake.application.options.trace
307
- last_modified = Transports.download(@uri + URI.parse(response["location"]), target, @options)
324
+ last_modified = Transports.download(@uri + URI.parse(response["location"]), target, @options, &block)
308
325
 
309
326
  when Net::HTTPOK
310
327
  puts "Downloading #{@uri}/#{path}" if verbose
data/lib/java/artifact.rb CHANGED
@@ -381,6 +381,8 @@ module Buildr
381
381
  Transports.perform URI.parse(repo_url.to_s), :proxy=>proxy do |http|
382
382
  mkpath File.dirname(path), :verbose=>false
383
383
  http.download(rel_path, path)
384
+ end
385
+ Transports.perform URI.parse(repo_url.to_s), :proxy=>proxy do |http|
384
386
  begin
385
387
  http.download(rel_path.ext("pom"), path.ext("pom"))
386
388
  rescue Transports::NotFound
data/lib/java/eclipse.rb CHANGED
@@ -76,8 +76,8 @@ module Buildr
76
76
  end
77
77
 
78
78
  # Classpath elements from other projects
79
- project_libs.map(&:name).sort.uniq.each do |prj_name|
80
- xml.classpathentry :kind=>'src', :combineaccessrules=>"false", :path=>"/#{prj_name}"
79
+ project_libs.map(&:id).sort.uniq.each do |project_id|
80
+ xml.classpathentry :kind=>'src', :combineaccessrules=>"false", :path=>"/#{project_id}"
81
81
  end
82
82
 
83
83
  # Main resources implicitly copied into project.compile.target
@@ -113,7 +113,7 @@ module Buildr
113
113
  File.open(task.name, "w") do |file|
114
114
  xml = Builder::XmlMarkup.new(:target=>file, :indent=>2)
115
115
  xml.projectDescription do
116
- xml.name project.name.tr(":", "-")
116
+ xml.name project.id
117
117
  xml.projects
118
118
  xml.buildSpec do
119
119
  xml.buildCommand do
data/lib/java/java.rb CHANGED
@@ -2,7 +2,7 @@ require "rjb"
2
2
  require "core/project"
3
3
 
4
4
  module Buildr
5
-
5
+
6
6
  # Base module for all things Java.
7
7
  module Java
8
8
 
@@ -82,13 +82,13 @@ module Buildr
82
82
  # :call-seq:
83
83
  # tools_jar() => path
84
84
  #
85
- # Returns a path to tools.jar. Returns nil if tools.jar not found, which may be a problem,
86
- # unless you're running OS/X.
85
+ # Returns a path to tools.jar. On OS/X which has not tools.jar, returns an empty array,
86
+ # on all other platforms, fails if it doesn't find tools.jar.
87
87
  def tools_jar()
88
- return nil if darwin?
89
- @tools ||= File.join(home, "lib/tools.jar") or raise "I need tools.jar to compile, can't find it in #{home}/lib"
88
+ return [] if darwin?
89
+ @tools ||= [File.join(home, "lib/tools.jar")] or raise "I need tools.jar to compile, can't find it in #{home}/lib"
90
90
  end
91
-
91
+
92
92
  # :call-seq:
93
93
  # home() => path
94
94
  #
@@ -275,7 +275,7 @@ module Buildr
275
275
  def junit(*args)
276
276
  options = Hash === args.last ? args.pop : {}
277
277
  options[:verbose] ||= Rake.application.options.trace || false
278
- rake_check_options options, :verbose, :classpath, :properties
278
+ rake_check_options options, :verbose, :classpath, :properties, :java_args
279
279
 
280
280
  classpath = classpath_from(options) + junit_artifacts
281
281
  tests = args.flatten
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.3
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: buildr
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.1.1
7
- date: 2007-05-16 00:00:00 -07:00
6
+ version: 1.1.2
7
+ date: 2007-05-29 00:00:00 -07:00
8
8
  summary: A build system that doesn't suck
9
9
  require_paths:
10
10
  - lib
@@ -42,8 +42,11 @@ files:
42
42
  - lib/core/rake_ext.rb
43
43
  - lib/core/common.rb
44
44
  - lib/buildr/jetty.rb
45
+ - lib/buildr/hibernate.rb
45
46
  - lib/buildr/xmlbeans.rb
46
47
  - lib/buildr/javacc.rb
48
+ - lib/buildr/cobertura.rb
49
+ - lib/buildr/jdepend.rb
47
50
  - lib/buildr/openjpa.rb
48
51
  - lib/buildr/jetty
49
52
  - lib/buildr/jetty/JettyWrapper.java