简体   繁体   中英

Use Gradle to download external dependencies without compiling?

Can I use Gradle to download Java external dependencies without compiling my source code?

The external dependencies have made big changes to package structure since I created my code. I would like to use Gradle to download the new versions and then fix my import statements using the tools in my IDE.

Gradle build seems to be failing without downloading the dependencies because it can't compile my source.

Thanks.

You can't download your dependencies with some custom task, which aims just for that. Dependencies are downloaded on demand, that means, that if you have changed dependencies versions in your gradle build script and then call the task, which have to compile your sources, all the dependencies will be downloaded. Sure, if the imports get wrong, your build will fail and you'll need to update your imports.

So, in other words, if you've changed dependencies versions and then called some task, that compile your sources, your dependencies will be downloaded automatically before the compilation start.

Here is a gradle task to download manually all dependency sources https://gist.github.com/ngtignacio/d0720b7a565729037d0fef1936655793

I adapted the script at https://stackoverflow.com/a/58748741/2439283

It should download all available sources even if the project does not compile.

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