buildr 1.3.5 → 1.4.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.
Files changed (151) hide show
  1. data/CHANGELOG +153 -8
  2. data/README.rdoc +1 -1
  3. data/addon/buildr/antlr.rb +5 -5
  4. data/addon/buildr/drb.rb +18 -18
  5. data/addon/buildr/hibernate.rb +18 -14
  6. data/addon/buildr/javacc.rb +4 -4
  7. data/addon/buildr/jetty.rb +5 -5
  8. data/addon/buildr/nailgun.rb +23 -23
  9. data/addon/buildr/openjpa.rb +1 -1
  10. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  11. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  12. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  13. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  14. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  15. data/addon/buildr/protobuf.rb +75 -0
  16. data/addon/buildr/xmlbeans.rb +5 -5
  17. data/buildr.buildfile +2 -2
  18. data/buildr.gemspec +8 -7
  19. data/doc/_layouts/default.html +2 -2
  20. data/doc/artifacts.textile +4 -4
  21. data/doc/building.textile +35 -3
  22. data/doc/contributing.textile +5 -0
  23. data/doc/download.textile +16 -5
  24. data/doc/extending.textile +38 -12
  25. data/doc/installing.textile +6 -5
  26. data/doc/languages.textile +182 -42
  27. data/doc/more_stuff.textile +2 -2
  28. data/doc/packaging.textile +14 -15
  29. data/doc/projects.textile +7 -2
  30. data/doc/quick_start.textile +4 -4
  31. data/doc/scripts/buildr-git.rb +63 -63
  32. data/doc/scripts/gitflow.rb +21 -21
  33. data/doc/settings_profiles.textile +9 -2
  34. data/doc/testing.textile +16 -5
  35. data/etc/KEYS +38 -0
  36. data/lib/buildr/core/application.rb +33 -27
  37. data/lib/buildr/core/build.rb +41 -28
  38. data/lib/buildr/core/cc.rb +172 -0
  39. data/lib/buildr/core/checks.rb +1 -1
  40. data/lib/buildr/core/common.rb +7 -6
  41. data/lib/buildr/core/compile.rb +7 -8
  42. data/lib/buildr/core/doc.rb +263 -0
  43. data/lib/buildr/core/environment.rb +6 -6
  44. data/lib/buildr/core/filter.rb +77 -35
  45. data/lib/buildr/core/generate.rb +7 -7
  46. data/lib/buildr/core/help.rb +1 -1
  47. data/lib/buildr/core/osx.rb +6 -6
  48. data/lib/buildr/core/progressbar.rb +4 -4
  49. data/lib/buildr/core/project.rb +144 -36
  50. data/lib/buildr/core/shell.rb +34 -34
  51. data/lib/buildr/core/test.rb +89 -20
  52. data/lib/buildr/core/transports.rb +8 -7
  53. data/lib/buildr/core/util.rb +77 -23
  54. data/lib/buildr/core.rb +1 -0
  55. data/lib/buildr/groovy/bdd.rb +5 -5
  56. data/lib/buildr/groovy/compiler.rb +19 -15
  57. data/lib/buildr/groovy/shell.rb +6 -6
  58. data/lib/buildr/ide/eclipse/java.rb +3 -3
  59. data/lib/buildr/ide/eclipse/plugin.rb +8 -5
  60. data/lib/buildr/ide/eclipse/scala.rb +4 -2
  61. data/lib/buildr/ide/eclipse.rb +148 -75
  62. data/lib/buildr/ide/idea.rb +2 -2
  63. data/lib/buildr/ide/idea7x.rb +23 -4
  64. data/lib/buildr/java/ant.rb +4 -4
  65. data/lib/buildr/java/bdd.rb +51 -54
  66. data/lib/buildr/java/cobertura.rb +57 -35
  67. data/lib/buildr/java/commands.rb +14 -5
  68. data/lib/buildr/java/compiler.rb +3 -217
  69. data/lib/buildr/java/deprecated.rb +4 -4
  70. data/lib/buildr/java/doc.rb +70 -0
  71. data/lib/buildr/java/emma.rb +22 -22
  72. data/lib/buildr/java/jruby.rb +4 -4
  73. data/lib/buildr/java/jtestr_runner.rb.erb +27 -25
  74. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  75. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +8 -3
  76. data/lib/buildr/java/packaging.rb +30 -29
  77. data/lib/buildr/java/pom.rb +4 -4
  78. data/lib/buildr/java/rjb.rb +6 -6
  79. data/lib/buildr/java/test_result.rb +61 -85
  80. data/lib/buildr/java/tests.rb +44 -27
  81. data/lib/buildr/java/version_requirement.rb +8 -8
  82. data/lib/buildr/java.rb +1 -0
  83. data/lib/buildr/packaging/archive.rb +55 -22
  84. data/lib/buildr/packaging/artifact.rb +75 -36
  85. data/lib/buildr/packaging/artifact_namespace.rb +90 -78
  86. data/lib/buildr/packaging/artifact_search.rb +5 -5
  87. data/lib/buildr/packaging/gems.rb +11 -7
  88. data/lib/buildr/packaging/package.rb +10 -7
  89. data/lib/buildr/packaging/tar.rb +14 -14
  90. data/lib/buildr/packaging/version_requirement.rb +30 -10
  91. data/lib/buildr/packaging/ziptask.rb +51 -13
  92. data/lib/buildr/scala/bdd.rb +25 -20
  93. data/lib/buildr/scala/compiler.rb +87 -40
  94. data/lib/buildr/scala/doc.rb +106 -0
  95. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  96. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
  97. data/lib/buildr/scala/shell.rb +14 -9
  98. data/lib/buildr/scala/tests.rb +33 -26
  99. data/lib/buildr/scala.rb +1 -0
  100. data/lib/buildr/shell.rb +33 -33
  101. data/lib/buildr.rb +1 -1
  102. data/rakelib/all-in-one.rake +113 -0
  103. data/rakelib/checks.rake +1 -1
  104. data/rakelib/doc.rake +7 -0
  105. data/rakelib/package.rake +1 -1
  106. data/rakelib/release.rake +9 -6
  107. data/rakelib/rspec.rake +26 -7
  108. data/rakelib/setup.rake +15 -3
  109. data/rakelib/stage.rake +18 -11
  110. data/spec/addon/drb_spec.rb +25 -25
  111. data/spec/core/application_spec.rb +111 -21
  112. data/spec/core/build_spec.rb +16 -15
  113. data/spec/core/cc_spec.rb +174 -0
  114. data/spec/core/checks_spec.rb +34 -34
  115. data/spec/core/common_spec.rb +51 -5
  116. data/spec/core/compile_spec.rb +89 -14
  117. data/spec/core/extension_spec.rb +127 -19
  118. data/spec/core/generate_spec.rb +2 -2
  119. data/spec/core/project_spec.rb +10 -10
  120. data/spec/core/test_spec.rb +144 -35
  121. data/spec/core/transport_spec.rb +8 -8
  122. data/spec/core/util_spec.rb +63 -5
  123. data/spec/groovy/bdd_spec.rb +5 -5
  124. data/spec/groovy/compiler_spec.rb +29 -18
  125. data/spec/ide/eclipse_spec.rb +185 -9
  126. data/spec/ide/idea7x_spec.rb +22 -10
  127. data/spec/java/ant_spec.rb +9 -5
  128. data/spec/java/bdd_spec.rb +29 -37
  129. data/spec/java/cobertura_spec.rb +12 -12
  130. data/spec/java/commands_spec.rb +34 -0
  131. data/spec/java/compiler_spec.rb +53 -53
  132. data/spec/java/emma_spec.rb +11 -11
  133. data/spec/java/java_spec.rb +10 -10
  134. data/spec/java/packaging_spec.rb +67 -20
  135. data/spec/java/test_coverage_helper.rb +18 -18
  136. data/spec/java/tests_spec.rb +13 -9
  137. data/spec/packaging/archive_spec.rb +187 -20
  138. data/spec/packaging/artifact_namespace_spec.rb +172 -83
  139. data/spec/packaging/artifact_spec.rb +83 -18
  140. data/spec/packaging/packaging_spec.rb +41 -14
  141. data/spec/sandbox.rb +23 -12
  142. data/spec/scala/bdd_spec.rb +13 -8
  143. data/spec/scala/compiler_spec.rb +18 -13
  144. data/spec/scala/scala.rb +3 -3
  145. data/spec/scala/tests_spec.rb +46 -24
  146. data/spec/spec_helpers.rb +28 -10
  147. data/spec/version_requirement_spec.rb +25 -11
  148. metadata +149 -133
  149. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  150. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +0 -35
  151. data/rakelib/stage.rake~ +0 -213
