Class: Xcode::Buildspec::TaskBuilder
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Xcode::Buildspec::TaskBuilder
- Includes:
- Rake::DSL
- Defined in:
- lib/xcode/buildspec.rb
Instance Method Summary collapse
-
#before(&block) ⇒ Object
A block to run before each builder invocation.
-
#build_number(&block) ⇒ Object
A block to generate the build number.
-
#builder ⇒ Object
Internally used to lazily instantiate the builder given the properties that have been set.
-
#deploy(type, args = {}) ⇒ Object
Set a deployment target.
-
#generate_rake_tasks ⇒ Object
Create a set of rake tasks for this buildspec.
-
#identity(identity) ⇒ Object
Set’s the identity to use to sign the package.
-
#initialize ⇒ TaskBuilder
constructor
A new instance of TaskBuilder.
-
#keychain(path, password = nil) ⇒ Object
Configure a keychain to use (optional).
- #notify(type, args = {}) ⇒ Object
-
#platform(name, version = nil) ⇒ Object
Specify the platform to build for.
-
#profile(profile) ⇒ Object
Set the profile (i.e. .mobileprovision) to use.
- #project_name ⇒ Object
-
#use(filename, args = {}) ⇒ Object
Use the given project/workspace file.
Constructor Details
#initialize ⇒ TaskBuilder
Returns a new instance of TaskBuilder.
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/xcode/buildspec.rb', line 70 def initialize @before = lambda {|builder| return nil } @deployments = [] @build_number = lambda do = Time.now.strftime("%Y%m%d%H%M%S") ENV['BUILD_NUMBER']||"SNAPSHOT-#{Socket.gethostname}-#{}" end # @profile = "Provisioning/#{name}.mobileprovision" end |
Instance Method Details
#before(&block) ⇒ Object
A block to run before each builder invocation
If supplied, the block will be yielded the builder object just before the invocation of clean/build/package
102 103 104 |
# File 'lib/xcode/buildspec.rb', line 102 def before &block @before = block end |
#build_number(&block) ⇒ Object
A block to generate the build number
This is optional, by default it will use ENV or create a snapshot filename based on the hostname and time
114 115 116 |
# File 'lib/xcode/buildspec.rb', line 114 def build_number &block @build_number = block end |
#builder ⇒ Object
Internally used to lazily instantiate the builder given the properties that have been set.
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/xcode/buildspec.rb', line 186 def builder return @builder unless @builder.nil? raise "profile must be defined" if @profile.nil? raise "project/workspace must be defined" if @filename.nil? begin project = Xcode.project @filename @builder = project.target(@args[:target]).config(@args[:config]).builder rescue workspace = Xcode.workspace @filename @builder = workspace.scheme(@args[:scheme]).builder rescue raise "You must provide a project or workspace" end raise "Could not create a builder using #{@args}" if @builder.nil? unless @platform.nil? builder.sdk = @platform.sdk end unless @identity.nil? builder.identity = @identity end unless @keychain.nil? keychain = Xcode::Keychain.new @keychain[:path] keychain.unlock @keychain[:password] unless @keychain[:password].nil? builder.identity = keychain.identities.first builder.keychain = keychain end builder.profile = @profile @before.call builder @builder end |
#deploy(type, args = {}) ⇒ Object
Set a deployment target.
This will configure a set of deploy: targets that will send the .ipa to various services (testflight, s3, ftp, sftp, etc)
170 171 172 |
# File 'lib/xcode/buildspec.rb', line 170 def deploy type, args = {} @deployments << {:type => type, :args => args} end |
#generate_rake_tasks ⇒ Object
Create a set of rake tasks for this buildspec
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/xcode/buildspec.rb', line 234 def generate_rake_tasks require 'socket' # namespace project_name.downcase do desc "Clean #{project_name}" task :clean do builder.clean end desc "Fetch dependencies for #{project_name}" task :deps do builder.dependencies end desc "Build #{project_name}" task :build => [:clean, :deps] do builder.config.info_plist do |info| info.version = @build_number.call info.save end builder.build end desc "Test #{project_name}" task :test => [:deps] do builder.test end desc "Package (.ipa & .dSYM.zip) #{project_name}" task :package => [:build, :test] do builder.package end namespace :deploy do @deployments.each do |deployment| desc "Deploy #{project_name} to #{deployment[:type]}" task deployment[:type] => [:package] do builder.deploy deployment[:type], deployment[:args] end end desc "Deploy #{project_name} to all" task :all => [:package]+(@deployments.map{|k,v| k[:type]}) do puts "Deployed to all" end end end |
#identity(identity) ⇒ Object
Set’s the identity to use to sign the package
This should be the name of the identity in your keychain, such as ‘iPhone Distribution: My Name’
149 150 151 |
# File 'lib/xcode/buildspec.rb', line 149 def identity identity @identity = identity end |
#keychain(path, password = nil) ⇒ Object
Configure a keychain to use (optional)
If specified, the keychain at the given path will be unlocked during the build and the first identity will be set on the builder
127 128 129 |
# File 'lib/xcode/buildspec.rb', line 127 def keychain path, password = nil @keychain = {:path => path, :password => password} end |
#notify(type, args = {}) ⇒ Object
175 176 177 |
# File 'lib/xcode/buildspec.rb', line 175 def notify type, args = {} @notifications << {:type => type, :args => args} end |
#platform(name, version = nil) ⇒ Object
Specify the platform to build for
137 138 139 |
# File 'lib/xcode/buildspec.rb', line 137 def platform name, version=nil @platform = Xcode::Platforms.find name, version end |
#profile(profile) ⇒ Object
Set the profile (i.e. .mobileprovision) to use
157 158 159 |
# File 'lib/xcode/buildspec.rb', line 157 def profile profile @profile = profile end |
#project_name ⇒ Object
227 228 229 |
# File 'lib/xcode/buildspec.rb', line 227 def project_name builder.product_name end |
#use(filename, args = {}) ⇒ Object
Use the given project/workspace file
This must be provided.
89 90 91 92 |
# File 'lib/xcode/buildspec.rb', line 89 def use filename, args={} @filename = filename @args = args end |