简体   繁体   中英

ANDROID : Gradle passing in a parameter e.g serverURL

I would like to run Gradle and pass in a server url so that I can have different endpoints for my Android App to look at.

I have followed this post Passing -P parameters to gradle from android studio

But when I deploy it to my pipeline, it can't see the task.

Error:

SYSTEMVSSCONNECTION exists true
[command]C:\Windows\system32\cmd.exe /D /S /C "C:\vstsagent\A1\_work\3\s\ftg\gradlew.bat task setBaseUrl "-Purl=https://blabla.com/api/Graph" jacocoRootReport"
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

> Configure project :app
app: 'annotationProcessor' dependencies won't be recognized as kapt annotation processors. Please change the configuration name to 'kapt' for these artifacts: 'com.github.bumptech.glide:compiler:4.8.0'.

FAILURE: Build failed with an exception.

* What went wrong:
Task 'setBaseUrl' not found in root project 'ftg'.

The Gradle task is in my App build.gradle

def serverUrl = "https://bla.com/api/Graph"

task setBaseUrl(){
    group = "build"
    if(project.hasProperty("url")){
        serverUrl = url
    }
}

I can call the task locally by doing

gradle task setBaseUrl -Purl=https://bla.com/api/Graph

This actually turned out that the pipeline (Azure Devops) was not pulling in the latest Gradle files even though it was building the branch. It was using the Gradle files from Develop but the code from FeatureXYZ

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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