@@ -38,9 +38,9 @@ module Buildr
38
38
 
39
39
  # :java nature explicitly set
40
40
  if eclipse.natures.include? :java
41
- eclipse.natures += NATURE unless eclipse.natures.include? NATURE
42
- eclipse.classpath_containers += CONTAINER unless eclipse.classpath_containers.include? CONTAINER
43
- eclipse.builders += BUILDER unless eclipse.builders.include? BUILDER
41
+ eclipse.natures += [NATURE] unless eclipse.natures.include? NATURE
42
+ eclipse.classpath_containers += [CONTAINER] unless eclipse.classpath_containers.include? CONTAINER
43
+ eclipse.builders += [BUILDER] unless eclipse.builders.include? BUILDER
44
44
  end
45
45
  end
46
46
 
@@ -30,7 +30,10 @@ module Buildr
30
30
  eclipse = project.eclipse
31
31
 
32
32
  # smart defaults
33
- if eclipse.natures.empty? && ((File.exists? project.path_to("plugin.xml")) || (File.exists? project.path_to("OSGI-INF")))
33
+ if eclipse.natures.empty? && (
34
+ (File.exists? project.path_to("plugin.xml")) ||
35
+ (File.exists? project.path_to("OSGI-INF")) ||
36
+ (File.exists?(project.path_to("META-INF/MANIFEST.MF")) && File.read(project.path_to("META-INF/MANIFEST.MF")).match(/^Bundle-SymbolicName:/)))
34
37
  eclipse.natures = [NATURE, Buildr::Eclipse::Java::NATURE]
