klaas1979-ivy4r 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,11 @@
1
+ === 0.4.0 / 2009-06-23
2
+
3
+ * added rake/ivy_extension similar to buildr/ivy_extension to help use ivy4r in rake
4
+
5
+ === 0.3.0 / 2009-06-20
6
+
7
+ * added ant*.jar to gem so that user does not need to have a local ant installation
8
+
1
9
  === 0.2.0 / 2009-06-18
2
10
 
3
11
  * added the Buildr ivy_extension to include ivy in buildr for dependency managment
data/Manifest.txt CHANGED
@@ -26,6 +26,7 @@ lib/ivy/settings.rb
26
26
  lib/ivy/target.rb
27
27
  lib/ivy/targets.rb
28
28
  lib/ivy4r.rb
29
+ lib/rake/ivy_extension.rb
29
30
  test/buildlist/p1/buildfile
30
31
  test/buildlist/p1/ivy.xml
31
32
  test/buildlist/sub/p2/buildfile
data/lib/ivy4r.rb CHANGED
@@ -34,7 +34,7 @@ is
34
34
  }
35
35
  =end
36
36
  class Ivy4r
37
- VERSION = '0.3.0'
37
+ VERSION = '0.4.0'
38
38
 
39
39
  # Set the ant home directory to load ant classes from if no custom __antwrap__ is provided
40
40
  # and the default provided ant version 1.7.1 should not be used.
