ittayd-buildr 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. data/CHANGELOG +62 -9
  2. data/NOTICE +1 -1
  3. data/README.rdoc +9 -21
  4. data/Rakefile +20 -39
  5. data/_buildr +1 -0
  6. data/{spec/java/ant.rb → _jbuildr} +11 -15
  7. metadata +30 -210
  8. data/DISCLAIMER +0 -7
  9. data/addon/buildr/antlr.rb +0 -65
  10. data/addon/buildr/cobertura.rb +0 -22
  11. data/addon/buildr/drb.rb +0 -281
  12. data/addon/buildr/emma.rb +0 -22
  13. data/addon/buildr/hibernate.rb +0 -142
  14. data/addon/buildr/javacc.rb +0 -85
  15. data/addon/buildr/jdepend.rb +0 -60
  16. data/addon/buildr/jetty.rb +0 -248
  17. data/addon/buildr/jibx.rb +0 -86
  18. data/addon/buildr/nailgun.rb +0 -221
  19. data/addon/buildr/openjpa.rb +0 -90
  20. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  21. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  22. data/addon/buildr/org/apache/buildr/BuildrNail.java +0 -41
  23. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  25. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  26. data/addon/buildr/org/apache/buildr/JettyWrapper.java +0 -144
  27. data/addon/buildr/path.rb +0 -136
  28. data/addon/buildr/xmlbeans.rb +0 -93
  29. data/buildr.buildfile +0 -53
  30. data/buildr.gemspec +0 -58
  31. data/doc/css/default.css +0 -228
  32. data/doc/css/print.css +0 -100
  33. data/doc/css/syntax.css +0 -52
  34. data/doc/images/apache-incubator-logo.png +0 -0
  35. data/doc/images/buildr-hires.png +0 -0
  36. data/doc/images/buildr.png +0 -0
  37. data/doc/images/favicon.png +0 -0
  38. data/doc/images/growl-icon.tiff +0 -0
  39. data/doc/images/note.png +0 -0
  40. data/doc/images/project-structure.png +0 -0
  41. data/doc/images/tip.png +0 -0
  42. data/doc/images/zbuildr.tif +0 -0
  43. data/doc/pages/artifacts.textile +0 -207
  44. data/doc/pages/building.textile +0 -240
  45. data/doc/pages/contributing.textile +0 -208
  46. data/doc/pages/download.textile +0 -62
  47. data/doc/pages/extending.textile +0 -175
  48. data/doc/pages/getting_started.textile +0 -273
  49. data/doc/pages/index.textile +0 -42
  50. data/doc/pages/languages.textile +0 -407
  51. data/doc/pages/mailing_lists.textile +0 -17
  52. data/doc/pages/more_stuff.textile +0 -314
  53. data/doc/pages/packaging.textile +0 -427
  54. data/doc/pages/projects.textile +0 -274
  55. data/doc/pages/recipes.textile +0 -103
  56. data/doc/pages/settings_profiles.textile +0 -274
  57. data/doc/pages/testing.textile +0 -212
  58. data/doc/pages/troubleshooting.textile +0 -103
  59. data/doc/pages/whats_new.textile +0 -323
  60. data/doc/print.haml +0 -51
  61. data/doc/print.toc.yaml +0 -29
  62. data/doc/scripts/buildr-git.rb +0 -412
  63. data/doc/scripts/install-jruby.sh +0 -44
  64. data/doc/scripts/install-linux.sh +0 -64
  65. data/doc/scripts/install-osx.sh +0 -52
  66. data/doc/site.haml +0 -56
  67. data/doc/site.toc.yaml +0 -47
  68. data/etc/KEYS +0 -151
  69. data/etc/git-svn-authors +0 -16
  70. data/lib/buildr.rb +0 -33
  71. data/lib/buildr/core.rb +0 -29
  72. data/lib/buildr/core/application.rb +0 -665
  73. data/lib/buildr/core/build.rb +0 -311
  74. data/lib/buildr/core/checks.rb +0 -254
  75. data/lib/buildr/core/common.rb +0 -150
  76. data/lib/buildr/core/compile.rb +0 -590
  77. data/lib/buildr/core/environment.rb +0 -117
  78. data/lib/buildr/core/filter.rb +0 -366
  79. data/lib/buildr/core/generate.rb +0 -195
  80. data/lib/buildr/core/help.rb +0 -119
  81. data/lib/buildr/core/osx.rb +0 -49
  82. data/lib/buildr/core/progressbar.rb +0 -156
  83. data/lib/buildr/core/project.rb +0 -923
  84. data/lib/buildr/core/test.rb +0 -715
  85. data/lib/buildr/core/transports.rb +0 -560
  86. data/lib/buildr/core/util.rb +0 -294
  87. data/lib/buildr/groovy.rb +0 -18
  88. data/lib/buildr/groovy/bdd.rb +0 -106
  89. data/lib/buildr/groovy/compiler.rb +0 -138
  90. data/lib/buildr/ide.rb +0 -19
  91. data/lib/buildr/ide/eclipse.rb +0 -222
  92. data/lib/buildr/ide/idea.ipr.template +0 -300
  93. data/lib/buildr/ide/idea.rb +0 -190
  94. data/lib/buildr/ide/idea7x.ipr.template +0 -290
  95. data/lib/buildr/ide/idea7x.rb +0 -212
  96. data/lib/buildr/java.rb +0 -23
  97. data/lib/buildr/java/ant.rb +0 -92
  98. data/lib/buildr/java/bdd.rb +0 -451
  99. data/lib/buildr/java/cobertura.rb +0 -236
  100. data/lib/buildr/java/commands.rb +0 -211
  101. data/lib/buildr/java/compiler.rb +0 -348
  102. data/lib/buildr/java/deprecated.rb +0 -141
  103. data/lib/buildr/java/emma.rb +0 -238
  104. data/lib/buildr/java/jruby.rb +0 -117
  105. data/lib/buildr/java/jtestr_runner.rb.erb +0 -116
  106. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  107. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +0 -119
  108. data/lib/buildr/java/packaging.rb +0 -717
  109. data/lib/buildr/java/pom.rb +0 -174
  110. data/lib/buildr/java/rjb.rb +0 -155
  111. data/lib/buildr/java/test_result.rb +0 -307
  112. data/lib/buildr/java/tests.rb +0 -329
  113. data/lib/buildr/java/version_requirement.rb +0 -172
  114. data/lib/buildr/packaging.rb +0 -24
  115. data/lib/buildr/packaging/archive.rb +0 -488
  116. data/lib/buildr/packaging/artifact.rb +0 -759
  117. data/lib/buildr/packaging/artifact_namespace.rb +0 -972
  118. data/lib/buildr/packaging/artifact_search.rb +0 -140
  119. data/lib/buildr/packaging/gems.rb +0 -102
  120. data/lib/buildr/packaging/package.rb +0 -233
  121. data/lib/buildr/packaging/tar.rb +0 -186
  122. data/lib/buildr/packaging/version_requirement.rb +0 -172
  123. data/lib/buildr/packaging/zip.rb +0 -64
  124. data/lib/buildr/packaging/ziptask.rb +0 -313
  125. data/lib/buildr/resources/buildr.icns +0 -0
  126. data/lib/buildr/scala.rb +0 -19
  127. data/lib/buildr/scala/compiler.rb +0 -109
  128. data/lib/buildr/scala/tests.rb +0 -203
  129. data/rakelib/apache.rake +0 -191
  130. data/rakelib/changelog.rake +0 -57
  131. data/rakelib/doc.rake +0 -103
  132. data/rakelib/package.rake +0 -76
  133. data/rakelib/release.rake +0 -65
  134. data/rakelib/rspec.rake +0 -83
  135. data/rakelib/rubyforge.rake +0 -56
  136. data/rakelib/scm.rake +0 -49
  137. data/rakelib/setup.rake +0 -81
  138. data/rakelib/stage.rake +0 -48
  139. data/spec/addon/drb_spec.rb +0 -328
  140. data/spec/core/application_spec.rb +0 -419
  141. data/spec/core/build_spec.rb +0 -423
  142. data/spec/core/checks_spec.rb +0 -519
  143. data/spec/core/common_spec.rb +0 -670
  144. data/spec/core/compile_spec.rb +0 -582
  145. data/spec/core/generate_spec.rb +0 -33
  146. data/spec/core/project_spec.rb +0 -776
  147. data/spec/core/test_spec.rb +0 -1098
  148. data/spec/core/transport_spec.rb +0 -500
  149. data/spec/groovy/bdd_spec.rb +0 -80
  150. data/spec/groovy/compiler_spec.rb +0 -239
  151. data/spec/ide/eclipse_spec.rb +0 -311
  152. data/spec/java/bdd_spec.rb +0 -358
  153. data/spec/java/cobertura_spec.rb +0 -77
  154. data/spec/java/compiler_spec.rb +0 -446
  155. data/spec/java/emma_spec.rb +0 -120
  156. data/spec/java/java_spec.rb +0 -96
  157. data/spec/java/packaging_spec.rb +0 -1120
  158. data/spec/java/test_coverage_spec.rb +0 -255
  159. data/spec/java/tests_spec.rb +0 -471
  160. data/spec/packaging/archive_spec.rb +0 -503
  161. data/spec/packaging/artifact_namespace_spec.rb +0 -646
  162. data/spec/packaging/artifact_spec.rb +0 -795
  163. data/spec/packaging/packaging_helper.rb +0 -63
  164. data/spec/packaging/packaging_spec.rb +0 -589
  165. data/spec/sandbox.rb +0 -139
  166. data/spec/scala/compiler_spec.rb +0 -228
  167. data/spec/scala/tests_spec.rb +0 -215
  168. data/spec/spec_helpers.rb +0 -327
  169. data/spec/version_requirement_spec.rb +0 -123
@@ -1,116 +0,0 @@
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
- # | \ / _ \ | \| |/ _ \_ _| | __| \_ _|_ _| |_ _| || |_ _/ __|
18
- # | |) | (_) | | .` | (_) || | | _|| |) | | | | | | | __ || |\__ \
19
- # |___/ \___/ |_|\_|\___/ |_| |___|___/___| |_| |_| |_||_|___|___/
20
- #
21
- # ___ ___ _ ___
22
- # | __|_ _| | | __| CHANGES TO THIS FILE WILL BE LOST
23
- # | _| | || |__| _| AUTO-GENERATED BY BUILDR on <%= Time.now %>
24
- # |_| |___|____|___| PREFER TO EDIT JtestR CONFIGURATION FILE:
25
- #
26
- # <%= user_config %>
27
-
28
- begin
29
-
30
- <%= jruby_gem %>
31
- <%= dependencies.map(&:to_s).inspect %>.each { |dep| $CLASSPATH << dep }
32
- <%= runner.gems.inspect %>.each { |ary| JRuby.gem(*ary.flatten) }
33
- <%= runner.requires.inspect %>.each { |rb| Kernel.require rb }
34
-
35
- jtestr = JtestR::TestRunner.new
36
-
37
- class << jtestr
38
- def config(&block)
39
- @config_blocks ||= []
40
- @config_blocks << block if block
41
- @config_blocks
42
- end
43
-
44
- def load_configuration
45
- super
46
- config.each { |block| @configuration.instance_eval(&block) }
47
- end
48
- end
49
-
50
- jtestr.config do
51
- classpath [] # already loaded
52
- add_common_classpath false
53
-
54
- <% ts = ( @jtestr_tests[:junit] & tests ).map { |c| 'Java.' + c } %>
55
- junit [<%= ts.join(', ') %>]
56
-
57
- <% ts = ( @jtestr_tests[:testng] & tests ).map { |c| 'Java.' + c } %>
58
- testng [<%= ts.join(', ') %>]
59
-
60
- <% ts = @jtestr_tests[:testunit] & tests %>
61
- test_unit <%= ts.inspect %>
62
-
63
- <% ts = @jtestr_tests[:story] & tests %>
64
- story <%= ts.inspect %>
65
-
66
- <% ts = @jtestr_tests[:rspec] & tests %>
67
- rspec <%= ts.inspect %>
68
-
69
- <% ts = @jtestr_tests[:expect] & tests %>
70
- expectations <%= ts.inspect %>
71
-
72
- ignore __FILE__
73
-
74
- if File.file?(<%= user_config.inspect %>)
75
- ignore <%= user_config.inspect %>
76
- load <%= user_config.inspect %>
77
- end
78
- end # config
79
-
80
- fake_out = StringIO.new
81
-
82
- <% if runner.output == false %>
83
- output = fake_out
84
- <% elsif runner.output.kind_of?(String) %>
85
- output = File.open(<%= result.output.inspect %>, 'w')
86
- <% else %>
87
- output = STDOUT
88
- <% end %>
89
-
90
-
91
- args = [ '<%= spec_dir %>', # the directory to search for jtestr files
92
- JtestR::SimpleLogger::ERR, # log level
93
- JtestR::GenericResultHandler::QUIET, #output level
94
- fake_out, # output STDOUT
95
- [], # groups to run
96
- Buildr::TestFramework::TestResult::RSpecResultHandler, # result handler
97
- [] # classpath
98
- ]
99
-
100
- argv = <%= runner.rspec.inspect %> || []
101
- argv.push *<%= tests.inspect %>
102
- Buildr::TestFramework::TestResult::RSpecResultHandler.init(argv, output, output)
103
-
104
- jtestr.run *args
105
-
106
- rescue => e
107
- Buildr::TestFramework::TestResult::Error.dump_yaml('<%= runner.result %>', e) rescue \
108
- puts "-[--- ERROR ---]-", e.class, e.message, *e.backtrace
109
- end
110
-
111
- exit 0 # let buildr find the erros from the result yaml
112
-
113
- # Local Variables:
114
- # mode: ruby
115
- # End:
116
-
@@ -1,119 +0,0 @@
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
14
- * under the License.
15
- */
16
-
17
-
18
- package org.apache.buildr;
19
-
20
- import java.lang.reflect.Method;
21
- import java.lang.reflect.Modifier;
22
- import java.io.File;
23
- import java.io.IOException;
24
- import java.net.URL;
25
- import java.net.URLClassLoader;
26
- import java.net.MalformedURLException;
27
- import java.util.Iterator;
28
- import java.util.Vector;
29
-
30
- public class JavaTestFilter {
31
-
32
- private ClassLoader _loader;
33
- private Vector methodAnnotations = new Vector();
34
- private Vector classAnnotations = new Vector();
35
- private Vector interfaces = new Vector();
36
-
37
- public JavaTestFilter(String[] paths) throws IOException {
38
- URL[] urls = new URL[paths.length];
39
- for (int i = 0 ; i < paths.length ; ++i) {
40
- File file = new File(paths[i]).getCanonicalFile();
41
- if (file.exists())
42
- urls[i] = file.toURL();
43
- else
44
- throw new IOException("No file or directory with the name " + file);
45
- }
46
- _loader = new URLClassLoader(urls, getClass().getClassLoader());
47
- }
48
-
49
- public JavaTestFilter addInterfaces(String[] names) throws ClassNotFoundException {
50
- for (int i = names.length; i -- > 0;) {
51
- String name = names[i];
52
- interfaces.add(_loader.loadClass(name));
53
- }
54
- return this;
55
- }
56
-
57
- public JavaTestFilter addClassAnnotations(String[] names) throws ClassNotFoundException {
58
- for (int i = names.length; i -- > 0;) {
59
- String name = names[i];
60
- classAnnotations.add(_loader.loadClass(name));
61
- }
62
- return this;
63
- }
64
-
65
- public JavaTestFilter addMethodAnnotations(String[] names) throws ClassNotFoundException {
66
- for (int i = names.length; i -- > 0;) {
67
- String name = names[i];
68
- methodAnnotations.add(_loader.loadClass(name));
69
- }
70
- return this;
71
- }
72
-
73
- private boolean isTest(Class cls) {
74
- if (Modifier.isAbstract(cls.getModifiers()) || !Modifier.isPublic(cls.getModifiers()))
75
- return false;
76
- if (interfaces != null) {
77
- for (Iterator it = interfaces.iterator(); it.hasNext(); ) {
78
- Class iface = (Class) it.next();
79
- if (iface.isAssignableFrom(cls)) { return true; }
80
- }
81
- }
82
- if (classAnnotations != null) {
83
- for (Iterator it = classAnnotations.iterator(); it.hasNext(); ) {
84
- Class annotation = (Class) it.next();
85
- if (cls.isAnnotationPresent(annotation)) { return true; }
86
- }
87
- }
88
- if (methodAnnotations != null) {
89
- Method[] methods = cls.getMethods();
90
- for (int j = methods.length ; j-- > 0 ;) {
91
- for (Iterator it = methodAnnotations.iterator(); it.hasNext(); ) {
92
- Class annotation = (Class) it.next();
93
- if (methods[j].isAnnotationPresent(annotation)) { return true; }
94
- }
95
- }
96
- }
97
- return false;
98
- }
99
-
100
-
101
- public String[] filter(String[] names) throws ClassNotFoundException {
102
- Vector testCases = new Vector();
103
- for (int i = names.length ; i-- > 0 ;) {
104
- Class cls = _loader.loadClass(names[i]);
105
- if (isTest(cls)) { testCases.add(names[i]); }
106
- }
107
- String[] result = new String[testCases.size()];
108
- testCases.toArray(result);
109
- return result;
110
- }
111
-
112
- }
113
-
114
- /*
115
- * Local Variables:
116
- * indent-tabs-mode: nil
117
- * c-basic-offset: 2
118
- * End:
119
- */
@@ -1,717 +0,0 @@
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/packaging'
18
-
19
-
20
- module Buildr
21
- module Packaging
22
-
23
- # Adds packaging for Java projects: JAR, WAR, AAR, EAR, Javadoc.
24
- module Java
25
-
26
- class Manifest
27
-
28
- STANDARD_HEADER = { 'Manifest-Version'=>'1.0', 'Created-By'=>'Buildr' }
29
- LINE_SEPARATOR = /\r\n|\n|\r[^\n]/ #:nodoc:
30
- SECTION_SEPARATOR = /(#{LINE_SEPARATOR}){2}/ #:nodoc:
31
-
32
- class << self
33
-
34
- # :call-seq:
35
- # parse(str) => manifest
36
- #
37
- # Parse a string in MANIFEST.MF format and return a new Manifest.
38
- def parse(str)
39
- sections = str.split(SECTION_SEPARATOR).reject { |s| s.strip.empty? }
40
- new sections.map { |section|
41
- lines = section.split(LINE_SEPARATOR).inject([]) { |merged, line|
42
- if line[0] == 32
43
- merged.last << line[1..-1]
44
- else
45
- merged << line
46
- end
47
- merged
48
- }
49
- lines.map { |line| line.scan(/(.*?):\s*(.*)/).first }.
50
- inject({}) { |map, (key, value)| map.merge(key=>value) }
51
- }
52
- end
53
-
54
- # :call-seq:
55
- # from_zip(file) => manifest
56
- #
57
- # Parse the MANIFEST.MF entry of a ZIP (or JAR) file and return a new Manifest.
58
- def from_zip(file)
59
- Zip::ZipFile.open(file.to_s) do |zip|
60
- return Manifest.new unless zip.get_entry('META-INF/MANIFEST.MF')
61
- Manifest.parse zip.read('META-INF/MANIFEST.MF')
62
- end
63
- end
64
-
65
- # :call-seq:
66
- # update_manifest(file) { |manifest| ... }
67
- #
68
- # Updates the MANIFEST.MF entry of a ZIP (or JAR) file. Reads the MANIFEST.MF,
69
- # yields to the block with the Manifest object, and writes the modified object
70
- # back to the file.
71
- def update_manifest(file)
72
- manifest = from_zip(file)
73
- result = yield manifest
74
- Zip::ZipFile.open(file.to_s) do |zip|
75
- zip.get_output_stream('META-INF/MANIFEST.MF') do |out|
76
- out.write manifest.to_s
77
- out.write "\n"
78
- end
79
- end
80
- result
81
- end
82
-
83
- end
84
-
85
- # Returns a new Manifest object based on the argument:
86
- # * nil -- Empty Manifest.
87
- # * Hash -- Manifest with main section using the hash name/value pairs.
88
- # * Array -- Manifest with one section from each entry (must be hashes).
89
- # * String -- Parse (see Manifest#parse).
90
- # * Proc/Method -- New Manifest from result of calling proc/method.
91
- def initialize(arg = nil)
92
- case arg
93
- when nil, Hash then @sections = [arg || {}]
94
- when Array then @sections = arg
95
- when String then @sections = Manifest.parse(arg).sections
96
- when Proc, Method then @sections = Manifest.new(arg.call).sections
97
- else
98
- fail 'Invalid manifest, expecting Hash, Array, file name/task or proc/method.'
99
- end
100
- # Add Manifest-Version and Created-By, if not specified.
101
- STANDARD_HEADER.each do |name, value|
102
- sections.first[name] ||= value
103
- end
104
- end
105
-
106
- # The sections of this manifest.
107
- attr_reader :sections
108
-
109
- # The main (first) section of this manifest.
110
- def main
111
- sections.first
112
- end
113
-
114
- include Enumerable
115
-
116
- # Iterate over each section and yield to block.
117
- def each(&block)
118
- @sections.each(&block)
119
- end
120
-
121
- # Convert to MANIFEST.MF format.
122
- def to_s
123
- @sections.map { |section|
124
- keys = section.keys
125
- keys.unshift('Name') if keys.delete('Name')
126
- lines = keys.map { |key| manifest_wrap_at_72("#{key}: #{section[key]}") }
127
- lines + ['']
128
- }.flatten.join("\n")
129
- end
130
-
131
- private
132
-
133
- def manifest_wrap_at_72(line)
134
- return [line] if line.size < 72
135
- [ line[0..70] ] + manifest_wrap_at_72(' ' + line[71..-1])
136
- end
137
-
138
- end
139
-
140
-
141
- # Adds support for MANIFEST.MF and other META-INF files.
142
- module WithManifest #:nodoc:
143
-
144
- class << self
145
- def included(base)
146
- base.class_eval do
147
- alias :initialize_without_manifest :initialize
148
- alias :initialize :initialize_with_manifest
149
- end
150
- end
151
-
152
- end
153
-
154
- # Specifies how to create the manifest file.
155
- attr_accessor :manifest
156
-
157
- # Specifies files to include in the META-INF directory.
158
- attr_accessor :meta_inf
159
-
160
- def initialize_with_manifest(*args) #:nodoc:
161
- initialize_without_manifest *args
162
- @manifest = false
163
- @meta_inf = []
164
- @dependencies = FileList[]
165
-
166
- prepare do
167
- @prerequisites << manifest if String === manifest || Rake::Task === manifest
168
- [meta_inf].flatten.map { |file| file.to_s }.uniq.each { |file| path('META-INF').include file }
169
- end
170
-
171
- enhance do
172
- if manifest
173
- # Tempfiles gets deleted on garbage collection, so we're going to hold on to it
174
- # through instance variable not closure variable.
175
- @manifest_tmp = Tempfile.new('MANIFEST.MF')
176
- self.manifest = File.read(manifest.to_s) if String === manifest || Rake::Task === manifest
177
- self.manifest = Manifest.new(manifest) unless Manifest === manifest
178
- #@manifest_tmp.write Manifest::STANDARD_HEADER
179
- @manifest_tmp.write manifest.to_s
180
- @manifest_tmp.write "\n"
181
- @manifest_tmp.rewind
182
- path('META-INF').include @manifest_tmp.path, :as=>'MANIFEST.MF'
183
- end
184
- end
185
- end
186
-
187
- end
188
-
189
- class ::Buildr::ZipTask
190
- include WithManifest
191
- end
192
-
193
-
194
- # Extends the ZipTask to create a JAR file.
195
- #
196
- # This task supports two additional attributes: manifest and meta-inf.
197
- #
198
- # The manifest attribute specifies how to create the MANIFEST.MF file.
199
- # * A hash of manifest properties (name/value pairs).
200
- # * An array of hashes, one for each section of the manifest.
201
- # * A string providing the name of an existing manifest file.
202
- # * A file task can be used the same way.
203
- # * Proc or method called to return the contents of the manifest file.
204
- # * False to not generate a manifest file.
205
- #
206
- # The meta-inf attribute lists one or more files that should be copied into
207
- # the META-INF directory.
208
- #
209
- # For example:
210
- # package(:jar).with(:manifest=>'src/MANIFEST.MF')
211
- # package(:jar).meta_inf << file('README')
212
- class JarTask < ZipTask
213
-
214
- def initialize(*args) #:nodoc:
215
- super
216
- end
217
-
218
- # :call-seq:
219
- # with(options) => self
220
- #
221
- # Additional
222
- # Pass options to the task. Returns self. ZipTask itself does not support any options,
223
- # but other tasks (e.g. JarTask, WarTask) do.
224
- #
225
- # For example:
226
- # package(:jar).with(:manifest=>'MANIFEST_MF')
227
- def with(*args)
228
- super args.pop if Hash === args.last
229
- include :from=>args
230
- self
231
- end
232
-
233
- end
234
-
235
-
236
- # Extends the JarTask to create a WAR file.
237
- #
238
- # Supports all the same options as JarTask, in additon to these two options:
239
- # * :libs -- An array of files, tasks, artifact specifications, etc that will be added
240
- # to the WEB-INF/lib directory.
241
- # * :classes -- A directory containing class files for inclusion in the WEB-INF/classes
242
- # directory.
243
- #
244
- # For example:
245
- # package(:war).with(:libs=>'log4j:log4j:jar:1.1')
246
- class WarTask < JarTask
247
-
248
- # Directories with class files to include under WEB-INF/classes.
249
- attr_accessor :classes
250
-
251
- # Artifacts to include under WEB-INF/libs.
252
- attr_accessor :libs
253
-
254
- def initialize(*args) #:nodoc:
255
- super
256
- @classes = []
257
- @libs = []
258
- prepare do
259
- @classes.to_a.flatten.each { |classes| path('WEB-INF/classes').include classes, :as=>'.' }
260
- path('WEB-INF/lib').include Buildr.artifacts(@libs) unless @libs.nil? || @libs.empty?
261
- end
262
- end
263
-
264
- def libs=(value) #:nodoc:
265
- @libs = Buildr.artifacts(value)
266
- end
267
-
268
- def classes=(value) #:nodoc:
269
- @classes = [value].flatten.map { |dir| file(dir.to_s) }
270
- end
271
-
272
- end
273
-
274
-
275
- # Extends the JarTask to create an AAR file (Axis2 service archive).
276
- #
277
- # Supports all the same options as JarTask, with the addition of :wsdls, :services_xml and :libs.
278
- #
279
- # * :wsdls -- WSDL files to include (under META-INF). By default packaging will include all WSDL
280
- # files found under src/main/axis2.
281
- # * :services_xml -- Location of services.xml file (included under META-INF). By default packaging
282
- # takes this from src/main/axis2/services.xml. Use a different path if you genereate the services.xml
283
- # file as part of the build.
284
- # * :libs -- Array of files, tasks, artifact specifications, etc that will be added to the /lib directory.
285
- #
286
- # For example:
287
- # package(:aar).with(:libs=>'log4j:log4j:jar:1.1')
288
- #
289
- # filter.from('src/main/axis2').into('target').include('services.xml', '*.wsdl').using('http_port'=>'8080')
290
- # package(:aar).wsdls.clear
291
- # package(:aar).with(:services_xml=>_('target/services.xml'), :wsdls=>_('target/*.wsdl'))
292
- class AarTask < JarTask
293
- # Artifacts to include under /lib.
294
- attr_accessor :libs
295
- # WSDLs to include under META-INF (defaults to all WSDLs under src/main/axis2).
296
- attr_accessor :wsdls
297
- # Location of services.xml file (defaults to src/main/axis2/services.xml).
298
- attr_accessor :services_xml
299
-
300
- def initialize(*args) #:nodoc:
301
- super
302
- @libs = []
303
- @wsdls = []
304
- prepare do
305
- path('META-INF').include @wsdls
306
- path('META-INF').include @services_xml, :as=>['services.xml'] if @services_xml
307
- path('lib').include Buildr.artifacts(@libs) unless @libs.nil? || @libs.empty?
308
- end
309
- end
310
-
311
- def libs=(value) #:nodoc:
312
- @libs = Buildr.artifacts(value)
313
- end
314
-
315
- def wsdls=(value) #:nodoc:
316
- @wsdls |= Array(value)
317
- end
318
- end
319
-
320
-
321
- # Extend the JarTask to create an EAR file.
322
- #
323
- # The following component types are supported by the EARTask:
324
- #
325
- # * :war -- A J2EE Web Application
326
- # * :ejb -- An Enterprise Java Bean
327
- # * :jar -- A J2EE Application Client.[1]
328
- # * :lib -- An ear scoped shared library[2] (for things like logging,
329
- # spring, etc) common to the ear components
330
- #
331
- # The EarTask uses the "Mechanism 2: Bundled Optional Classes" as described on [2].
332
- # All specified libraries are added to the EAR archive and the Class-Path manifiest entry is
333
- # modified for each EAR component. Special care is taken with WebApplications, as they can
334
- # contain libraries on their WEB-INF/lib directory, libraries already included in a war file
335
- # are not referenced by the Class-Path entry of the war in order to avoid class collisions
336
- #
337
- # EarTask supports all the same options as JarTask, in additon to these two options:
338
- #
339
- # * :display_name -- The displayname to for this ear on application.xml
340
- #
341
- # * :map -- A Hash used to map component type to paths within the EAR.
342
- # By default each component type is mapped to a directory with the same name,
343
- # for example, EJBs are stored in the /ejb path. To customize:
344
- # package(:ear).map[:war] = 'web-applications'
345
- # package(:ear).map[:lib] = nil # store shared libraries on root of archive
346
- #
347
- # EAR components are added by means of the EarTask#add, EarTask#<<, EarTask#push methods
348
- # Component type is determined from the artifact's type.
349
- #
350
- # package(:ear) << project('coolWebService').package(:war)
351
- #
352
- # The << method is just an alias for push, with the later you can add multiple components
353
- # at the same time. For example..
354
- #
355
- # package(:ear).push 'org.springframework:spring:jar:2.6',
356
- # projects('reflectUtils', 'springUtils'),
357
- # project('coolerWebService').package(:war)
358
- #
359
- # The add method takes a single component with an optional hash. You can use it to override
360
- # some component attributes.
361
- #
362
- # You can override the component type for a particular artifact. The following example
363
- # shows how you can tell the EarTask to treat a JAR file as an EJB:
364
- #
365
- # # will add an ejb entry for the-cool-ejb-2.5.jar in application.xml
366
- # package(:ear).add 'org.coolguys:the-cool-ejb:jar:2.5', :type=>:ejb
367
- # # A better syntax for this is:
368
- # package(:ear).add :ejb=>'org.coolguys:the-cool-ejb:jar:2.5'
369
- #
370
- # By default, every JAR package is assumed to be a library component, so you need to specify
371
- # the type when including an EJB (:ejb) or Application Client JAR (:jar).
372
- #
373
- # For WebApplications (:war)s, you can customize the context-root that appears in application.xml.
374
- # The following example also specifies a different directory inside the EAR where to store the webapp.
375
- #
376
- # package(:ear).add project(:remoteService).package(:war),
377
- # :path=>'web-services', :context_root=>'/Some/URL/Path'
378
- #
379
- # [1] http://java.sun.com/j2ee/sdk_1.2.1/techdocs/guides/ejb/html/Overview5.html#10106
380
- # [2] http://java.sun.com/j2ee/verified/packaging.html
381
- class EarTask < JarTask
382
-
383
- SUPPORTED_TYPES = [:war, :ejb, :jar, :rar, :lib]
384
-
385
- # The display-name entry for application.xml
386
- attr_accessor :display_name
387
- # Map from component type to path inside the EAR.
388
- attr_accessor :dirs
389
-
390
- def initialize(*args)
391
- super
392
- @dirs = Hash.new { |h, k| k.to_s }
393
- @libs, @components = [], []
394
- prepare do
395
- @components.each do |component|
396
- path(component[:path]).include(component[:clone] || component[:artifact])
397
- end
398
- path('META-INF').include(descriptor)
399
- end
400
- end
401
-
402
- # Add an artifact to this EAR.
403
- def add(*args)
404
- options = Hash === args.last ? args.pop.clone : {}
405
- args.flatten!
406
- args.map! do |pkg|
407
- case pkg
408
- when Project
409
- pkg.packages.select { |pp| JarTask === pp && SUPPORTED_TYPES.include?(pp.type) }
410
- when Rake::FileTask
411
- pkg # add the explicitly provided file
412
- when Hash
413
- Buildr.artifact(pkg)
414
- when String
415
- begin
416
- Buildr.artifact(pkg)
417
- rescue # not an artifact spec, it must me a filename
418
- file(pkg)
419
- end
420
- else
421
- raise "Invalid EAR component #{pkg.class}: #{pkg}"
422
- end
423
- end
424
- args.flatten!
425
- args.compact!
426
- if args.empty?
427
- raise ":type must not be specified for type=>component argument style" if options.key?(:type)
428
- raise ":as must not be specified for type=>component argument style" if options.key?(:as)
429
- comps = {}
430
- options.delete_if { |k, v| comps[k] = v if SUPPORTED_TYPES.include?(k) }
431
- raise "You must specify at least one valid component to add" if comps.empty?
432
- comps.each { |k, v| add(v, {:as => k}.merge(options)) }
433
- else
434
- args.each do |artifact|
435
- type = options[:as] || options[:type]
436
- unless type
437
- type = artifact.respond_to?(:type) ? artifact.type : artifact.to_s.pathmap('%x').to_sym
438
- type = :lib if type == :jar
439
- end
440
- raise "Unknown EAR component type: #{type}. Perhaps you may explicity tell what component type to use." unless
441
- SUPPORTED_TYPES.include?(type)
442
- component = options.merge(:artifact => artifact, :type => type,
443
- :id=>artifact.respond_to?(:to_spec) ? artifact.id : artifact.to_s.pathmap('%n'),
444
- :path=>options[:path] || dirs[type].to_s)
445
- component[:clone] = component_clone(component) unless :lib == type
446
- # update_classpath(component) unless :lib == type || Artifact === artifact
447
- @components << component
448
- end
449
- end
450
- self
451
- end
452
-
453
- alias_method :push, :add
454
- alias_method :<<, :push
455
-
456
- protected
457
-
458
- def component_clone(component)
459
- file(path_to(component[:path], component[:artifact].to_s.pathmap('%f')) => component[:artifact]) do |task|
460
- mkpath task.to_s.pathmap('%d'), :verbose => false
461
- cp component[:artifact].to_s, task.to_s, :verbose => false
462
- Manifest.update_manifest(task) do |manifest|
463
- class_path = manifest.main['Class-Path'].to_s.split
464
- included_libs = class_path.map { |fn| fn.pathmap('%f') }
465
- Zip::ZipFile.foreach(task.to_s) do |entry|
466
- included_libs << entry.name.pathmap('%f') if entry.file? && entry.name =~ /^WEB-INF\/lib\/[^\/]+$/
467
- end
468
- # Include all other libraries in the classpath.
469
- class_path += libs_classpath(component).reject { |path| included_libs.include?(File.basename(path)) }
470
- manifest.main['Class-Path'] = class_path.join(' ')
471
- end
472
- end
473
- end
474
-
475
- def associate(project)
476
- @project = project
477
- end
478
-
479
- def path_to(*args) #:nodoc:
480
- @project.path_to(:target, :ear, name.pathmap('%n'), *args)
481
- end
482
- alias_method :_, :path_to
483
-
484
- def update_classpath(component)
485
- package = file(component[:artifact].to_s)
486
- package.manifest = (package.manifest || {}).dup # avoid mofifying parent projects manifest
487
- package.prepare do
488
- header = case package.manifest
489
- when Hash then package.manifest
490
- when Array then package.manifest.first
491
- end
492
- if header
493
- # Determine which libraries are already included.
494
- class_path = header['Class-Path'].to_s.split
495
- included_libs = class_path.map { |fn| File.basename(fn) }
496
- included_libs += package.path('WEB-INF/lib').sources.map { |fn| File.basename(fn) }
497
- # Include all other libraries in the classpath.
498
- class_path += libs_classpath(component).reject { |path| included_libs.include?(File.basename(path)) }
499
- header['Class-Path'] = class_path.join(' ')
500
- end
501
- end
502
- end
503
-
504
- private
505
-
506
- # Classpath of all packages included as libraries (type :lib).
507
- def libs_classpath(component)
508
- from = component[:path]
509
- @classpath = @components.select { |comp| comp[:type] == :lib }.
510
- map do |lib|
511
- basename = lib[:artifact].to_s.pathmap('%f')
512
- full_path = lib[:path].empty? ? basename : File.join(lib[:path], basename)
513
- Util.relative_path(full_path, from)
514
- end
515
- end
516
-
517
- def descriptor_xml
518
- buffer = ""
519
- xml = Builder::XmlMarkup.new(:target=>buffer, :indent => 2)
520
- xml.declare! :DOCTYPE, :application, :PUBLIC,
521
- "-//Sun Microsystems, Inc.//DTD J2EE Application 1.2//EN",
522
- "http://java.sun.com/j2ee/dtds/application_1_2.dtd"
523
- xml.application do
524
- xml.tag! 'display-name', display_name
525
- @components.each do |comp|
526
- basename = comp[:artifact].to_s.pathmap('%f')
527
- uri = comp[:path].empty? ? basename : File.join(comp[:path], basename)
528
- case comp[:type]
529
- when :war
530
- xml.module :id=>comp[:id] do
531
- xml.web do
532
- xml.tag! 'web-uri', uri
533
- xml.tag! 'context-root', File.join('', (comp[:context_root] || comp[:id])) unless comp[:context_root] == false
534
- end
535
- end
536
- when :ejb
537
- xml.module :id=>comp[:id] do
538
- xml.ejb uri
539
- end
540
- when :jar
541
- xml.jar uri
542
- end
543
- end
544
- end
545
- buffer
546
- end
547
-
548
- # return a FileTask to build the ear application.xml file
549
- def descriptor
550
- return @descriptor if @descriptor
551
- descriptor_path = path_to('META-INF/application.xml')
552
- @descriptor = file(descriptor_path) do |task|
553
- trace "Creating EAR Descriptor: #{task.to_s}"
554
- mkpath File.dirname(task.name), :verbose=>false
555
- File.open(task.name, 'w') { |file| file.print task.xml }
556
- end
557
- class << @descriptor
558
- attr_accessor :ear
559
-
560
- def xml
561
- @xml ||= ear.send :descriptor_xml
562
- end
563
-
564
- def needed?
565
- super || xml != File.read(self.to_s) rescue true
566
- end
567
- end
568
- @descriptor.ear = self
569
- @descriptor
570
- end
571
-
572
- end
573
-
574
-
575
- include Extension
576
-
577
- before_define do |project|
578
- ::Java.load
579
- if project.parent && project.parent.manifest
580
- project.manifest = project.parent.manifest.dup
581
- else
582
- project.manifest = {
583
- 'Build-By'=>ENV['USER'], 'Build-Jdk'=>ENV_JAVA['java.version'],
584
- 'Implementation-Title'=>project.comment || project.name,
585
- 'Implementation-Version'=>project.version }
586
- end
587
- if project.parent && project.parent.meta_inf
588
- project.meta_inf = project.parent.meta_inf.dup
589
- else
590
- project.meta_inf = [project.file('LICENSE')].select { |file| File.exist?(file.to_s) }
591
- end
592
- end
593
-
594
-
595
- # Manifest used for packaging. Inherited from parent project. The default value is a hash that includes
596
- # the Build-By, Build-Jdk, Implementation-Title and Implementation-Version values.
597
- # The later are taken from the project's comment (or name) and version number.
598
- attr_accessor :manifest
599
-
600
- # Files to always include in the package META-INF directory. The default value include
601
- # the LICENSE file if one exists in the project's base directory.
602
- attr_accessor :meta_inf
603
-
604
- # :call-seq:
605
- # package_with_sources(options?)
606
- #
607
- # Call this when you want the project (and all its sub-projects) to create a source distribution.
608
- # You can use the source distribution in an IDE when debugging.
609
- #
610
- # A source distribution is a ZIP package with the classifier 'sources', which includes all the
611
- # sources used by the compile task.
612
- #
613
- # Packages use the project's manifest and meta_inf properties, which you can override by passing
614
- # different values (e.g. false to exclude the manifest) in the options.
615
- #
616
- # To create source distributions only for specific projects, use the :only and :except options,
617
- # for example:
618
- # package_with_sources :only=>['foo:bar', 'foo:baz']
619
- #
620
- # (Same as calling package :sources on each project/sub-project that has source directories.)
621
- def package_with_sources(options = nil)
622
- options ||= {}
623
- enhance do
624
- selected = options[:only] ? projects(options[:only]) :
625
- options[:except] ? ([self] + projects - projects(options[:except])) :
626
- [self] + projects
627
- selected.reject { |project| project.compile.sources.empty? }.
628
- each { |project| project.package(:sources) }
629
- end
630
- end
631
-
632
- # :call-seq:
633
- # package_with_javadoc(options?)
634
- #
635
- # Call this when you want the project (and all its sub-projects) to create a JavaDoc distribution.
636
- # You can use the JavaDoc distribution in an IDE when coding against the API.
637
- #
638
- # A JavaDoc distribution is a ZIP package with the classifier 'javadoc', which includes all the
639
- # sources used by the compile task.
640
- #
641
- # Packages use the project's manifest and meta_inf properties, which you can override by passing
642
- # different values (e.g. false to exclude the manifest) in the options.
643
- #
644
- # To create JavaDoc distributions only for specific projects, use the :only and :except options,
645
- # for example:
646
- # package_with_javadoc :only=>['foo:bar', 'foo:baz']
647
- #
648
- # (Same as calling package :javadoc on each project/sub-project that has source directories.)
649
- def package_with_javadoc(options = nil)
650
- options ||= {}
651
- enhance do
652
- selected = options[:only] ? projects(options[:only]) :
653
- options[:except] ? ([self] + projects - projects(options[:except])) :
654
- [self] + projects
655
- selected.reject { |project| project.compile.sources.empty? }.
656
- each { |project| project.package(:javadoc) }
657
- end
658
- end
659
-
660
- protected
661
-
662
- def package_as_jar(file_name) #:nodoc:
663
- Java::JarTask.define_task(file_name).tap do |jar|
664
- jar.with :manifest=>manifest, :meta_inf=>meta_inf
665
- jar.with [compile.target, resources.target].compact
666
- end
667
- end
668
-
669
- def package_as_war(file_name) #:nodoc:
670
- Java::WarTask.define_task(file_name).tap do |war|
671
- war.with :manifest=>manifest, :meta_inf=>meta_inf
672
- # Add libraries in WEB-INF lib, and classes in WEB-INF classes
673
- war.with :classes=>[compile.target, resources.target].compact
674
- war.with :libs=>compile.dependencies
675
- # Add included files, or the webapp directory.
676
- webapp = path_to(:source, :main, :webapp)
677
- war.with webapp if File.exist?(webapp)
678
- end
679
- end
680
-
681
- def package_as_aar(file_name) #:nodoc:
682
- Java::AarTask.define_task(file_name).tap do |aar|
683
- aar.with :manifest=>manifest, :meta_inf=>meta_inf
684
- aar.with :wsdls=>path_to(:source, :main, :axis2, '*.wsdl')
685
- aar.with :services_xml=>path_to(:source, :main, :axis2, 'services.xml')
686
- aar.with [compile.target, resources.target].compact
687
- aar.with :libs=>compile.dependencies
688
- end
689
- end
690
-
691
- def package_as_ear(file_name) #:nodoc:
692
- Java::EarTask.define_task(file_name).tap do |ear|
693
- ear.send :associate, self
694
- ear.with :display_name=>id, :manifest=>manifest, :meta_inf=>meta_inf
695
- end
696
- end
697
-
698
- def package_as_javadoc_spec(spec) #:nodoc:
699
- spec.merge(:type=>:zip, :classifier=>'javadoc')
700
- end
701
-
702
- def package_as_javadoc(file_name) #:nodoc:
703
- ZipTask.define_task(file_name).tap do |zip|
704
- zip.include :from=>javadoc.target
705
- javadoc.options[:windowtitle] ||= project.comment || project.name
706
- end
707
- end
708
-
709
- end
710
-
711
- end
712
- end
713
-
714
-
715
- class Buildr::Project
716
- include Buildr::Packaging::Java
717
- end