35
38
  eclipse.classpath_containers = [CONTAINER, Buildr::Eclipse::Java::CONTAINER] if eclipse.classpath_containers.empty?
36
39
  eclipse.builders = BUILDERS + [Buildr::Eclipse::Java::BUILDER] if eclipse.builders.empty?
@@ -49,12 +52,12 @@ module Buildr
49
52
  index = eclipse.classpath_containers.index(Buildr::Eclipse::Java::CONTAINER) || -1
50
53
  eclipse.classpath_containers = eclipse.classpath_containers.insert(index, CONTAINER)
51
54
  end
52
- unless (eclipse.builders.include?(BUILDER[0]) && eclipse.builders.include?(BUILDER[1]))
55
+ unless (eclipse.builders.include?(BUILDERS[0]) && eclipse.builders.include?(BUILDERS[1]))
53
56
  # plugin builder must be before java builder
54
57
  index = eclipse.classpath_containers.index(Buildr::Eclipse::Java::BUILDER) || -1
55
- eclipse.builders = eclipse.builders.insert(index, BUILDER[1]) unless eclipse.builders.include? BUILDER[1]
56
- index = eclipse.classpath_containers.index(BUILDER[1]) || -1
57
- eclipse.builders = eclipse.builders.insert(index, BUILDER[0]) unless eclipse.builders.include? BUILDER[0]
58
+ eclipse.builders = eclipse.builders.insert(index, BUILDERS[1]) unless eclipse.builders.include? BUILDERS[1]
59
+ index = eclipse.classpath_containers.index(BUILDERS[1]) || -1
60
+ eclipse.builders = eclipse.builders.insert(index, BUILDERS[0]) unless eclipse.builders.include? BUILDERS[0]
58
61
  end
