buildr 1.3.5-x86-mswin32

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 (186) hide show
  1. data/CHANGELOG +998 -0
  2. data/LICENSE +176 -0
  3. data/NOTICE +26 -0
  4. data/README.rdoc +134 -0
  5. data/Rakefile +45 -0
  6. data/_buildr +29 -0
  7. data/_jbuildr +29 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/cobertura.rb +22 -0
  10. data/addon/buildr/drb.rb +281 -0
  11. data/addon/buildr/emma.rb +22 -0
  12. data/addon/buildr/hibernate.rb +142 -0
  13. data/addon/buildr/javacc.rb +85 -0
  14. data/addon/buildr/jdepend.rb +60 -0
  15. data/addon/buildr/jetty.rb +248 -0
  16. data/addon/buildr/jibx.rb +86 -0
  17. data/addon/buildr/nailgun.rb +221 -0
  18. data/addon/buildr/openjpa.rb +90 -0
  19. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  20. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  21. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  22. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  23. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  25. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  26. data/addon/buildr/xmlbeans.rb +93 -0
  27. data/bin/buildr +19 -0
  28. data/buildr.buildfile +58 -0
  29. data/buildr.gemspec +65 -0
  30. data/doc/_config.yml +1 -0
  31. data/doc/_layouts/default.html +88 -0
  32. data/doc/_layouts/preface.html +22 -0
  33. data/doc/artifacts.textile +211 -0
  34. data/doc/building.textile +244 -0
  35. data/doc/contributing.textile +252 -0
  36. data/doc/css/default.css +236 -0
  37. data/doc/css/print.css +101 -0
  38. data/doc/css/syntax.css +23 -0
  39. data/doc/download.textile +79 -0
  40. data/doc/extending.textile +186 -0
  41. data/doc/images/1442160941-frontcover.jpg +0 -0
  42. data/doc/images/asf-logo.gif +0 -0
  43. data/doc/images/asf-logo.png +0 -0
  44. data/doc/images/buildr-hires.png +0 -0
  45. data/doc/images/buildr.png +0 -0
  46. data/doc/images/favicon.png +0 -0
  47. data/doc/images/growl-icon.tiff +0 -0
  48. data/doc/images/note.png +0 -0
  49. data/doc/images/project-structure.png +0 -0
  50. data/doc/images/tip.png +0 -0
  51. data/doc/images/zbuildr.png +0 -0
  52. data/doc/images/zbuildr.tif +0 -0
  53. data/doc/index.textile +69 -0
  54. data/doc/installing.textile +266 -0
  55. data/doc/languages.textile +459 -0
  56. data/doc/mailing_lists.textile +25 -0
  57. data/doc/more_stuff.textile +457 -0
  58. data/doc/packaging.textile +430 -0
  59. data/doc/preface.textile +54 -0
  60. data/doc/projects.textile +271 -0
  61. data/doc/quick_start.textile +210 -0
  62. data/doc/scripts/buildr-git.rb +512 -0
  63. data/doc/scripts/gitflow.rb +296 -0
  64. data/doc/scripts/install-jruby.sh +44 -0
  65. data/doc/scripts/install-linux.sh +72 -0
  66. data/doc/scripts/install-osx.sh +52 -0
  67. data/doc/settings_profiles.textile +280 -0
  68. data/doc/testing.textile +222 -0
  69. data/etc/KEYS +151 -0
  70. data/lib/buildr.rb +36 -0
  71. data/lib/buildr/core.rb +35 -0
  72. data/lib/buildr/core/application.rb +656 -0
  73. data/lib/buildr/core/build.rb +452 -0
  74. data/lib/buildr/core/checks.rb +254 -0
  75. data/lib/buildr/core/common.rb +150 -0
  76. data/lib/buildr/core/compile.rb +608 -0
  77. data/lib/buildr/core/environment.rb +129 -0
  78. data/lib/buildr/core/filter.rb +362 -0
  79. data/lib/buildr/core/generate.rb +195 -0
  80. data/lib/buildr/core/help.rb +119 -0
  81. data/lib/buildr/core/osx.rb +46 -0
  82. data/lib/buildr/core/progressbar.rb +156 -0
  83. data/lib/buildr/core/project.rb +866 -0
  84. data/lib/buildr/core/shell.rb +198 -0
  85. data/lib/buildr/core/test.rb +723 -0
  86. data/lib/buildr/core/transports.rb +559 -0
  87. data/lib/buildr/core/util.rb +449 -0
  88. data/lib/buildr/groovy.rb +19 -0
  89. data/lib/buildr/groovy/bdd.rb +106 -0
  90. data/lib/buildr/groovy/compiler.rb +138 -0
  91. data/lib/buildr/groovy/shell.rb +48 -0
  92. data/lib/buildr/ide.rb +19 -0
  93. data/lib/buildr/ide/eclipse.rb +334 -0
  94. data/lib/buildr/ide/eclipse/java.rb +53 -0
  95. data/lib/buildr/ide/eclipse/plugin.rb +68 -0
  96. data/lib/buildr/ide/eclipse/scala.rb +66 -0
  97. data/lib/buildr/ide/idea.ipr.template +300 -0
  98. data/lib/buildr/ide/idea.rb +190 -0
  99. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  100. data/lib/buildr/ide/idea7x.rb +212 -0
  101. data/lib/buildr/java.rb +23 -0
  102. data/lib/buildr/java/ant.rb +94 -0
  103. data/lib/buildr/java/bdd.rb +459 -0
  104. data/lib/buildr/java/cobertura.rb +274 -0
  105. data/lib/buildr/java/commands.rb +213 -0
  106. data/lib/buildr/java/compiler.rb +349 -0
  107. data/lib/buildr/java/deprecated.rb +141 -0
  108. data/lib/buildr/java/emma.rb +244 -0
  109. data/lib/buildr/java/jruby.rb +117 -0
  110. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  111. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  112. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +137 -0
  113. data/lib/buildr/java/packaging.rb +716 -0
  114. data/lib/buildr/java/pom.rb +174 -0
  115. data/lib/buildr/java/rjb.rb +155 -0
  116. data/lib/buildr/java/test_result.rb +353 -0
  117. data/lib/buildr/java/tests.rb +333 -0
  118. data/lib/buildr/java/version_requirement.rb +172 -0
  119. data/lib/buildr/packaging.rb +24 -0
  120. data/lib/buildr/packaging/archive.rb +488 -0
  121. data/lib/buildr/packaging/artifact.rb +749 -0
  122. data/lib/buildr/packaging/artifact_namespace.rb +972 -0
  123. data/lib/buildr/packaging/artifact_search.rb +140 -0
  124. data/lib/buildr/packaging/gems.rb +102 -0
  125. data/lib/buildr/packaging/package.rb +238 -0
  126. data/lib/buildr/packaging/tar.rb +186 -0
  127. data/lib/buildr/packaging/version_requirement.rb +172 -0
  128. data/lib/buildr/packaging/zip.rb +73 -0
  129. data/lib/buildr/packaging/ziptask.rb +316 -0
  130. data/lib/buildr/resources/buildr.icns +0 -0
  131. data/lib/buildr/scala.rb +25 -0
  132. data/lib/buildr/scala/bdd.rb +109 -0
  133. data/lib/buildr/scala/compiler.rb +195 -0
  134. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  135. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  136. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
  137. data/lib/buildr/scala/shell.rb +55 -0
  138. data/lib/buildr/scala/tests.rb +157 -0
  139. data/lib/buildr/shell.rb +180 -0
  140. data/rakelib/checks.rake +57 -0
  141. data/rakelib/doc.rake +92 -0
  142. data/rakelib/jekylltask.rb +120 -0
  143. data/rakelib/package.rake +73 -0
  144. data/rakelib/release.rake +149 -0
  145. data/rakelib/rspec.rake +73 -0
  146. data/rakelib/setup.rake +54 -0
  147. data/rakelib/stage.rake +213 -0
  148. data/rakelib/stage.rake~ +213 -0
  149. data/spec/addon/drb_spec.rb +328 -0
  150. data/spec/core/application_spec.rb +502 -0
  151. data/spec/core/build_spec.rb +677 -0
  152. data/spec/core/checks_spec.rb +519 -0
  153. data/spec/core/common_spec.rb +670 -0
  154. data/spec/core/compile_spec.rb +583 -0
  155. data/spec/core/extension_spec.rb +93 -0
  156. data/spec/core/generate_spec.rb +33 -0
  157. data/spec/core/project_spec.rb +762 -0
  158. data/spec/core/test_spec.rb +1098 -0
  159. data/spec/core/transport_spec.rb +537 -0
  160. data/spec/core/util_spec.rb +67 -0
  161. data/spec/groovy/bdd_spec.rb +80 -0
  162. data/spec/groovy/compiler_spec.rb +240 -0
  163. data/spec/ide/eclipse_spec.rb +501 -0
  164. data/spec/ide/idea7x_spec.rb +84 -0
  165. data/spec/java/ant_spec.rb +33 -0
  166. data/spec/java/bdd_spec.rb +382 -0
  167. data/spec/java/cobertura_spec.rb +85 -0
  168. data/spec/java/compiler_spec.rb +446 -0
  169. data/spec/java/emma_spec.rb +119 -0
  170. data/spec/java/java_spec.rb +124 -0
  171. data/spec/java/packaging_spec.rb +1134 -0
  172. data/spec/java/test_coverage_helper.rb +257 -0
  173. data/spec/java/tests_spec.rb +493 -0
  174. data/spec/packaging/archive_spec.rb +527 -0
  175. data/spec/packaging/artifact_namespace_spec.rb +654 -0
  176. data/spec/packaging/artifact_spec.rb +795 -0
  177. data/spec/packaging/packaging_helper.rb +63 -0
  178. data/spec/packaging/packaging_spec.rb +684 -0
  179. data/spec/sandbox.rb +142 -0
  180. data/spec/scala/bdd_spec.rb +119 -0
  181. data/spec/scala/compiler_spec.rb +284 -0
  182. data/spec/scala/scala.rb +38 -0
  183. data/spec/scala/tests_spec.rb +261 -0
  184. data/spec/spec_helpers.rb +340 -0
  185. data/spec/version_requirement_spec.rb +129 -0
  186. metadata +383 -0
