问题
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