59
62
  end
60
63
  end
@@ -26,14 +26,15 @@ module Buildr
26
26
  CONTAINER = 'ch.epfl.lamp.sdt.launching.SCALA_CONTAINER'
27
27
  BUILDER = 'ch.epfl.lamp.sdt.core.scalabuilder'
28
28
 
29
- after_define do |project|
29
+ after_define :eclipse => :eclipse_scala
30
+ after_define :eclipse_scala do |project|
30
31
  eclipse = project.eclipse
31
-
32
32
  # smart defaults
33
33
  if eclipse.natures.empty? && (project.compile.language == :scala || project.test.compile.language == :scala)
34
34
  eclipse.natures = [NATURE, Buildr::Eclipse::Java::NATURE]
35
35
  eclipse.classpath_containers = [CONTAINER, Buildr::Eclipse::Java::CONTAINER] if eclipse.classpath_containers.empty?
36
36
  eclipse.builders = BUILDER if eclipse.builders.empty?
37
+ eclipse.exclude_libs += Buildr::Scala::Scalac.dependencies
37
38
  end
38
39
 
39
40
  # :scala nature explicitly set
@@ -54,6 +55,7 @@ module Buildr
54
55
  eclipse.builders -= [Buildr::Eclipse::Java::BUILDER]
55
56
  eclipse.builders += [BUILDER]
56
57
  end
58
+ eclipse.exclude_libs += Buildr::Scala::Scalac.dependencies
57
59
  end
58
60
  end
59
61
 
@@ -31,6 +31,29 @@ module Buildr
31
31
  @options = Options.new(project)
32
32
  end
33
33
 
34
+ # :call-seq:
35
+ # classpath_variables { :VAR => '/path/to/location' }
36
+ # Sets classpath variables to be used for library path substitution
37
+ # on the project.
38
+ #
39
+ def classpath_variables(*values)
40
+ fail "eclipse.classpath_variables expects a single hash argument" if values.size > 1
41
+ if values.size == 1
42
+ fail "eclipse.classpath_variables expects a Hash argument" unless values[0].is_a? Hash
43
+ # convert keys to strings
44
+ values = values[0].inject({}) { |h, (k,v)| h[k.to_s] = @project.path_to(v); h }
45
+ @variables = values.merge(@variables || {})
46
+ end
47
+ @variables || (@project.parent ? @project.parent.eclipse.classpath_variables : default_classpath_variables)
48
+ end
49
+
50
+ def default_classpath_variables
51
+ vars = {}
52
+ vars[:SCALA_HOME] = ENV['SCALA_HOME'] if ENV['SCALA_HOME']
53
+ vars[:JAVA_HOME] = ENV['JAVA_HOME'] if ENV['JAVA_HOME']
54
+ vars
55
+ end
56
+
34
57
  # :call-seq:
35
58
  # natures=(natures)
36
59
  # Sets the Eclipse project natures on the project.
@@ -49,7 +72,7 @@ module Buildr
49
72
  def natures(*values)
50
73
  if values.size > 0
51
74
  @natures ||= []
52
- @natures += values
75
+ @natures += values.flatten
53
76
  else
54
77
  @natures || (@project.parent ? @project.parent.eclipse.natures : [])
55
78
  end
@@ -74,12 +97,32 @@ module Buildr
74
97
  def classpath_containers(*values)
75
98
  if values.size > 0
76
99
  @classpath_containers ||= []
77
- @classpath_containers += values
100
+ @classpath_containers += values.flatten
78
101
  else