@@ -0,0 +1,106 @@
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
+ module Buildr::Groovy
18
+
19
+ # EasyB is a Groovy based BDD framework.
20
+ # To use in your project:
21
+ #
22
+ # test.using :easyb
23
+ #
24
+ # This framework will search in your project for:
25
+ # src/spec/groovy/**/*Story.groovy
26
+ # src/spec/groovy/**/*Specification.groovy
27
+ #
28
+ # Support the following options:
29
+ # * :format -- Report format :txt or :xml, default is :txt
30
+ # * :properties -- Hash of properties passed to the test suite.
31
+ # * :java_args -- Arguments passed to the JVM.
32
+ class EasyB < TestFramework::JavaBDD
33
+ @lang = :groovy
34
+ @bdd_dir = :spec
35
+
36
+ VERSION = "0.9"
37
+ TESTS_PATTERN = [ /(Story|Specification).groovy$/ ]
38
+ OPTIONS = [:format, :properties, :java_args]
39
+
40
+ class << self
41
+ def version
42
+ Buildr.settings.build['jbehave'] || VERSION
43
+ end
44
+
45
+ def dependencies
46
+ @dependencies ||= ["org.easyb:easyb:jar:#{version}",
47
+ 'org.codehaus.groovy:groovy:jar:1.5.3','asm:asm:jar:2.2.3',
48
+ 'commons-cli:commons-cli:jar:1.0','antlr:antlr:jar:2.7.7']
49
+ end
50
+
51
+ def applies_to?(project) #:nodoc:
52
+ %w{
53
+ **/*Specification.groovy **/*Story.groovy
54
+ }.any? { |glob| !Dir[project.path_to(:source, bdd_dir, lang, glob)].empty? }
55
+ end
56
+
57
+ private
58
+ def const_missing(const)
59
+ return super unless const == :REQUIRES # TODO: remove in 1.5
60
+ Buildr.application.deprecated "Please use JBehave.dependencies/.version instead of JBehave::REQUIRES/VERSION"
61
+ dependencies
62
+ end
63
+ end
64
+
65
+ def tests(dependencies) #:nodoc:
66
+ Dir[task.project.path_to(:source, bdd_dir, lang, "**/*.groovy")].
67
+ select { |name| TESTS_PATTERN.any? { |pat| pat === name } }
68
+ end
69
+
70
+ def run(tests, dependencies) #:nodoc:
71
+ options = { :format => :txt }.merge(self.options).only(*OPTIONS)
72
+
73
+ if :txt == options[:format]
74
+ easyb_format, ext = 'txtstory', '.txt'
75
+ elsif :xml == options[:format]
76
+ easyb_format, ext = 'xmlbehavior', '.xml'
77
+ else
78
+ raise "Invalid format #{options[:format]} expected one of :txt :xml"
79
+ end
80
+
81
+ cmd_args = [ 'org.disco.easyb.BehaviorRunner' ]
82
+ cmd_options = { :properties => options[:properties],
83
+ :java_args => options[:java_args],
84
+ :classpath => dependencies }
85
+
86
+ tests.inject([]) do |passed, test|
87
+ name = test.sub(/.*?groovy[\/\\]/, '').pathmap('%X')
88
+ report = File.join(task.report_to.to_s, name + ext)
89
+ mkpath report.pathmap('%d')
90
+ begin
91
+ Java::Commands.java cmd_args,
92
+ "-#{easyb_format}", report,
93
+ test, cmd_options.merge(:name => name)
94
+ rescue => e
95
+ passed
96
+ else
97
+ passed << test
98
+ end
99
+ end
100
+ end
101
+
102
+ end # EasyB
103
+
104
+ end
105
+
106
+ Buildr::TestFramework << Buildr::Groovy::EasyB
@@ -0,0 +1,138 @@
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
+ module Buildr::Groovy
18
+
19
+ # Groovyc compiler:
20
+ # compile.using(:groovyc)
21
+ #
22
+ # You need to require 'buildr/groovy/compiler' if you need to use this compiler.
23
+ #
24
+ # Used by default if .groovy files are found in the src/main/groovy directory (or src/test/groovy)
25
+ # and sets the target directory to target/classes (or target/test/classes).
26
+ #
27
+ # Groovyc is a joint compiler, this means that when selected for a project, this compiler is used
28
+ # to compile both groovy and java sources. It's recommended that Groovy sources are placed in the
29
+ # src/main/groovy directory, even though this compiler also looks in src/main/java
30
+ #
31
+ # Groovyc accepts the following options:
32
+ #
33
+ # * :encoding -- Encoding of source files
34
+ # * :verbose -- Asks the compiler for verbose output, true when running in verbose mode.
35
+ # * :fork -- Whether to execute groovyc using a spawned instance of the JVM; defaults to no
36
+ # * :memoryInitialSize -- The initial size of the memory for the underlying VM, if using fork mode; ignored otherwise.
37
+ # Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
38
+ # * :memoryMaximumSize -- The maximum size of the memory for the underlying VM, if using fork mode; ignored otherwise.
39
+ # Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
40
+ # * :listfiles -- Indicates whether the source files to be compiled will be listed; defaults to no
41
+ # * :stacktrace -- If true each compile error message will contain a stacktrace
42
+ # * :warnings -- Issue warnings when compiling. True when running in verbose mode.
43
+ # * :debug -- Generates bytecode with debugging information. Set from the debug
44
+ # environment variable/global option.
45
+ # * :deprecation -- If true, shows deprecation messages. False by default.
46
+ # * :optimise -- Generates faster bytecode by applying optimisations to the program.
47
+ # * :source -- Source code compatibility.
48
+ # * :target -- Bytecode compatibility.
49
+ # * :javac -- Hash of options passed to the ant javac task
50
+ #
51
+ class Groovyc < Compiler::Base
52
+
53
+ # The groovyc compiler jars are added to classpath at load time,
54
+ # if you want to customize artifact versions, you must set them on the
55
+ #
56
+ # artifact_ns['Buildr::Compiler::Groovyc'].groovy = '1.5.4'
57
+ #
58
+ # namespace before this file is required.
59
+ REQUIRES = ArtifactNamespace.for(self) do |ns|
60
+ ns.groovy! 'org.codehaus.groovy:groovy:jar:>=1.5.3'
61
+ ns.commons_cli! 'commons-cli:commons-cli:jar:>=1.0'
62
+ ns.asm! 'asm:asm:jar:>=2.2'
63
+ ns.antlr! 'antlr:antlr:jar:>=2.7.7'
64
+ end
65
+
66
+ ANT_TASK = 'org.codehaus.groovy.ant.Groovyc'
67
+ GROOVYC_OPTIONS = [:encoding, :verbose, :fork, :memoryInitialSize, :memoryMaximumSize, :listfiles, :stacktrace]
68
+ JAVAC_OPTIONS = [:optimise, :warnings, :debug, :deprecation, :source, :target, :javac]
69
+ OPTIONS = GROOVYC_OPTIONS + JAVAC_OPTIONS
70
+
71
+ class << self
72
+ def dependencies #:nodoc:
73
+ REQUIRES.artifacts
74
+ end
75
+
76
+ def applies_to?(project, task) #:nodoc:
77
+ paths = task.sources + [sources].flatten.map { |src| Array(project.path_to(:source, task.usage, src.to_sym)) }
78
+ paths.flatten!
79
+ # Just select if we find .groovy files
80
+ paths.any? { |path| !Dir["#{path}/**/*.groovy"].empty? }
81
+ end
82
+ end
83
+
84
+ Java.classpath << dependencies
85
+
86
+ specify :language => :groovy, :sources => [:groovy, :java], :source_ext => [:groovy, :java],
87
+ :target => 'classes', :target_ext => 'class', :packaging => :jar
88
+
89
+ def initialize(project, options) #:nodoc:
90
+ super
91
+ options[:debug] = Buildr.options.debug if options[:debug].nil?
92
+ options[:deprecation] ||= false
93
+ options[:optimise] ||= false
94
+ options[:verbose] ||= Buildr.application.options.trace if options[:verbose].nil?
95
+ options[:warnings] = verbose if options[:warnings].nil?
96
+ options[:javac] = OpenObject.new if options[:javac].nil?
97
+ end
98
+
99
+ # http://groovy.codehaus.org/The+groovyc+Ant+Task
100
+ def compile(sources, target, dependencies) #:nodoc:
101
+ return if Buildr.application.options.dryrun
102
+ Buildr.ant 'groovyc' do |ant|
103
+ classpath = dependencies | self.class.dependencies.map(&:to_s)
104
+ ant.taskdef :name => 'groovyc', :classname => ANT_TASK, :classpath => classpath.join(File::PATH_SEPARATOR)
105
+ ant.groovyc groovyc_options(sources, target) do
106
+ sources.each { |src| ant.src :path => src }
107
+ ant.classpath do
108
+ classpath.each { |dep| ant.pathelement :path => dep }
109
+ end
110
+ ant.javac(javac_options)
111
+ end
112
+ end
113
+ end
114
+
115
+ private
116
+ def groovyc_options(sources, target)
117
+ check_options options, OPTIONS
118
+ groovyc_options = options.to_hash.only(*GROOVYC_OPTIONS)
119
+ groovyc_options[:destdir] = File.expand_path(target)
120
+ groovyc_options
121
+ end
122
+
123
+ def javac_options
124
+ check_options options, OPTIONS
125
+ javac_options = options.to_hash.only(*JAVAC_OPTIONS)
126
+ javac_options[:optimize] = (javac_options.delete(:optimise) || false)
127
+ javac_options[:nowarn] = (javac_options.delete(:warnings) || verbose).to_s !~ /^(true|yes|on)$/i
128
+ other = javac_options.delete(:javac) || {}
129
+ javac_options.merge!(other)
130
+ javac_options
131
+ end
132
+
133
+ end
134
+ end
135
+
136
+ # Groovy compiler comes first, ahead of Javac, this allows it to pick
137
+ # projects that mix Groovy and Java code by spotting Groovy code first.
138
+ Buildr::Compiler.compilers.unshift Buildr::Groovy::Groovyc
@@ -0,0 +1,48 @@
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
+ require 'buildr/shell'
17
+
18
+ module Buildr
19
+ module Groovy
20
+ class GroovySH < Buildr::Shell::Base
21
+ SUFFIX = if Util.win_os? then '.bat' else '' end
22
+
23
+ class << self
24
+ def lang
25
+ :groovy
26
+ end
27
+ end
28
+
29
+ def launch
30
+ fail 'Are we forgetting something? GROOVY_HOME not set.' unless groovy_home
31
+
32
+ cp = project.compile.dependencies.join(File::PATH_SEPARATOR) +
33
+ File::PATH_SEPARATOR + project.path_to(:target, :classes)
34
+
35
+ cmd_args = " -classpath '#{cp}'"
36
+ trace "groovysh #{cmd_args}"
37
+ system(File.expand_path("bin#{File::SEPARATOR}groovysh#{SUFFIX}", groovy_home) + cmd_args)
38
+ end
39
+
40
+ private
41
+ def groovy_home
42
+ @home ||= ENV['GROOVY_HOME']
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ Buildr::ShellProviders << Buildr::Groovy::GroovySH
data/lib/buildr/ide.rb ADDED
@@ -0,0 +1,19 @@
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/ide/eclipse'
18
+ require 'buildr/ide/idea'
19
+ require 'buildr/ide/idea7x'
@@ -0,0 +1,334 @@
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/core/project'
18
+ require 'buildr/packaging'
19
+
20
+
21
+ module Buildr
22
+ module Eclipse #:nodoc:
23
+ include Extension
24
+
25
+ class Eclipse
26
+
27
+ attr_reader :options
28
+
29
+ def initialize(project)
30
+ @project = project
31
+ @options = Options.new(project)
32
+ end
33
+
34
+ # :call-seq:
35
+ # natures=(natures)
36
+ # Sets the Eclipse project natures on the project.
37
+ #
38
+ def natures=(var)
39
+ @natures = arrayfy(var)
40
+ end
41
+
42
+ # :call-seq:
43
+ # natures() => [n1, n2]
44
+ # Returns the Eclipse project natures on the project.
45
+ # They may be derived from the parent project if no specific natures have been set
46
+ # on the project.
47
+ #
48
+ # An Eclipse project nature is used internally by Eclipse to determine the aspects of a project.
49
+ def natures(*values)
50
+ if values.size > 0
51
+ @natures ||= []
52
+ @natures += values
53
+ else
54
+ @natures || (@project.parent ? @project.parent.eclipse.natures : [])
55
+ end
56
+ end
57
+
58
+ # :call-seq:
59
+ # classpath_containers=(cc)
60
+ # Sets the Eclipse project classpath containers on the project.
61
+ #
62
+ def classpath_containers=(var)
63
+ @classpath_containers = arrayfy(var)
64
+ end
65
+
66
+ # :call-seq:
67
+ # classpath_containers() => [con1, con2]
68
+ # Returns the Eclipse project classpath containers on the project.
69
+ # They may be derived from the parent project if no specific classpath containers have been set
70
+ # on the project.
71
+ #
72
+ # A classpath container is an Eclipse pre-determined ensemble of dependencies made available to
73
+ # the project classpath.
74
+ def classpath_containers(*values)
75
+ if values.size > 0
76
+ @classpath_containers ||= []
77
+ @classpath_containers += values
78
+ else
79
+ @classpath_containers || (@project.parent ? @project.parent.eclipse.classpath_containers : [])
80
+ end
81
+ end
82
+
83
+ # :call-seq:
84
+ # builders=(builders)
85
+ # Sets the Eclipse project builders on the project.
86
+ #
87
+ def builders=(var)
88
+ @builders = arrayfy(var)
89
+ end
90
+
91
+ # :call-seq:
92
+ # builders() => [b1, b2]
93
+ # Returns the Eclipse project builders on the project.
94
+ # They may be derived from the parent project if no specific builders have been set
95
+ # on the project.
96
+ #
97
+ # A builder is an Eclipse background job that parses the source code to produce built artifacts.
98
+ def builders(*values)
99
+ if values.size > 0
100
+ @builders ||= []
101
+ @builders += values
102
+ else
103
+ @builders || (@project.parent ? @project.parent.eclipse.builders : [])
104
+ end
105
+ end
106
+
107
+ private
108
+
109
+ def arrayfy(obj)
110
+ obj.is_a?(Array) ? obj : [obj]
111
+ end
112
+ end
113
+
114
+ class Options
115
+
116
+ attr_writer :m2_repo_var
117
+
118
+ def initialize(project)
119
+ @project = project
120
+ end
121
+
122
+ # The classpath variable used to point at the local maven2 repository.
123
+ # Example:
124
+ # eclipse.options.m2_repo_var = 'M2_REPO'
125
+ def m2_repo_var(*values)
126
+ fail "m2_repo_var can only accept one value: #{values}" if values.size > 1
127
+ if values.size > 0
128
+ @m2_repo_var = values[0]
129
+ else
130
+ @m2_repo_var || (@project.parent ? @project.parent.eclipse.options.m2_repo_var : 'M2_REPO')
131
+ end
132
+ end
133
+ end
134
+
135
+ def eclipse
136
+ @eclipse ||= Eclipse.new(self)
137
+ @eclipse
138
+ end
139
+
140
+ first_time do
141
+ # Global task "eclipse" generates artifacts for all projects.
142
+ desc 'Generate Eclipse artifacts for all projects'
143
+ Project.local_task('eclipse'=>'artifacts') { |name| "Generating Eclipse project for #{name}" }
144
+ end
145
+
146
+ before_define do |project|
147
+ project.recursive_task('eclipse')
148
+ end
149
+
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
168
+
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 }
171
+
172
+ # project_libs: artifacts created by other projects
173
+ project_libs, others = cp.partition { |path| path.is_a?(Project) }
174
+
175
+ # Separate artifacts from Maven2 repository
176
+ m2_libs, others = others.partition { |path| path.to_s.index(m2repo) == 0 }
177
+
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) }
180
+
181
+ classpathentry.src project.compile.sources + generated
182
+ classpathentry.src project.resources
183
+
184
+ if project.test.compile.target
185
+ classpathentry.src project.test.compile
186
+ classpathentry.src project.test.resources
187
+ 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
+ end
200
+ end
201
+ end
202
+ end
203
+
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
217
+ end
218
+ }
219
+ end
220
+ xml.natures do
221
+ project.eclipse.natures.each { |nature|
222
+ xml.nature nature unless nature.is_a? Symbol
223
+ }
224
+ end
225
+ end
226
+ end
227
+ end
228
+ end
229
+ end
230
+
231
+
232
+ # Writes 'classpathentry' tags in an xml file.
233
+ # It converts tasks to paths.
234
+ # It converts absolute paths to relative paths.
235
+ # It ignores duplicate directories.
236
+ class ClasspathEntryWriter #:nodoc:
237
+ def initialize project, target
238
+ @project = project
239
+ @xml = Builder::XmlMarkup.new(:target=>target, :indent=>2)
240
+ @excludes = [ '**/.svn/', '**/CVS/' ].join('|')
241
+ @paths_written = []
242
+ end
243
+
244
+ def write &block
245
+ @xml.classpath &block
246
+ end
247
+
248
+ def con path
249
+ @xml.classpathentry :kind=>'con', :path=>path
250
+ end
251
+
252
+ def lib libs
253
+ libs.map(&:to_s).sort.uniq.each do |path|
254
+ @xml.classpathentry :kind=>'lib', :path=>path
255
+ end
256
+ end
257
+
258
+ # Write a classpathentry of kind 'src'.
259
+ # Accept an array of absolute paths or a task.
260
+ def src arg
261
+ if [:sources, :target].all? { |message| arg.respond_to?(message) }
262
+ src_from_task arg
263
+ else
264
+ src_from_absolute_paths arg
265
+ end
266
+ end
267
+
268
+ # Write a classpathentry of kind 'src' for dependent projects.
269
+ # Accept an array of projects.
270
+ def src_projects project_libs
271
+ project_libs.map(&:id).sort.uniq.each do |project_id|
272
+ @xml.classpathentry :kind=>'src', :combineaccessrules=>'false', :path=>"/#{project_id}"
273
+ end
274
+ end
275
+
276
+ def output target
277
+ @xml.classpathentry :kind=>'output', :path=>relative(target)
278
+ end
279
+
280
+ # Write a classpathentry of kind 'var' (variable) for a library in a local repo.
281
+ # * +libs+ is an array of library paths.
282
+ # * +var_name+ is a variable name as defined in Eclipse (e.g., 'M2_REPO').
283
+ # * +var_value+ is the value of this variable (e.g., '/home/me/.m2').
284
+ # 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|
287
+ 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
292
+ end
293
+ end
294
+
295
+ private
296
+
297
+ # Find a path relative to the project's root directory.
298
+ def relative path
299
+ path or raise "Invalid path '#{path.inspect}'"
300
+ msg = [:to_path, :to_str, :to_s].find { |msg| path.respond_to? msg }
301
+ path = path.__send__(msg)
302
+ Util.relative_path(File.expand_path(path), @project.path_to)
303
+ end
304
+
305
+ def src_from_task task
306
+ src_from_absolute_paths task.sources, task.target
307
+ end
308
+
309
+ def src_from_absolute_paths absolute_paths, output=nil
310
+ relative_paths = absolute_paths.map { |src| relative(src) }
311
+ relative_paths.sort.uniq.each do |path|
312
+ unless @paths_written.include?(path)
313
+ attributes = { :kind=>'src', :path=>path, :excluding=>@excludes }
314
+ attributes[:output] = relative(output) if output
315
+ @xml.classpathentry attributes
316
+ @paths_written << path
317
+ end
318
+ end
319
+ end
320
+ end
321
+
322
+ end
323
+
324
+ end # module Buildr
325
+
326
+ class Buildr::Project
327
+ include Buildr::Eclipse
328
+ end
329
+
330
+ # Order is significant for auto-detection, from most specific to least
331
+ require 'buildr/ide/eclipse/plugin'
332
+ require 'buildr/ide/eclipse/scala'
333
+ require 'buildr/ide/eclipse/java'
334
+