Several configurations for the task in my build.gradle

I am using this awesome Gradle plugin to compile my iOS project.

As per the documentation, my build.gradle looks like this:

buildscript {
  repositories {
    maven {
      url('http://openbakery.org/repository/')
    }
    mavenCentral()
  }
  dependencies {
    classpath group: 'org.openbakery', name: 'xcodePlugin', version: '0.9.+'
  }
}
apply plugin: 'xcode'

task wrapper(type: Wrapper) {
  gradleVersion = '1.12'
}


xcodebuild {
  workspace = 'WORKSPACE'
  sdk = 'iphoneos'
  target = 'TARGET'

  signing {
    mobileProvisionURI = 'URI'
    certificateURI = 'URI'
    certificatePassword = 'PASSWORD'
  }
  scheme = 'SCHEME'
  configuration = 'CONFIGURATION'
}

      

How can I manage multiple configurations for my xcodebuild task? I would like something like

...
xcodebuild-staging {
      workspace = 'STAGING_WORKSPACE'
      sdk = 'iphoneos'
      target = 'STAGING_TARGET'

      signing {
        mobileProvisionURI = 'URI'
        certificateURI = 'URI'
        certificatePassword = 'STAGING_PASSWORD'
      }
      scheme = 'STAGING_SCHEME'
      configuration = 'STAGING_CONFIGURATION'
    }

xcodebuild-production {
      workspace = 'PRODUCTION_WORKSPACE'
      sdk = 'iphoneos'
      target = 'PRODUCTION_TARGET'

      signing {
        mobileProvisionURI = 'PRODUCTION_URI'
        certificateURI = 'PRODUCTION_URI'
        certificatePassword = 'PRODUCTION_PASSWORD'
      }
      scheme = 'PRODUCTION_SCHEME'
      configuration = 'PRODUCTION_CONFIGURATION'
    }
...

      

I tried several things: create a new task that calls xcodebuild.execute () or extends xcodebuild. None of them worked the way I wanted. I ran out of different build.gradle files ...

Do you know how to do it?

+3


source to share


2 answers


After a quick exploration of the source, it seems like you don't need to (and it seems a little odd - such a plugin should allow the user to create multiple schemas). I suggest you contact the author.



0


source


It's possible! Have you tried adding the issue type as a property? something like...

task xcodebuild-staging (type: org.openbakery.XcodeBuildTask) {
  workspace = 'STAGING_WORKSPACE'
  sdk = 'iphoneos'
  target = 'STAGING_TARGET'

  signing {
    mobileProvisionURI = 'URI'
    certificateURI = 'URI'
    certificatePassword = 'STAGING_PASSWORD'
  }
  scheme = 'STAGING_SCHEME'
  configuration = 'STAGING_CONFIGURATION'
}

task xcodebuild-production (type: org.openbakery.XcodeBuildTask){
  workspace = 'PRODUCTION_WORKSPACE'
  sdk = 'iphoneos'
  target = 'PRODUCTION_TARGET'

  signing {
    mobileProvisionURI = 'PRODUCTION_URI'
    certificateURI = 'PRODUCTION_URI'
    certificatePassword = 'PRODUCTION_PASSWORD'
  }
  scheme = 'PRODUCTION_SCHEME'
  configuration = 'PRODUCTION_CONFIGURATION'
}

      



It depends on how the plugin is written, but you can override tasks like this if the significant configuration provided by the plugin does not exist. I found that plugins can also be extended https://docs.gradle.org/current/userguide/custom_plugins.html#custom_plugins, but this is more complicated.

0


source







All Articles