buildr 1.4.9 → 1.4.10

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,49 @@
1
+ 1.4.10 (2013-02-10)
2
+ * Added: Support a single intermediate directory for each project hierarchy
3
+ through an addon 'buildr/single_intermediate_layout'.
4
+ * Fixed: BUILDR-660 possible build issue when using build.yaml and tasks/*.rake
5
+ (Félix Enrique Llorente Pastora)
6
+ * Added: Support the :dir option in the Java::Commands.java method.
7
+ * Fixed: Scala 2.10 support - compiler now uses additional/separate jars
8
+ introduced in 2.10 such as scala-reflect.jar and scala-actor.jar
9
+ * Added: Add an addon for NSIS.
10
+ * Change: BUILDR-612 - Support the TestNG 6.x versions and default
11
+ to 6.8.
12
+ * Added: BUILDR-599 - Support the passing of arguments to testng
13
+ test runner.
14
+ * Fixed: Observer the per-project source version when generating
15
+ IDEA module files.
16
+ * Change: Sort the components in IDEA project files in the same
17
+ order the idea sorts them.
18
+ * Fixed: Findbugs addon correctly handles String dependencies
19
+ (vs task dependencies)
20
+ * Fixed: Checkstyle addon correctly handles String dependencies
21
+ (vs task dependencies)
22
+ * Added: Created an addon 'buildr/wsgen' for generating wsdls from java
23
+ and java from wsdls using the underlying wsgen tool.
24
+ * Change: Defer the expansion of generated poms by wrapping the generation
25
+ in a Proc.
26
+ * Change: Rework Artifact.content(value) method to accept a Proc that
27
+ will be called before the artifact is written rather than
28
+ requiring a string.
29
+ * Added: Create a 'buildr/gpg' addon that signs and uploads signatures
30
+ when uploading artifacts. Inspired by a similar extension in
31
+ the Apache ODE project by Tammo van Lessen.
32
+ * Change: Updated dependency versions;
33
+ - jruby-openssl (0.8.2)
34
+ - atoulme-Antwrap (0.7.4)
35
+ * Change: Require 'bundler/setup' as part of buildr startup to ensure that
36
+ buildr always runs with up to date dependencies if a Gemfile is
37
+ present.
38
+ * Added: Add FrameworkDetectionExcludesConfiguration facet to Idea project
39
+ file creation by default.
40
+ * Fixed: In the IntelliJ extension, defer the materialization of the
41
+ default_components until expansion time to avoid loss of sub-
42
+ components added after an add_component call.
43
+ * Fixed: BUILDR-633 - Remove hardcoded shebang lines in all-in-one release.
44
+ * Added: Create a simple extension that modifies the project layout to place
45
+ generated files at the top level.
46
+
1
47
  1.4.9 (2012-11-08)
2
48
  * Fixed: Fixed the interaction with the FileUtils classes. The last release
3
49
  introduced a non-deterministic bug that sometimes caused logging
@@ -34,7 +34,7 @@ module Buildr
34
34
 
35
35
  def checkstyle(configuration_file, format, output_file, source_paths, options = {})
36
36
  dependencies = (options[:dependencies] || []) + self.dependencies
37
- cp = Buildr.artifacts(dependencies).each(&:invoke).map(&:to_s)
37
+ cp = Buildr.artifacts(dependencies).each { |a| a.invoke() if a.respond_to?(:invoke) }.map(&:to_s)
38
38
 
39
39
  args = []
40
40
  if options[:properties_file]
@@ -141,7 +141,7 @@ module Buildr
141
141
  end
142
142
 
143
143
  def extra_dependencies
144
- @extra_dependencies ||= [self.project.compile.dependencies, self.project.test.compile.dependencies]
144
+ @extra_dependencies ||= [self.project.compile.dependencies, self.project.test.compile.dependencies].flatten
145
145
  end
146
146
 
147
147
  protected
@@ -46,7 +46,7 @@ module Buildr
46
46
 
47
47
  def findbugs(output_file, source_paths, analyze_paths, options = { })
48
48
  dependencies = (options[:dependencies] || []) + self.dependencies
49
- cp = Buildr.artifacts(dependencies).each(&:invoke).map(&:to_s).join(File::PATH_SEPARATOR)
49
+ cp = Buildr.artifacts(dependencies).each { |a| a.invoke() if a.respond_to?(:invoke) }.map(&:to_s).join(File::PATH_SEPARATOR)
50
50
 
51
51
  args = {
52
52
  :output => "xml:withMessages",
@@ -79,7 +79,7 @@ module Buildr
79
79
  end
80
80
  if options[:extra_dependencies]
81
81
  ant.auxClasspath do |aux|
82
- Buildr.artifacts(options[:extra_dependencies]).each(&:invoke).each do |dep|
82
+ Buildr.artifacts(options[:extra_dependencies]).each { |a| a.invoke() if a.respond_to?(:invoke) }.each do |dep|
83
83
  aux.pathelement :location => dep.to_s
84
84
  end
85
85
  end
@@ -0,0 +1,77 @@
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
+ module Buildr
17
+
18
+ # Signs the packages using gpg and uploads signatures as part of the upload process.
19
+ #
20
+ # Require explicitly using <code>require "buildr/apg"</code>. This will result in all
21
+ # packages being signed. The user must specify the GPG_USER environment key to identify
22
+ # the key to use and may specify GPG_PASS if the key needs a password to access. e.g.
23
+ #
24
+ # $ GPG_USER=user@example.com GPG_PASSWD=secret buildr clean upload
25
+ #
26
+ module GPG
27
+ class << self
28
+
29
+ def sign_task(pkg)
30
+ raise "ENV['GPG_USER'] not specified" unless ENV['GPG_USER']
31
+ asc_filename = pkg.to_s + '.asc'
32
+ file(asc_filename => [pkg.to_s]) do
33
+ info "GPG signing #{pkg.to_spec}"
34
+
35
+ cmd = []
36
+ cmd << 'gpg'
37
+ cmd << '--local-user'
38
+ cmd << ENV['GPG_USER']
39
+ cmd << '--armor'
40
+ cmd << '--output'
41
+ cmd << pkg.to_s + '.asc'
42
+ if ENV['GPG_PASS']
43
+ cmd << '--passphrase'
44
+ cmd << ENV['GPG_PASS']
45
+ end
46
+ cmd << '--detach-sig'
47
+ cmd << pkg
48
+ trace(cmd.join(' '))
49
+ `#{cmd.join(' ')}`
50
+ raise "Unable to generate signature for #{pkg}" unless File.exist?(asc_filename)
51
+ end
52
+ end
53
+
54
+ def sign_and_upload(project, pkg)
55
+ project.task(:upload).enhance do
56
+ artifact = Buildr.artifact(pkg.to_spec_hash.merge(:type => "#{pkg.type}.asc"))
57
+ artifact.from(sign_task(pkg))
58
+ artifact.invoke
59
+ artifact.upload
60
+ end
61
+ end
62
+ end
63
+
64
+ module ProjectExtension
65
+ include Extension
66
+
67
+ after_define do |project|
68
+ project.packages.each { |pkg| Buildr::GPG.sign_and_upload(project, pkg) }
69
+ project.packages.map { |pkg| pkg.pom }.uniq.each { |pom| Buildr::GPG.sign_and_upload(project, pom) }
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ class Buildr::Project
76
+ include Buildr::GPG::ProjectExtension
77
+ end
@@ -0,0 +1,80 @@
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
+ module Buildr
17
+ module PackageAsNsis
18
+ include Extension
19
+
20
+ class NSISTask < Rake::FileTask
21
+ attr_accessor :nsi
22
+ attr_accessor :values
23
+ attr_accessor :nsis_executable
24
+ attr_accessor :nsis_major_version
25
+
26
+ def initialize(*args) #:nodoc:
27
+ self.nsis_executable = "makensis"
28
+ self.nsis_major_version = 3
29
+ self.values = {}
30
+
31
+ super(*args)
32
+
33
+ enhance do
34
+ info "Calling makensis"
35
+ # We make available one variable to the nsi script:
36
+ # Use it like this: OutFile "${OUTPUT}"
37
+ values = self.values.merge("OUTPUT" => to_s)
38
+
39
+ log_level_param = (self.nsis_major_version == 2 ? "/" : "-") + (verbose ? "V2" : "V0")
40
+ define_prefix = (self.nsis_major_version == 2) ? "/D" : "-D"
41
+
42
+ command = "#{self.nsis_executable} #{log_level_param} #{values.inject([]) { |array, (key, value)| array << "#{define_prefix}#{key}=#{value}"; array }.join(" ")} #{self.nsi}"
43
+ trace command
44
+ system(command) or fail "Error while executing makeNSIS"
45
+ end
46
+ end
47
+
48
+ # :call-seq:
49
+ # with(options) => self
50
+ #
51
+ # Passes options to the task and returns self. Some tasks support additional options, for example,
52
+ # the WarTask supports options like :manifest, :libs and :classes.
53
+ #
54
+ # For example:
55
+ # package(:jar).with(:manifest=>'MANIFEST_MF')
56
+ def with(options)
57
+ options.each do |key, value|
58
+ begin
59
+ send "#{key}=", value
60
+ rescue NoMethodError
61
+ raise ArgumentError, "#{self.class.name} does not support the option #{key}"
62
+ end
63
+ end
64
+ self
65
+ end
66
+ end
67
+
68
+ def package_as_nsis(file_name)
69
+ NSISTask.define_task(file_name)
70
+ end
71
+
72
+ def package_as_nsis_spec(spec)
73
+ spec.merge(:type=>:exe)
74
+ end
75
+ end
76
+ end
77
+
78
+ class Buildr::Project
79
+ include Buildr::PackageAsNsis
80
+ end
@@ -0,0 +1,69 @@
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
+ module Buildr #nodoc
17
+ class Project #nodoc
18
+ class << self
19
+
20
+ alias :original_define :define
21
+
22
+ # Monkey patch the built-in define so that there is a single root directory for
23
+ # all of the generated artifacts within a project hierarchy.
24
+ #
25
+ def define(name, properties = nil, &block) #:yields:project
26
+
27
+ properties = properties.nil? ? {} : properties.dup
28
+
29
+ parent_name = name.split(':')[0...-1]
30
+ parent = parent_name.empty? ? nil : Buildr.application.lookup(parent_name.join(':'))
31
+
32
+ # Follow the same algorithm as in project code
33
+ if properties[:base_dir]
34
+ base_dir = properties[:base_dir]
35
+ elsif parent
36
+ base_dir = File.expand_path(name.split(':').last, parent.base_dir)
37
+ else
38
+ base_dir = Dir.pwd
39
+ end
40
+
41
+ # The top directory is the base directory of the root project
42
+ top_dir = base_dir
43
+ while parent
44
+ top_dir = parent.base_dir
45
+ parent = parent.parent
46
+ end
47
+
48
+ target_dir = "#{top_dir}/target/#{name.gsub(':', '_')}"
49
+ reports_dir = "#{top_dir}/reports/#{name.gsub(':', '_')}"
50
+ target_dir = ::Buildr::Util.relative_path(target_dir, File.expand_path(base_dir))
51
+ reports_dir = ::Buildr::Util.relative_path(reports_dir, File.expand_path(base_dir))
52
+
53
+ properties[:layout] = Buildr::Layout::Default.new unless properties[:layout]
54
+ properties[:layout][:target] = target_dir
55
+ properties[:layout][:reports] = reports_dir
56
+ properties[:layout][:target, :main] = target_dir
57
+
58
+ Project.original_define(name, properties) do
59
+ project.instance_eval &block
60
+ if top_dir == base_dir && project.iml?
61
+ project.iml.excluded_directories << "#{base_dir}/target"
62
+ project.iml.excluded_directories << "#{base_dir}/reports"
63
+ end
64
+ project
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,37 @@
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
+ module Buildr
17
+
18
+ # A simple extension that modifies the project layout to place generated files at the top level.
19
+ # Generated files are typically created below layout[:target, :generated], placing them at the top
20
+ # level makes it easy for IDEs to inspect source in the generated directory while ignoring the dir
21
+ # containing the intermediate artifacts.
22
+ #
23
+ module TopLevelGenerateDir
24
+ module ProjectExtension
25
+ include Extension
26
+
27
+ before_define do |project|
28
+ project.layout[:target, :generated] = "generated"
29
+ project.clean { rm_rf project._(:target, :generated) }
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ class Buildr::Project
36
+ include Buildr::TopLevelGenerateDir::ProjectExtension
37
+ end
@@ -0,0 +1,160 @@
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
+ module Buildr
17
+ module Wsgen
18
+ class << self
19
+
20
+ # :call-seq:
21
+ # java2wsdl(project, classnames, options) => String
22
+ #
23
+ # Uses wsgen to generate wsdl files form annotated, compiled classes. The parameters are
24
+ # * :project -- The project in which the classes are compiled.
25
+ # * :classnames -- Either an array of classnames to convert to wsdl or a map keyed on classnames and service
26
+ # specific customizations provided.
27
+ #
28
+ # Service options include:
29
+ # * :service_name -- The name of the service.
30
+ # * :namespace_url -- The namespace of the service.
31
+ #
32
+ # Method options include:
33
+ # * :output_dir -- The target directory.
34
+ # * :namespace_url -- The default namespace for the services.
35
+ #
36
+ # For example:
37
+ # Buildr::Wsgen.java2wsdl(project, %w(com.example.MyService))
38
+ # Buildr::Wsgen.java2wsdl(project, %w(com.example.MyService com.example.MyOtherService))
39
+ # Buildr::Wsgen.java2wsdl(project, %w(com.example.MyService com.example.MyOtherService), :namespace_url => "http://example.com/services")
40
+ # Buildr::Wsgen.java2wsdl(project, {"com.example.MyService" => {:service_name => 'MiaService', :namespace_url => "http://example.com/it/services"}))
41
+ def java2wsdl(project, classnames, options = {})
42
+ desc "Generate wsdl from java"
43
+ project.task("java2wsdl").enhance([project.compile.target])
44
+
45
+ base_wsdl_dir = File.expand_path(options[:output_dir] || project._(:target, :generated, :wsgen, :main, :wsdl))
46
+ project.iml.main_source_directories << base_wsdl_dir if project.iml?
47
+ project.file(base_wsdl_dir)
48
+ project.task("java2wsdl").enhance([base_wsdl_dir])
49
+
50
+ services = classnames.is_a?(Array) ? classnames.inject({}) {|result, element| result[element] = {}; result} : classnames
51
+
52
+ services.each_pair do |classname, config|
53
+
54
+ name_parts = classname.split('.')
55
+ service_name = config[:service_name] || name_parts.last
56
+ namespace_url = config[:namespace_url] || options[:namespace_url] || "http://#{name_parts[0...-1].reverse.join('.')}"
57
+ wsdl_file = File.expand_path("#{base_wsdl_dir}/META-INF/wsdl/#{service_name}.wsdl")
58
+
59
+ project.file(wsdl_file) do
60
+ mkdir_p File.dirname(wsdl_file)
61
+ cp = Buildr.artifacts(project.compile.dependencies + [project.compile.target]).map(&:to_s).join(File::PATH_SEPARATOR)
62
+
63
+ java_dir = project._(:target, :ignored, :wsgen, :main, :java)
64
+ intermediate_dir = project._(:target, :ignored, :wsgen, :main, :java)
65
+
66
+ rm_rf java_dir
67
+ rm_rf intermediate_dir
68
+ mkdir_p java_dir
69
+ mkdir_p intermediate_dir
70
+
71
+ args = []
72
+ args << "-keep"
73
+ args << "-inlineSchemas" if (options[:inlineSchemas] && ENV_JAVA['java.version'] >= '1.7')
74
+ args << "-wsdl"
75
+ args << "-servicename"
76
+ args << "{#{namespace_url}}#{service_name}"
77
+ args << "-portname"
78
+ args << "{#{namespace_url}}#{service_name}Port"
79
+ args << "-d "
80
+ args << intermediate_dir
81
+ args << "-r"
82
+ args << "#{base_wsdl_dir}/META-INF/wsdl"
83
+ args << "-keep"
84
+ args << "-s"
85
+ args << java_dir
86
+ args << "-cp"
87
+ args << cp
88
+ args << classname
89
+
90
+ command = "wsgen #{args.join(' ')}"
91
+ trace command
92
+ sh command
93
+ if $? != 0
94
+ raise "Problem building wsdl"
95
+ end
96
+
97
+ content = IO.read(wsdl_file).gsub('REPLACE_WITH_ACTUAL_URL', "http://example.com/#{service_name}")
98
+ File.open(wsdl_file, 'wb') { |f| f.write content }
99
+ end
100
+
101
+ project.file(base_wsdl_dir).enhance([wsdl_file])
102
+ project.task("java2wsdl").enhance([wsdl_file])
103
+ end
104
+
105
+ base_wsdl_dir
106
+ end
107
+
108
+ # :call-seq:
109
+ # wsdl2java(project, wsdls, options) => String
110
+ #
111
+ # Uses wsgen to generate java files form wsdls. The parameters are
112
+ # * :project -- The project in which the classes are compiled.
113
+ # * :wsdls -- A hash of wsdl filenames to service configuration.
114
+ #
115
+ # Service options include:
116
+ # * :service_name -- The name of the service.
117
+ # * :package -- The package in which to generate the code.
118
+ #
119
+ # Method options include:
120
+ # * :output_dir -- The target directory.
121
+ # * :target -- The target version for generated source..
122
+ # * :package -- The default package in which to generate the code.
123
+ #
124
+ # For example:
125
+ # Buildr::Wsgen.wsdl2java(project, {_('src/main/wsdl/MyService.wsdl') => {}})
126
+ # Buildr::Wsgen.wsdl2java(project, {_('src/main/wsdl/MyService.wsdl') => {:package => 'com.example'}})
127
+ # Buildr::Wsgen.wsdl2java(project, {_('src/main/wsdl/MyService.wsdl') => {:output_dir => _(:target, :wsdl, :java)}})
128
+ # Buildr::Wsgen.wsdl2java(project, {_('src/main/wsdl/MyService.wsdl') => {}}, :package => 'com.example' )
129
+ def wsdl2java(project, wsdls, options = {})
130
+ desc "Generate java from wsdl"
131
+ project.task("wsdl2java")
132
+
133
+ ws_dir = File.expand_path(options[:output_dir] || project._(:target, :generated, "main/ws"))
134
+ project.file(ws_dir)
135
+ project.task('wsdl2java').enhance([ws_dir])
136
+
137
+ target = options[:target] || '2.1'
138
+
139
+ wsdls.each_pair do |wsdl_file, config|
140
+ pkg = config[:package] || options[:package]
141
+ service = config[:service] || File.basename(wsdl_file, '.wsdl')
142
+ java_file = "#{ws_dir}/#{pkg.gsub('.', '/')}/#{service}.java"
143
+ project.file(java_file) do
144
+ mkdir_p ws_dir
145
+ `wsimport -keep -Xnocompile -target #{target} -s #{ws_dir} -p #{pkg} -wsdllocation META-INF/wsdl/#{service}.wsdl #{wsdl_file}`
146
+ if $? != 0 || !File.exist?(java_file)
147
+ rm_rf java_file
148
+ raise "Problem building webservices"
149
+ end
150
+ end
151
+ project.file(ws_dir).enhance([java_file])
152
+ end
153
+
154
+ project.compile.from ws_dir
155
+ project.iml.main_source_directories << ws_dir if project.iml?
156
+ project.compile.enhance(['wsdl2java'])
157
+ end
158
+ end
159
+ end
160
+ end