@@ -0,0 +1,258 @@
1
+ require 'ivy4r'
2
+
3
+ class Rake::Application
4
+ attr_accessor :ivy
5
+ end
6
+
7
+ module Rake
8
+ module Ivy
9
+ class IvyConfig
10
+
11
+ # The extension directory containing ivy settings, the local repository and cache
12
+ attr_accessor :extension_dir
13
+
14
+ # Returns the resolve result
15
+ attr_reader :resolved
16
+
17
+ # Store the current rake application and initialize ivy ant wrapper
18
+ def initialize(application)
19
+ @application = application
20
+ @extension_dir = File.join("#{@application.original_dir}", "#{ENV['IVY_EXT_DIR']}")
21
+ end
22
+
23
+ # Returns the correct ant instance to use.
24
+ def ant
25
+ unless @ant
26
+ @ant = ::Ivy4r.new
27
+ @ant.lib_dir = lib_dir
28
+ @ant.project_dir = @extension_dir
29
+ end
30
+ @ant
31
+ end
32
+
33
+ # Returns the artifacts for given configurations as array
34
+ def deps(*confs)
35
+ configure
36
+ pathid = "ivy.deps." + confs.join('.')
37
+ ant.cachepath :conf => confs.join(','), :pathid => pathid
38
+ end
39
+
40
+ # Returns ivy info for configured ivy file.
41
+ def info
42
+ ant.settings :id => 'ivy.info.settingsref'
43
+ ant.info :file => file, :settingsRef => 'ivy.info.settingsref'
44
+ end
45
+
46
+ # Configures the ivy instance with additional properties and loading the settings file if it was provided
47
+ def configure
48
+ unless @configured
49
+ ant.property['ivy.status'] = status
50
+ ant.property['ivy.home'] = home
51
+ properties.each {|key, value| ant.property[key.to_s] = value }
52
+ @configured = ant.settings :file => settings if settings
53
+ end
54
+ end
55
+
56
+ # Resolves the configured file once.
57
+ def resolve
58
+ unless @resolved
59
+ @resolved = ant.resolve :file => file
60
+ end
61
+ end
62
+
63
+ # Creates the standard ivy dependency report
64
+ def report
65
+ ant.report :todir => report_dir
66
+ end
67
+
68
+ # Publishs the project as defined in ivy file if it has not been published already
69
+ def publish
70
+ unless @published
71
+ options = {:artifactspattern => "#{publish_from}/[artifact].[ext]"}
72
+ options[:pubrevision] = revision if revision
73
+ options[:status] = status if status
74
+ options = publish_options * options
75
+ ant.publish options
76
+ @published = true
77
+ end
78
+ end
79
+
80
+ def home
81
+ @ivy_home_dir ||= "#{@extension_dir}/ivy-home"
82
+ end
83
+
84
+ def lib_dir
85
+ @lib_dir ||= "#{home}/jars"
86
+ end
87
+
88
+ def settings
89
+ @settings ||= "#{@extension_dir}/ant-scripts/ivysettings.xml"
90
+ end
91
+
92
+ def file
93
+ @ivy_file ||= 'ivy.xml'
94
+ end
95
+
96
+ # Sets the revision to use for the project, this is useful for development revisions that
97
+ # have an appended timestamp or any other dynamic revisioning.
98
+ #
99
+ # To set a different revision this method can be used in different ways.
100
+ # 1. project.ivy.revision(revision) to set the revision directly
101
+ # 2. project.ivy.revision { |ivy| [calculate revision] } use the block for dynamic
102
+ # calculation of the revision. You can access ivy4r via <tt>ivy.ant.[method]</tt>
103
+ def revision(*revision, &block)
104
+ raise "Invalid call with parameters and block!" if revision.size > 0 && block
105
+ if revision.empty? && block.nil?
106
+ if @revision_calc
107
+ @revision ||= @revision_calc.call(self)
108
+ else
109
+ @revision
110
+ end
111
+ elsif block.nil?
112
+ raise "revision value invalid #{revision.join(', ')}" unless revision.size == 1
113
+ @revision = revision[0]
114
+ self
115
+ else
116
+ @revision_calc = block
117
+ self
118
+ end
119
+ end
120
+
121
+ # Sets the status to use for the project, this is useful for custom status handling
122
+ # like integration, alpha, gold.
123
+ #
124
+ # To set a different status this method can be used in different ways.
125
+ # 1. project.ivy.status(status) to set the status directly
126
+ # 2. project.ivy.status { |ivy| [calculate status] } use the block for dynamic
127
+ # calculation of the status. You can access ivy4r via <tt>ivy.ant.[method]</tt>
128
+ def status(*status, &block)
129
+ raise "Invalid call with parameters and block!" if status.size > 0 && block
130
+ if status.empty? && block.nil?
131
+ if @status_calc
132
+ @status ||= @status_calc.call(self)
133
+ else
134
+ @status
135
+ end
136
+ elsif status.empty? && block.nil?
137
+ raise "status value invalid #{status.join(', ')}" unless status.size == 1
138
+ @status = status[0]
139
+ self
140
+ else
141
+ @status_calc = block
142
+ self
143
+ end
144
+ end
145
+
146
+ # Sets the publish options to use for the project. The options are merged with the default
147
+ # options including value set via #publish_from and overwrite all of them.
148
+ #
149
+ # To set the options this method can be used in different ways.
150
+ # 1. project.ivy.publish_options(options) to set the options directly
151
+ # 2. project.ivy.publish_options { |ivy| [calculate options] } use the block for dynamic
152
+ # calculation of options. You can access ivy4r via <tt>ivy.ant.[method]</tt>
153
+ def publish_options(*options, &block)
154
+ raise "Invalid call with parameters and block!" if options.size > 0 && block
155
+ if options.empty? && block.nil?
156
+ if @publish_options_calc
157
+ @publish_options ||= @publish_options_calc.call(self)
158
+ else
159
+ @publish_options ||= {}
160
+ end
161
+ else
162
+ if options.size > 0 && block.nil?
163
+ raise "publish options value invalid #{options.join(', ')}" unless options.size == 1
164
+ @publish_options = options[0]
165
+ self
166
+ else
167
+ @publish_options_calc = block
168
+ self
169
+ end
170
+ end
171
+ end
172
+
173
+ # Sets the additional properties for the ivy process use a Hash with the properties to set.
174
+ def properties(*properties)
175
+ if properties.empty?
176
+ @properties ||= {}
177
+ else
178
+ raise "properties value invalid #{properties.join(', ')}" unless properties.size == 1
179
+ @properties = properties[0]
180
+ self
181
+ end
182
+ end
183
+
184
+ # Sets the local repository for ivy files
185
+ def local_repository(*local_repository)
186
+ if local_repository.empty?
187
+ @local_repository ||= "#{home}/repository"
188
+ else
189
+ raise "local_repository value invalid #{local_repository.join(', ')}" unless local_repository.size == 1
190
+ @local_repository = local_repository[0]
191
+ self
192
+ end
193
+ end
194
+
195
+ # Sets the directory to publish artifacts from.
196
+ def publish_from(*publish_dir)
197
+ if publish_dir.empty?
198
+ @publish_from ||= @application.original_dir
199
+ else
200
+ raise "publish_from value invalid #{publish_dir.join(', ')}" unless publish_dir.size == 1
201
+ @publish_from = publish_dir[0]
202
+ self
203
+ end
204
+ end
205
+
206
+ # Sets the directory to create dependency reports in.
207
+ def report_dir(*report_dir)
208
+ if report_dir.empty?
209
+ @report_dir ||= @application.original_dir
210
+ else
211
+ raise "publish_from value invalid #{report_dir.join(', ')}" unless report_dir.size == 1
212
+ @report_dir = report_dir[0]
213
+ self
214
+ end
215
+ end
216
+ end
217
+
218
+
219
+ class Tasks < ::Rake::TaskLib
220
+ def initialize(ivy = nil, &block)
221
+ @ivy = ivy || Rake::Ivy::IvyConfig.new(Rake.application)
222
+ yield @ivy if block_given?
223
+ Rake.application.ivy = @ivy
224
+
225
+ define
226
+ end
227
+
228
+ private
229
+ def define
230
+ namespace 'ivy' do
231
+ task :configure do
232
+ Rake.application.ivy.configure
233
+ end
234
+
235
+ desc 'Resolves the ivy dependencies'
236
+ task :resolve => "ivy:configure" do
237
+ Rake.application.ivy.resolve
238
+ end
239
+
240
+ desc 'Publish the artifacts to ivy repository'
241
+ task :publish => "ivy:resolve" do
242
+ Rake.application.ivy.publish
243
+ end
244
+
245
+ desc 'Creates a dependency report for the project'
246
+ task :report => "ivy:resolve" do
247
+ Rake.application.ivy.report
248
+ end
249
+
250
+ desc 'Clean the local Ivy cache and the local ivy repository'
251
+ task :clean do
252
+ Rake.application.ivy.ant.clean
253
+ end
254
+ end
255
+ end
256
+ end
257
+ end
258
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: klaas1979-ivy4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Klaas Prause
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-19 00:00:00 -07:00
12
+ date: 2009-06-23 00:00:00 -07:00
13
13
  default_executable: ivy4r
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -72,6 +72,7 @@ files:
72
72
  - lib/ivy/target.rb
73
73
  - lib/ivy/targets.rb
74
74
  - lib/ivy4r.rb
75
+ - lib/rake/ivy_extension.rb
75
76
  - test/buildlist/p1/buildfile
76
77
  - test/buildlist/p1/ivy.xml
77
78
  - test/buildlist/sub/p2/buildfile
@@ -83,7 +84,7 @@ files:
83
84
  - test/ivy/test_target.rb
84
85
  - test/ivy/test_targets.rb
85
86
  - test/test_ivy4r.rb
86
- has_rdoc: true
87
+ has_rdoc: false
87
88
  homepage: http://github.com/klaas1979/ivy4r/tree/master
88
89
  post_install_message:
89
90
  rdoc_options: