简体   繁体   English

如何将私人签名信息转换为 Kotlin DSL?

[英]How to convert private signing information to Kotlin DSL?

I'm in the process of migrating to Kotlin DSL.我正在迁移到 Kotlin DSL。 I have followed most of the popular blogs out there to set it up initially.我已经按照大多数流行的博客进行了最初的设置。 Now it's time to refactor build.gradle file.现在是重构build.gradle文件的时候了。 I have private signing information logic as shown below.我有如下所示的私人签名信息逻辑。

if (project.hasProperty('propertyfile') && project.hasProperty('key.store')) {

  def keystorePropertiesFile = rootProject.file(project.getProperty('propertyfile'))
  def keystoreProperties = new Properties()
  keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

  signingConfigs {
    release {
        keyAlias keystoreProperties['key.alias']
        keyPassword keystoreProperties['key.alias.password']
        storeFile file(project.getProperty('key.store'))
        storePassword keystoreProperties['key.store.password']
    }
  }
}

I'm not sure how to convert this part to one equivalent to Kotlin DSL.我不确定如何将此部件转换为与 Kotlin DSL 等效的部件。 Looked through related posts and blog around this topic, but couldn't find anything relevant.浏览了有关此主题的相关帖子和博客,但找不到任何相关内容。 Could anyone please help me share some thoughts on how to do this?谁能帮我分享一些关于如何做到这一点的想法?

Please try like below,请尝试如下,

if (project.hasProperty("propertyfile") && project.hasProperty("key.store")) {
    val keystorePropertiesFile = rootProject.file(project.properties["propertyfile"])
    val keystoreProperties = Properties()
    keystoreProperties.load(FileInputStream(keystorePropertiesFile))

    signingConfigs {
        create("release") {
            keyAlias = keystoreProperties["key.alias"] as String
            keyPassword = keystoreProperties["key.alias.password"] as String
            storeFile = file(project.properties["key.store"])
            storePassword = keystoreProperties["key.store.passord"] as String
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM