buildr 1.1.3 → 1.2.0
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 +48 -0
- data/README +1 -1
- data/Rakefile +204 -0
- data/bin/buildr +7 -0
- data/lib/buildr.rb +155 -16
- data/lib/buildr/cobertura.rb +26 -19
- data/lib/buildr/hibernate.rb +8 -6
- data/lib/buildr/javacc.rb +1 -0
- data/lib/buildr/jdepend.rb +31 -4
- data/lib/buildr/jetty.rb +26 -28
- data/lib/buildr/openjpa.rb +8 -6
- data/lib/buildr/xmlbeans.rb +9 -4
- data/lib/core/build.rb +40 -50
- data/lib/core/checks.rb +358 -0
- data/lib/core/common.rb +161 -62
- data/lib/core/generate.rb +65 -0
- data/lib/core/help.rb +72 -0
- data/lib/core/project.rb +32 -37
- data/lib/core/rake_ext.rb +12 -66
- data/lib/core/transports.rb +388 -363
- data/lib/java/ant.rb +33 -36
- data/lib/java/artifact.rb +172 -160
- data/lib/java/compile.rb +13 -21
- data/lib/java/eclipse.rb +5 -5
- data/lib/java/idea.ipr.template +284 -0
- data/lib/java/idea.rb +107 -72
- data/lib/java/java.rb +42 -18
- data/lib/java/packaging.rb +242 -124
- data/lib/java/test.rb +532 -135
- data/lib/tasks/zip.rb +72 -23
- metadata +24 -10
data/lib/buildr/cobertura.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
module Buildr
|
2
|
+
|
3
|
+
# Addes the <code>cobertura:html</code> and <code>cobertura:xml</code> tasks.
|
4
|
+
# Require explicitly using <code>require "buildr/cobertura"</code>.
|
2
5
|
module Cobertura
|
3
6
|
|
4
7
|
class << self
|
@@ -9,17 +12,12 @@ module Buildr
|
|
9
12
|
@requires ||= Buildr.artifacts(REQUIRES).each(&:invoke).map(&:to_s)
|
10
13
|
end
|
11
14
|
|
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
15
|
def report_to(file = nil)
|
18
|
-
File.expand_path(File.join(*["cobertura", file.to_s].compact))
|
16
|
+
File.expand_path(File.join(*["reports/cobertura", file.to_s].compact))
|
19
17
|
end
|
20
18
|
|
21
19
|
def data_file()
|
22
|
-
File.expand_path("cobertura.ser")
|
20
|
+
File.expand_path("reports/cobertura.ser")
|
23
21
|
end
|
24
22
|
|
25
23
|
end
|
@@ -32,39 +30,48 @@ module Buildr
|
|
32
30
|
# Instrumented bytecode goes in a different directory. This task creates before running the test
|
33
31
|
# cases and monitors for changes in the generate bytecode.
|
34
32
|
instrumented = project.file(project.path_to(:target, "instrumented")=>project.compile.target) do |task|
|
35
|
-
|
36
|
-
|
33
|
+
Buildr.ant "cobertura" do |ant|
|
34
|
+
ant.taskdef :classpath=>requires.join(File::PATH_SEPARATOR), :resource=>"tasks.properties"
|
35
|
+
ant.send "cobertura-instrument", :todir=>task.to_s, :datafile=>data_file do
|
36
|
+
ant.fileset(:dir=>project.compile.target.to_s) { ant.include :name=>"**/*.class" }
|
37
|
+
end
|
37
38
|
end
|
38
39
|
touch task.to_s, :verbose=>false
|
39
40
|
end
|
40
41
|
# We now have two target directories with bytecode. It would make sense to remove compile.target
|
41
42
|
# and add instrumented instead, but apparently Cobertura only creates some of the classes, so
|
42
43
|
# we need both directories and instrumented must come first.
|
43
|
-
project.test.
|
44
|
-
project.test.
|
44
|
+
project.test.classpath.unshift file(instrumented)
|
45
|
+
project.test.with requires
|
45
46
|
project.clean { rm_rf instrumented.to_s, :verbose=>false }
|
46
47
|
end
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
50
51
|
desc "Run the test cases and produce code coverage reports in #{report_to(:html)}"
|
51
|
-
task "html"=>["instrument", "
|
52
|
+
task "html"=>["instrument", "test:all"] do
|
52
53
|
puts "Creating test coverage reports in #{report_to(:html)}"
|
53
54
|
projects = Buildr.projects
|
54
|
-
|
55
|
-
|
56
|
-
|
55
|
+
Buildr.ant "cobertura" do |ant|
|
56
|
+
ant.taskdef :classpath=>requires.join(File::PATH_SEPARATOR), :resource=>"tasks.properties"
|
57
|
+
ant.send "cobertura-report", :destdir=>report_to(:html), :format=>"html", :datafile=>data_file do
|
58
|
+
ant.projects.map(&:compile).map(&:sources).flatten.each do |src|
|
59
|
+
ant.fileset(:dir=>src.to_s) { ant.include :name=>"**/*.java" } if File.exist?(src.to_s)
|
60
|
+
end
|
57
61
|
end
|
58
62
|
end
|
59
63
|
end
|
60
64
|
|
61
65
|
desc "Run the test cases and produce code coverage reports in #{report_to(:xml)}"
|
62
|
-
task "xml"=>["instrument", "
|
66
|
+
task "xml"=>["instrument", "test:all"] do
|
63
67
|
puts "Creating test coverage reports in #{report_to(:xml)}"
|
64
68
|
projects = Buildr.projects
|
65
|
-
|
66
|
-
|
67
|
-
|
69
|
+
Buildr.ant "cobertura" do |ant|
|
70
|
+
ant.taskdef :classpath=>requires.join(File::PATH_SEPARATOR), :resource=>"tasks.properties"
|
71
|
+
ant.send "cobertura-report", :destdir=>report_to(:xml), :format=>"xml", :datafile=>data_file do
|
72
|
+
ant.projects.map(&:compile).map(&:sources).flatten.each do |src|
|
73
|
+
ant.fileset :dir=>src.to_s if File.exist?(src.to_s)
|
74
|
+
end
|
68
75
|
end
|
69
76
|
end
|
70
77
|
end
|
data/lib/buildr/hibernate.rb
CHANGED
@@ -2,6 +2,8 @@ require "java/java"
|
|
2
2
|
require "java/ant"
|
3
3
|
|
4
4
|
module Buildr
|
5
|
+
|
6
|
+
# Provides Hibernate Doclet and schema export tasks. Require explicitly using <code>require "buildr/hibernate"</code>.
|
5
7
|
module Hibernate
|
6
8
|
|
7
9
|
REQUIRES = Buildr.struct(
|
@@ -29,12 +31,12 @@ module Buildr
|
|
29
31
|
# doclet :sources=>compile.sources, :target=>compile.target, :excludedtags=>"@version,@author,@todo"
|
30
32
|
def doclet(options)
|
31
33
|
options[:sources].each { |src| file(src).invoke }
|
32
|
-
ant
|
33
|
-
|
34
|
-
|
35
|
-
hibernate :version=>"3.0"
|
34
|
+
ant "hibernatedoclet" do |ant|
|
35
|
+
ant.taskdef :name=>"hibernatedoclet", :classname=>"xdoclet.modules.hibernate.HibernateDocletTask", :classpath=>requires
|
36
|
+
ant.hibernatedoclet :destdir=>options[:target].to_s, :excludedtags=>options[:excludedtags], :force=>"true" do
|
37
|
+
ant.hibernate :version=>"3.0"
|
36
38
|
options[:sources].map(&:to_s).each do |source|
|
37
|
-
fileset :dir=>source.to_s, :includes=>"**/*.java"
|
39
|
+
ant.fileset :dir=>source.to_s, :includes=>"**/*.java"
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
@@ -49,7 +51,7 @@ module Buildr
|
|
49
51
|
# fileset :dir=>source.to_s, :includes=>"**/*.hbm.xml"
|
50
52
|
# end
|
51
53
|
def schemaexport(options = nil, &block)
|
52
|
-
ant
|
54
|
+
ant "schemaexport" do |ant|
|
53
55
|
ant.taskdef :name=>"schemaexport", :classname=>"org.hibernate.tool.hbm2ddl.SchemaExportTask", :classpath=>requires
|
54
56
|
ant.schemaexport options, &block if options
|
55
57
|
end
|
data/lib/buildr/javacc.rb
CHANGED
data/lib/buildr/jdepend.rb
CHANGED
@@ -1,13 +1,40 @@
|
|
1
1
|
module Buildr
|
2
|
+
|
3
|
+
# Addes the <code>jdepend:swing</code>, <code>jdepend:text</code> and <code>jdepend:xml</code> tasks.
|
4
|
+
# Require explicitly using <code>require "buildr/jdepend"</code>.
|
2
5
|
module Jdepend
|
3
6
|
|
4
7
|
REQUIRES = ["jdepend:jdepend:jar:2.9.1"]
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
class << self
|
10
|
+
|
11
|
+
def requires()
|
12
|
+
@requires ||= Buildr.artifacts(REQUIRES).each(&:invoke).map(&:to_s)
|
13
|
+
end
|
14
|
+
|
15
|
+
def paths()
|
16
|
+
Project.projects.map(&:compile).each(&:invoke).map(&:target).map(&:to_s).select { |path| File.exist?(path) }
|
17
|
+
end
|
18
|
+
|
10
19
|
end
|
11
20
|
|
21
|
+
namespace "jdepend" do
|
22
|
+
|
23
|
+
desc "Runs JDepend on all your projects (Swing UI)"
|
24
|
+
task "swing" do
|
25
|
+
Buildr.java "jdepend.swingui.JDepend", paths, :classpath=>requires, :name=>"JDepend"
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Runs JDepend on all your projects (Text UI)"
|
29
|
+
task "text" do
|
30
|
+
Buildr.java "jdepend.textui.JDepend", paths, :classpath=>requires, :name=>"JDepend"
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Runs JDepend on all your projects (XML output to jdepend.xml)"
|
34
|
+
task "xml" do
|
35
|
+
Buildr.java "jdepend.xmlui.JDepend", "-file", "jdepend.xml", paths, :classpath=>requires, :name=>"JDepend"
|
36
|
+
puts "Created jdepend.xml"
|
37
|
+
end
|
38
|
+
end
|
12
39
|
end
|
13
40
|
end
|
data/lib/buildr/jetty.rb
CHANGED
@@ -4,6 +4,7 @@ require "core/project"
|
|
4
4
|
require "java/artifact"
|
5
5
|
require "java/java"
|
6
6
|
require "thread"
|
7
|
+
#require "struct"
|
7
8
|
|
8
9
|
module Buildr
|
9
10
|
|
@@ -16,9 +17,9 @@ module Buildr
|
|
16
17
|
#
|
17
18
|
# If you want to keep Jetty running across builds, and look at error messages, you can
|
18
19
|
# start Jetty in a separate console with:
|
19
|
-
#
|
20
|
+
# buildr jetty:start
|
20
21
|
# To stop this instance of Jetty, simply kill the process (Ctrl-C) or run:
|
21
|
-
#
|
22
|
+
# buildr jetty:stop
|
22
23
|
#
|
23
24
|
# If you start Jetty separately from the build, the #use task will connect to that
|
24
25
|
# existing server. Since you are using Jetty across several builds, you will want to
|
@@ -26,6 +27,17 @@ module Buildr
|
|
26
27
|
# which are called when Jetty is first used in the build, and when the build ends.
|
27
28
|
class Jetty
|
28
29
|
|
30
|
+
# Which version of Jetty we're using by default (change with options.jetty.version).
|
31
|
+
VERSION = "6.1.3"
|
32
|
+
|
33
|
+
# Libraries used by Jetty.
|
34
|
+
REQUIRES = [ "org.mortbay.jetty:jetty:jar:#{VERSION}", "org.mortbay.jetty:jetty-util:jar:#{VERSION}",
|
35
|
+
"org.mortbay.jetty:servlet-api-2.5:jar:#{VERSION}", "log4j:log4j:jar:1.2.13", "commons-logging:commons-logging:jar:1.1" ]
|
36
|
+
Java.rjb.onload { |rjb| rjb.classpath << REQUIRES << File.join(__DIR__, "jetty") }
|
37
|
+
|
38
|
+
# Default URL for Jetty (change with options.jetty.url).
|
39
|
+
URL = "http://localhost:8080"
|
40
|
+
|
29
41
|
class << self
|
30
42
|
|
31
43
|
# :call-seq:
|
@@ -33,24 +45,14 @@ module Buildr
|
|
33
45
|
#
|
34
46
|
# Returns an instance of Jetty.
|
35
47
|
def instance()
|
36
|
-
@instance ||= Jetty.new
|
48
|
+
@instance ||= Jetty.new("jetty", URL)
|
37
49
|
end
|
38
50
|
|
39
51
|
end
|
40
52
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
"commons-logging:commons-logging:jar:1.1" ]
|
45
|
-
|
46
|
-
Java.rjb.classpath << REQUIRES << File.join(__DIR__, "jetty")
|
47
|
-
|
48
|
-
# Default URL for Jetty.
|
49
|
-
URL = "http://localhost:8080"
|
50
|
-
|
51
|
-
def initialize() #:nodoc:
|
52
|
-
@url = URL
|
53
|
-
namespace "jetty" do
|
53
|
+
def initialize(name, url) #:nodoc:
|
54
|
+
@url = url
|
55
|
+
namespace name do
|
54
56
|
@setup = task("setup")
|
55
57
|
@teardown = task("teardown")
|
56
58
|
@use = task("use") { fire }
|
@@ -214,17 +216,13 @@ module Buildr
|
|
214
216
|
task("stop") { Jetty.instance.stop }
|
215
217
|
end
|
216
218
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
def jetty()
|
225
|
-
@jetty ||= Jetty.instance
|
226
|
-
end
|
227
|
-
|
219
|
+
# :call-seq:
|
220
|
+
# jetty() => Jetty
|
221
|
+
#
|
222
|
+
# Returns a Jetty object. You can use this to discover the Jetty#use task,
|
223
|
+
# configure the Jetty#setup and Jetty#teardown tasks, deploy and undeploy to Jetty.
|
224
|
+
def jetty()
|
225
|
+
@jetty ||= Jetty.instance
|
228
226
|
end
|
229
|
-
|
227
|
+
|
230
228
|
end
|
data/lib/buildr/openjpa.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require "java/java"
|
2
2
|
|
3
3
|
module Buildr
|
4
|
+
|
5
|
+
# Provides OpenJPA bytecode enhancement and Mapping tool task. Require explicitly using <code>require "buildr/openjpa"</code>.
|
4
6
|
module OpenJPA
|
5
7
|
|
6
8
|
VERSION = "0.9.7-incubating"
|
@@ -24,12 +26,12 @@ module Buildr
|
|
24
26
|
artifacts = Buildr.artifacts(options[:classpath]).each { |a| a.invoke }.map(&:to_s) + [options[:output].to_s]
|
25
27
|
properties = file(options[:properties]).tap { |task| task.invoke }.to_s
|
26
28
|
|
27
|
-
|
29
|
+
Buildr.ant "openjpa" do |ant|
|
28
30
|
ant.taskdef :name=>"enhancer", :classname=>"org.apache.openjpa.ant.PCEnhancerTask",
|
29
31
|
:classpath=>requires.join(File::PATH_SEPARATOR)
|
30
32
|
ant.enhancer :directory=>options[:output].to_s do
|
31
|
-
config :propertiesFile=>properties
|
32
|
-
classpath :path=>artifacts.join(File::PATH_SEPARATOR)
|
33
|
+
ant.config :propertiesFile=>properties
|
34
|
+
ant.classpath :path=>artifacts.join(File::PATH_SEPARATOR)
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
@@ -39,12 +41,12 @@ module Buildr
|
|
39
41
|
artifacts = Buildr.artifacts(options[:classpath]).each{ |a| a.invoke }.map(&:to_s)
|
40
42
|
properties = file(options[:properties].to_s).tap { |task| task.invoke }.to_s
|
41
43
|
|
42
|
-
|
44
|
+
Buildr.ant("openjpa") do |ant|
|
43
45
|
ant.taskdef :name=>"mapping", :classname=>"org.apache.openjpa.jdbc.ant.MappingToolTask",
|
44
46
|
:classpath=>requires.join(File::PATH_SEPARATOR)
|
45
47
|
ant.mapping :schemaAction=>options[:action], :sqlFile=>options[:sql].to_s, :ignoreErrors=>"true" do
|
46
|
-
config :propertiesFile=>properties
|
47
|
-
classpath :path=>artifacts.join(File::PATH_SEPARATOR)
|
48
|
+
ant.config :propertiesFile=>properties
|
49
|
+
ant.classpath :path=>artifacts.join(File::PATH_SEPARATOR)
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
data/lib/buildr/xmlbeans.rb
CHANGED
@@ -2,6 +2,8 @@ require "java/java"
|
|
2
2
|
require "java/ant"
|
3
3
|
|
4
4
|
module Buildr
|
5
|
+
|
6
|
+
# Provides XMLBeans schema compiler. Require explicitly using <code>require "buildr/xmlbeans"</code>.
|
5
7
|
module XMLBeans
|
6
8
|
|
7
9
|
REQUIRES = [ "xmlbeans:xbean:jar:2.2.0", "stax:stax-api:jar:1.0" ]
|
@@ -13,12 +15,12 @@ module Buildr
|
|
13
15
|
options[:verbose] ||= Rake.application.options.trace || false
|
14
16
|
rake_check_options options, :verbose, :noop, :javasource, :jar, :compile, :output, :xsb
|
15
17
|
puts "Running XMLBeans schema compiler" if verbose
|
16
|
-
|
18
|
+
Buildr.ant "xmlbeans" do |ant|
|
17
19
|
ant.taskdef :name=>"xmlbeans", :classname=>"org.apache.xmlbeans.impl.tool.XMLBean",
|
18
20
|
:classpath=>requires.join(File::PATH_SEPARATOR)
|
19
21
|
ant.xmlbeans :srconly=>"true", :srcgendir=>options[:output].to_s, :classgendir=>options[:output].to_s,
|
20
22
|
:javasource=>options[:javasource] do
|
21
|
-
args.flatten.each { |file| fileset File.directory?(file) ? { :dir=>file } : { :file=>file } }
|
23
|
+
args.flatten.each { |file| ant.fileset File.directory?(file) ? { :dir=>file } : { :file=>file } }
|
22
24
|
end
|
23
25
|
end
|
24
26
|
# Touch paths to let other tasks know there's an update.
|
@@ -34,9 +36,12 @@ module Buildr
|
|
34
36
|
end
|
35
37
|
|
36
38
|
def compile_xml_beans(*args)
|
39
|
+
# Run whenever XSD file changes, but typically we're given an directory of XSD files, or even file patterns
|
40
|
+
# (the last FileList is there to deal with things like *.xsdconfig).
|
41
|
+
files = args.flatten.map { |file| File.directory?(file) ? FileList["#{file}/*.xsd"] : FileList[file] }.flatten
|
37
42
|
# Generate sources and add them to the compile task.
|
38
|
-
generated = file(path_to(:target, "generated/xmlbeans")=>
|
39
|
-
XMLBeans.compile
|
43
|
+
generated = file(path_to(:target, "generated/xmlbeans")=>files) do |task|
|
44
|
+
XMLBeans.compile args.flatten, :output=>task.name,
|
40
45
|
:javasource=>compile.options.source, :xsb=>compile.target
|
41
46
|
end
|
42
47
|
compile.from(generated).with(JAVAX.stream, XMLBEANS)
|
data/lib/core/build.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require "core/project"
|
2
|
+
require "core/common"
|
3
|
+
require "core/checks"
|
2
4
|
|
3
5
|
module Buildr
|
4
6
|
|
@@ -12,47 +14,37 @@ module Buildr
|
|
12
14
|
Project.local_task("install"=>"package") { |name| "Installing packages from #{name}" }
|
13
15
|
desc "Remove previously installed packages"
|
14
16
|
Project.local_task("uninstall") { |name| "Uninstalling packages from #{name}" }
|
15
|
-
desc "
|
16
|
-
Project.local_task("
|
17
|
+
desc "Upload packages created by the project"
|
18
|
+
Project.local_task("upload"=>"package") { |name| "Deploying packages from #{name}" }
|
17
19
|
|
18
|
-
[ :build, :clean, :package, :install, :uninstall, :
|
20
|
+
[ :build, :clean, :package, :install, :uninstall, :upload ].each do |name|
|
19
21
|
Project.on_define { |project| project.recursive_task name }
|
20
22
|
end
|
21
23
|
|
24
|
+
task("deploy"=>"upload") do
|
25
|
+
warn_deprecated "Please use the 'upload' task instead of 'deploy'."
|
26
|
+
end
|
27
|
+
|
22
28
|
|
23
|
-
# Collection of options for controlling Buildr. For example for running builds without running
|
24
|
-
# test cases, or running builds in parallel.
|
25
29
|
class Options
|
26
30
|
|
27
31
|
# Runs the build in parallel when true (defaults to false). You can force a parallel build by
|
28
32
|
# setting this option directly, or by running the parallel task ahead of the build task.
|
29
33
|
#
|
30
34
|
# This option only affects recurvise tasks. For example:
|
31
|
-
#
|
35
|
+
# buildr parallel package
|
32
36
|
# will run all package tasks (from the sub-projects) in parallel, but each sub-project's package
|
33
37
|
# task runs its child tasks (prepare, compile, resources, etc) in sequence.
|
34
38
|
attr_accessor :parallel
|
35
39
|
|
36
40
|
end
|
37
41
|
|
38
|
-
class << self
|
39
|
-
|
40
|
-
# :call-seq:
|
41
|
-
# options() => Options
|
42
|
-
#
|
43
|
-
# Returns the Buildr options. See Options.
|
44
|
-
def options()
|
45
|
-
@options ||= Options.new
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
42
|
task("parallel") { Buildr.options.parallel = true }
|
51
43
|
|
52
44
|
|
53
45
|
class Project
|
54
46
|
|
55
|
-
# The target directory. By default, it's the target directory inside the project. Various tasks
|
47
|
+
# The target directory. By default, it's the "target" directory inside the project. Various tasks
|
56
48
|
# use it to determine where to place files, e.g. when compiling or packaging. The clean task
|
57
49
|
# nukes it.
|
58
50
|
def target()
|
@@ -63,6 +55,17 @@ module Buildr
|
|
63
55
|
@target = _(dir)
|
64
56
|
end
|
65
57
|
|
58
|
+
# The reports directory. By default, it's the "reports" directory inside the project. Various tasks
|
59
|
+
# use it to determine where to place reports, e.g. when running test cases or code analysis.
|
60
|
+
# The clean task nukes it.
|
61
|
+
def reports()
|
62
|
+
@reports ||= _("reports")
|
63
|
+
end
|
64
|
+
|
65
|
+
def reports=(dir)
|
66
|
+
@reports = _(dir)
|
67
|
+
end
|
68
|
+
|
66
69
|
# :call-seq:
|
67
70
|
# build(*prereqs) => task
|
68
71
|
# build { |task| .. } => task
|
@@ -73,8 +76,8 @@ module Buildr
|
|
73
76
|
end
|
74
77
|
|
75
78
|
# :call-seq:
|
76
|
-
#
|
77
|
-
#
|
79
|
+
# clean(*prereqs) => task
|
80
|
+
# clean { |task| .. } => task
|
78
81
|
#
|
79
82
|
# Returns the project's clean task. With arguments or block, also enhances that task.
|
80
83
|
def clean(*prereqs, &block)
|
@@ -83,8 +86,14 @@ module Buildr
|
|
83
86
|
|
84
87
|
end
|
85
88
|
|
89
|
+
|
86
90
|
Project.on_define do |project|
|
87
|
-
project.clean
|
91
|
+
project.clean do
|
92
|
+
verbose(true) do
|
93
|
+
rm_rf project.path_to(:target)
|
94
|
+
rm_rf project.path_to(:reports)
|
95
|
+
end
|
96
|
+
end
|
88
97
|
end
|
89
98
|
|
90
99
|
desc "The default task it build"
|
@@ -104,7 +113,7 @@ module Buildr
|
|
104
113
|
# Make a release.
|
105
114
|
def make()
|
106
115
|
check
|
107
|
-
version = with_next_version { |filename, version| sh "
|
116
|
+
version = with_next_version { |filename, version| sh "buildr clean upload DEBUG=no --buildfile #{filename}" }
|
108
117
|
tag version
|
109
118
|
commit version + "-SNAPSHOT"
|
110
119
|
end
|
@@ -129,9 +138,9 @@ module Buildr
|
|
129
138
|
# Yields to block with upgraded version number, before committing to use it. Returns the *new*
|
130
139
|
# current version number.
|
131
140
|
#
|
132
|
-
# We need a
|
133
|
-
#
|
134
|
-
# a separate (
|
141
|
+
# We need a Buildfile with upgraded version numbers to run the build, but we don't want the
|
142
|
+
# Buildfile modified unless the build succeeds. So this method updates the version numbers in
|
143
|
+
# a separate (Buildfile.next) file, yields to the block with that filename, and if successful
|
135
144
|
# copies the new file over the existing one.
|
136
145
|
#
|
137
146
|
# Version numbers are updated as follows. The next release version becomes the current one,
|
@@ -160,19 +169,19 @@ module Buildr
|
|
160
169
|
end
|
161
170
|
|
162
171
|
# :call-seq:
|
163
|
-
# change_version() { |this, next| ... } =>
|
172
|
+
# change_version() { |this, next| ... } => buildfile
|
164
173
|
#
|
165
|
-
# Change version numbers in the current
|
166
|
-
# Returns the contents of the
|
174
|
+
# Change version numbers in the current Buildfile, but without writing a new file (yet).
|
175
|
+
# Returns the contents of the Buildfile with the modified version numbers.
|
167
176
|
#
|
168
177
|
# This method yields to the block with the current (this) and next version numbers and expects
|
169
178
|
# an array with the new this and next version numbers.
|
170
179
|
def change_version()
|
171
180
|
rakefile = File.read(Rake.application.rakefile)
|
172
181
|
this_version = rakefile.scan(THIS_VERSION_PATTERN)[0][1] or
|
173
|
-
fail "Looking for THIS_VERSION = \"...\" in your
|
182
|
+
fail "Looking for THIS_VERSION = \"...\" in your Buildfile, none found"
|
174
183
|
next_version = rakefile.scan(NEXT_VERSION_PATTERN)[0][1] or
|
175
|
-
fail "Looking for NEXT_VERSION = \"...\" in your
|
184
|
+
fail "Looking for NEXT_VERSION = \"...\" in your Buildfile, none found"
|
176
185
|
this_version, next_version = yield(this_version, next_version)
|
177
186
|
if verbose
|
178
187
|
puts "Upgrading version numbers:"
|
@@ -222,23 +231,4 @@ module Buildr
|
|
222
231
|
Release.make
|
223
232
|
end
|
224
233
|
|
225
|
-
|
226
|
-
namespace "buildr" do
|
227
|
-
|
228
|
-
desc "Freezes the Rakefile so it always uses Buildr version #{Buildr::VERSION}"
|
229
|
-
task "freeze" do
|
230
|
-
gem = %Q{gem "buildr", "#{Buildr::VERSION}"}
|
231
|
-
rakefile = read(Rake.application.rakefile)
|
232
|
-
puts "Freezing the Rakefile so it always uses Buildr version #{Buildr::VERSION}"
|
233
|
-
write Rake.application.rakefile, rakefile =~ /gem\s*(["'])buildr\1/ ?
|
234
|
-
rakefile.sub(/gem\s*(["'])buildr\1\s*,\s*(["']).*\2/, gem) : gem + "\n" + rakefile
|
235
|
-
end
|
236
|
-
|
237
|
-
desc "Unfreezes the Rakefile to use the latest version of Buildr"
|
238
|
-
task "unfreeze" do
|
239
|
-
puts "Unfreezing the Rakefile to use the latest version of Buildr from your Gems repository"
|
240
|
-
write Rake.application.rakefile, read(Rake.application.rakefile).sub(/^\s*gem\s*(["'])buildr\1.*\n/, "")
|
241
|
-
end
|
242
|
-
|
243
|
-
end
|
244
234
|
end
|