79
102
  @classpath_containers || (@project.parent ? @project.parent.eclipse.classpath_containers : [])
80
103
  end
81
104
  end
82
105
 
106
+ # :call-seq:
107
+ # exclude_libs() => [lib1, lib2]
108
+ # Returns the an array of libraries to be excluded from the generated Eclipse classpath
109
+ def exclude_libs(*values)
110
+ if values.size > 0
111
+ @exclude_libs ||= []
112
+ @exclude_libs += values.flatten
113
+ else
114
+ @exclude_libs || (@project.parent ? @project.parent.eclipse.exclude_libs : [])
115
+ end
116
+ end
117
+
118
+ # :call-seq:
119
+ # exclude_libs=(lib1, lib2)
120
+ # Sets libraries to be excluded from the generated Eclipse classpath
121
+ #
122
+ def exclude_libs=(libs)
123
+ @exclude_libs = arrayfy(libs)
124
+ end
125
+
83
126
  # :call-seq:
84
127
  # builders=(builders)
85
128
  # Sets the Eclipse project builders on the project.
@@ -98,7 +141,7 @@ module Buildr
98
141
  def builders(*values)
99
142
  if values.size > 0
100
143
  @builders ||= []
101
- @builders += values
144
+ @builders += values.flatten
102
145
  else
103
146
  @builders || (@project.parent ? @project.parent.eclipse.builders : [])
104
147
  end
@@ -147,80 +190,99 @@ module Buildr
147
190
  project.recursive_task('eclipse')
148
191
  end
149
192
 
150
- after_define do |project|
151
- eclipse = project.task('eclipse')
152
-
153
- eclipse.enhance [ file(project.path_to('.classpath')), file(project.path_to('.project')) ]
154
-
155
- # The only thing we need to look for is a change in the Buildfile.
156
- file(project.path_to('.classpath')=>Buildr.application.buildfile) do |task|
157
- if (project.eclipse.natures.reject { |x| x.is_a?(Symbol) }.size > 0)
158
- info "Writing #{task.name}"
159
-
160
- m2repo = Buildr::Repositories.instance.local
161
-
162
- File.open(task.name, 'w') do |file|
163
- classpathentry = ClasspathEntryWriter.new project, file
164
- classpathentry.write do
165
- # Note: Use the test classpath since Eclipse compiles both "main" and "test" classes using the same classpath
166
- cp = project.test.compile.dependencies.map(&:to_s) - [ project.compile.target.to_s, project.resources.target.to_s ]
167
- cp = cp.uniq
193
+ after_define(:eclipse => :package) do |project|
194
+ # Need to enhance because using project.projects during load phase of the
195
+ # buildfile has harmful side-effects on project definition order
196
+ project.enhance do
197
+ eclipse = project.task('eclipse')
198
+ # We don't create the .project and .classpath files if the project contains projects.
199
+ if project.projects.empty?
200
+
201
+ eclipse.enhance [ file(project.path_to('.classpath')), file(project.path_to('.project')) ]
202
+
203
+ # The only thing we need to look for is a change in the Buildfile.
204
+ file(project.path_to('.classpath')=>Buildr.application.buildfile) do |task|
205
+ if (project.eclipse.natures.reject { |x| x.is_a?(Symbol) }.size > 0)
206
+ info "Writing #{task.name}"
207
+
208
+ m2repo = Buildr::Repositories.instance.local
209
+
210
+ File.open(task.name, 'w') do |file|
211
+ classpathentry = ClasspathEntryWriter.new project, file
212
+ classpathentry.write do
213
+ # Note: Use the test classpath since Eclipse compiles both "main" and "test" classes using the same classpath
214
+ cp = project.test.compile.dependencies.map(&:to_s) - [ project.compile.target.to_s, project.resources.target.to_s ]
215
+ cp = cp.uniq
216
+
217
+ # Convert classpath elements into applicable Project objects
218
+ cp.collect! { |path| Buildr.projects.detect { |prj| prj.packages.detect { |pkg| pkg.to_s == path } } || path }
219
+
220
+ # Remove excluded libs
221
+ cp -= project.eclipse.exclude_libs.map(&:to_s)
222
+
223
+ # project_libs: artifacts created by other projects
224
+ project_libs, others = cp.partition { |path| path.is_a?(Project) }
225
+
226
+ # Separate artifacts under known classpath variable paths
227
+ # including artifacts located in local Maven2 repository
228
+ vars = []
229
+ project.eclipse.classpath_variables.merge(project.eclipse.options.m2_repo_var => m2repo).each do |name, path|
230
+ matching, others = others.partition { |f| File.expand_path(f.to_s).index(path) == 0 }
231
+ matching.each do |m|
232
+ vars << [m, name, path]
233
+ end
234
+ end
168
235
 
