gradle: how to access the gradle.properties from another project

我的梦境 提交于 2021-01-29 10:32:12

问题


How can I access a gradle.properties from another project?

project1/gradle.properties

project2

Project2 uses the same gradle.properties as Project1. The gradle.properties is in source control, so it is not good idea to put it in user home directory.

The gradle.properties of Project1 contains some credentials I would like to reuse in Project2.

Is there a way to tell Gradle the location of gradle.properties?


回答1:


I don't think its a very good idea to put username & password into a version control system. Your user home is the place to store your credentials. Make sure the users home gradle.properties can only be read by your user processes. On a Unix like operating system this would be:

chmod 600 ~/.gradle/gradle.properties

Furthermore creating dependency between repositories sharing a gradle.properties feels like the wrong approach. This is why Gradle introduced the user home gradle.properties.

But if you still think it is a good idea and/or you don't have any other choice you can set -Dgradle.user.home=project1 and it will pick up the gradle.properties from Project1.



来源:https://stackoverflow.com/questions/50789488/gradle-how-to-access-the-gradle-properties-from-another-project

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!