Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fastlane gradle command - properties not passed

I created a fastlane task for uploading to the Play Store as follows:

  lane :DEPLOY_BETA do

  gradle(task: "clean")

  version_codes = google_play_track_version_codes(
      package_name: "",
      json_key: "play_store_service_account_key.json",
  )

  gradle(
    task: "assemble",
    flavor: "World",
    build_type: "Release",
    properties: { "versionCode" => 100 }
  )

  apk_path = Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]
  supply(
    apk: apk_path,
    json_key: "play_store_service_account_key.json",
    package_name: "",
    track: "beta",
    skip_upload_metadata: true,
    validate_only: true,
    skip_upload_images: true,
    skip_upload_screenshots: true
    )

  end

The problem is that the property versionCode doesn't override the versionCode specified in the flavor(nor defaultConfig). Is this a bug in fastlane? If i don't set the versionCode in build.gradle at all it simply adds no versionCode and fastlane supply will fail.

Can anyone help me out here?

like image 321
Sjaak Rusma Avatar asked Apr 24 '18 11:04

Sjaak Rusma


People also ask

How do you pass system properties in Gradle command line?

Using the -D command-line option, you can pass a system property to the JVM which runs Gradle. The -D option of the gradle command has the same effect as the -D option of the java command. You can also set system properties in gradle. properties files with the prefix systemProp.


1 Answers

I had the same problem. And you have to use them inside your build.gradle, something like this:

versionCode project.hasProperty('versionCode') ? project.property('versionCode') as int : 1 versionName project.hasProperty('versionName') ? project.property('versionName') : "No versionName"

I found this comment inside the original pull request. Seems like gradle don't expose those directly and we need to assign them manually (as per this comment).

like image 195
sebleclerc Avatar answered Sep 28 '22 07:09

sebleclerc