169
- # Convert classpath elements into applicable Project objects
170
- cp.collect! { |path| Buildr.projects.detect { |prj| prj.packages.detect { |pkg| pkg.to_s == path } } || path }
236
+ # Generated: Any non-file classpath elements in the project are assumed to be generated
237
+ libs, generated = others.partition { |path| File.file?(path.to_s) }
171
238
 
172
- # project_libs: artifacts created by other projects
173
- project_libs, others = cp.partition { |path| path.is_a?(Project) }
239
+ classpathentry.src project.compile.sources + generated
240
+ classpathentry.src project.resources
174
241
 
175
- # Separate artifacts from Maven2 repository
176
- m2_libs, others = others.partition { |path| path.to_s.index(m2repo) == 0 }
242
+ if project.test.compile.target
243
+ classpathentry.src project.test.compile
244
+ classpathentry.src project.test.resources
245
+ end
177
246
 
178
- # Generated: Any non-file classpath elements in the project are assumed to be generated
179
- libs, generated = others.partition { |path| File.file?(path.to_s) }
247
+ # Classpath elements from other projects
248
+ classpathentry.src_projects project_libs
180
249
 
181
- classpathentry.src project.compile.sources + generated
182
- classpathentry.src project.resources
250
+ classpathentry.output project.compile.target if project.compile.target
251
+ classpathentry.lib libs
252
+ classpathentry.var vars
183
253
 
184
- if project.test.compile.target
185
- classpathentry.src project.test.compile
186
- classpathentry.src project.test.resources
254
+ project.eclipse.classpath_containers.each { |container|
255
+ classpathentry.con container
256
+ }
257
+ end
187
258
  end
188
-
189
- # Classpath elements from other projects
190
- classpathentry.src_projects project_libs
191
-
192
- classpathentry.output project.compile.target if project.compile.target
193
- classpathentry.lib libs
194
- classpathentry.var m2_libs, project.eclipse.options.m2_repo_var, m2repo
195
-
196
- project.eclipse.classpath_containers.each { |container|
197
- classpathentry.con container
198
- }
199
259
  end
200
260
  end
201
- end
202
- end
203
261
 
204
- # The only thing we need to look for is a change in the Buildfile.
205
- file(project.path_to('.project')=>Buildr.application.buildfile) do |task|
206
- if (project.eclipse.natures.reject { |x| x.is_a?(Symbol) }.size > 0)
207
- info "Writing #{task.name}"
208
- File.open(task.name, 'w') do |file|
209
- xml = Builder::XmlMarkup.new(:target=>file, :indent=>2)
210
- xml.projectDescription do
211
- xml.name project.id
212
- xml.projects
213
- xml.buildSpec do
214
- project.eclipse.builders.each { |builder|
215
- xml.buildCommand do
216
- xml.name builder
262
+ # The only thing we need to look for is a change in the Buildfile.
263
+ file(project.path_to('.project')=>Buildr.application.buildfile) do |task|
264
+ info "Writing #{task.name}"
265
+ File.open(task.name, 'w') do |file|
266
+ xml = Builder::XmlMarkup.new(:target=>file, :indent=>2)
267
+ xml.projectDescription do
268
+ xml.name project.id
269
+ xml.projects
270
+ unless project.eclipse.builders.empty?
271
+ xml.buildSpec do
272
+ project.eclipse.builders.each { |builder|
273
+ xml.buildCommand do
274
+ xml.name builder
275
+ end
276
+ }
217
277
  end
218
- }
219
- end
220
- xml.natures do
221
- project.eclipse.natures.each { |nature|
222
- xml.nature nature unless nature.is_a? Symbol
223
- }
278
+ end
279
+ unless project.eclipse.natures.empty?
280
+ xml.natures do
281
+ project.eclipse.natures.each { |nature|
282
+ xml.nature nature unless nature.is_a? Symbol
283
+ }
284
+ end
285
+ end
224
286
  end
