Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
511 views
in Technique[技术] by (71.8m points)

shell - list gradle dependencies for all subprojects

I can query the dependency tree for a Gradle project with ./gradlew -q dependencies.

I can also run the query for the service subproject with ./gradlew service:dependencies.

How can I list the dependencies automatically for all subprojects from the command line without modifying the gradle.properties file?

Thank you in advance.

question from:https://stackoverflow.com/questions/65852292/list-gradle-dependencies-for-all-subprojects

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I believe there’s no built-in way in Gradle to achieve this (without adapting the build configuration) – unless you manually list the dependencies task for all subprojects as in:

./gradlew sub1:dependencies sub2:dependencies sub1:subsub:dependencies

However, if you need this feature often enough, then you could create a shell alias for it. Example in bash (e.g., put this in your ~/.bashrc file):

alias gradle-all-deps='./gradlew dependencies $(./gradlew -q projects 
    | grep -Fe --- Project 
    | sed -Ee "s/^.+--- Project '"'([^']+)'/1:dependencies/"'")'

Then simply call gradle-all-deps from the root project directory.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...