225
287
  end
226
288
  end
@@ -251,7 +313,7 @@ module Buildr
251
313
 
252
314
  def lib libs
253
315
  libs.map(&:to_s).sort.uniq.each do |path|
254
- @xml.classpathentry :kind=>'lib', :path=>path
316
+ @xml.classpathentry :kind=>'lib', :path=>relative(path)
255
317
  end
256
318
  end
257
319
 
@@ -282,24 +344,35 @@ module Buildr
282
344
  # * +var_name+ is a variable name as defined in Eclipse (e.g., 'M2_REPO').
283
345
  # * +var_value+ is the value of this variable (e.g., '/home/me/.m2').
284
346
  # E.g., <tt>var([lib1, lib2], 'M2_REPO', '/home/me/.m2/repo')</tt>
285
- def var libs, var_name, var_value
286
- libs.each do |lib_path|
347
+ def var(libs)
348
+ libs.each do |lib_path, var_name, var_value|
287
349
  lib_artifact = file(lib_path)
288
- source_path = lib_artifact.sources_artifact.to_s
289
- relative_lib_path = lib_path.sub(var_value, var_name)
290
- relative_source_path = source_path.sub(var_value, var_name)
291
- @xml.classpathentry :kind=>'var', :path=>relative_lib_path, :sourcepath=>relative_source_path
350
+ relative_lib_path = lib_path.sub(var_value, var_name.to_s)
351
+ if lib_artifact.respond_to? :sources_artifact
352
+ source_path = lib_artifact.sources_artifact.to_s
353
+ relative_source_path = source_path.sub(var_value, var_name)
354
+ @xml.classpathentry :kind=>'var', :path=>relative_lib_path, :sourcepath=>relative_source_path
355
+ else
356
+ @xml.classpathentry :kind=>'var', :path=>relative_lib_path
357
+ end
292
358
  end
293
359
  end
294
360
 
295
361
  private
296
362
 
297
- # Find a path relative to the project's root directory.
363
+ # Find a path relative to the project's root directory if possible. If the
364
+ # two paths do not share the same root the absolute path is returned. This
365
+ # can happen on Windows, for instance, when the two paths are not on the
366
+ # same drive.
298
367
  def relative path
299
368
  path or raise "Invalid path '#{path.inspect}'"
300
369
  msg = [:to_path, :to_str, :to_s].find { |msg| path.respond_to? msg }
301
370
  path = path.__send__(msg)
302
- Util.relative_path(File.expand_path(path), @project.path_to)
371
+ begin
372
+ Util.relative_path(File.expand_path(path), @project.path_to)
373
+ rescue ArgumentError
374
+ File.expand_path(path)
375
+ end
303
376
  end
304
377
 
305
378
  def src_from_task task
@@ -30,11 +30,11 @@ module Buildr
30
30
  Project.local_task "idea"=>"artifacts"
31
31
  end
32
32
 
33
- before_define do |project|
33
+ before_define(:idea) do |project|
34
34
  project.recursive_task("idea")
35
35
  end
36
36
 
37
- after_define do |project|
37
+ after_define(:idea => :package) do |project|
38
38
  idea = project.task("idea")
39
39
  # We need paths relative to the top project's base directory.
40
40
  root_path = lambda { |p| f = lambda { |p| p.parent ? f[p.parent] : p.base_dir }; f[p] }[project]
@@ -37,13 +37,17 @@ module Buildr
37
37
  # Global task "idea" generates artifacts for all projects.
38
38
  desc "Generate Idea 7.x artifacts for all projects"
39
39
  Project.local_task "idea7x"=>"artifacts"
40
+
41
+ desc "Delete the generated Idea 7.x artifacts for all projects"
42
+ Project.local_task "idea7x:clean"
40
43
  end
41
44
 
42
- before_define do |project|
45
+ before_define(:idea7x) do |project|
43
46
  project.recursive_task("idea7x")
47
+ project.recursive_task("idea7x:clean")
44
48
  end
45
49
 
46
- after_define do |project|
50
+ after_define(:idea7x => :package) do |project|
47
51
  idea7x = project.task("idea7x")
48
52
 
49
53
  # We need paths relative to the top project's base directory.
@@ -90,7 +94,7 @@ module Buildr
90
94
  ext_libs = m2_libs.map { |path| "jar://#{path.to_s.sub(m2repo, "$M2_REPO$")}!/" }
91
95
  ext_libs << "#{MODULE_DIR_URL}/#{relative[project.test.resources.target.to_s]}" if project.test.resources.target
92
96
  ext_libs << "#{MODULE_DIR_URL}/#{relative[project.resources.target.to_s]}" if project.resources.target
93
-
97
+
94
98
  Buildr::Idea7x.generate_module_libs(xml, ext_libs)
95
99
  xml.orderEntryProperties
96
100
  end
@@ -99,11 +103,18 @@ module Buildr
99
103
  end
100
104
  end
101
105
 
106
+ # Add task to remove generated module
107
+ project.task("idea7x:clean") do
108
+ if File.exist?(task_name)
109
+ info "Removing #{task_name}"
110
+ rm_rf task_name
111
+ end
112
+ end
113
+
102
114
  # Root project aggregates all the subprojects.
103
115
  if project.parent == nil
104
116
  Buildr::Idea7x.generate_ipr(project, idea7x, Buildr.application.buildfile)
105
117
  end
106
-
107
118
  end # after_define
108
119
 
109
120
  class << self
@@ -200,6 +211,14 @@ module Buildr
200
211
  template_xml.write file
201
212
  end
202
213
  end
214
+
215
+ # Add task to remove generated project file
216
+ project.task("idea7x:clean") do
217
+ if File.exist?(task_name)
218
+ info "Removing #{task_name}"
219
+ rm_rf task_name
220
+ end
221
+ end
203
222
  end
204
223
 
205
224
  end
@@ -25,8 +25,8 @@ module Buildr
25
25
  module Ant
26
26
 
27
27
  # Which version of Ant we're using by default.
28
- VERSION = '1.7.1'
29
-
28
+ VERSION = '1.8.0'
29
+
30
30
  class << self
31
31
  # Current version of Ant being used.
32
32
  def version
@@ -40,14 +40,14 @@ module Buildr
40
40
  @dependencies ||= ["org.apache.ant:ant:jar:#{version}", "org.apache.ant:ant-launcher:jar:#{version}",
41
41
  "org.apache.ant:ant-trax:jar:#{version}"]
42
42
  end
43
-
43
+
44
44
  private
45
45
  def const_missing(const)
46
46
  return super unless const == :REQUIRES # TODO: remove in 1.5
47
47
  Buildr.application.deprecated "Please use Ant.dependencies/.version instead of Ant::REQUIRES/VERSION"
48
48
  dependencies
49
49
  end
50
- end
50
+ end
51
51
 
52
52
 
53
53
  Java.classpath << lambda { Ant.dependencies }