0

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.

andrew
  • 3,929
  • 1
  • 25
  • 38

2 Answers2

1

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.

Stanislav
  • 27,441
  • 9
  • 87
  • 82
  • Thanks. That is what I thought was happening, but I wasn't seeing them in my dependencies directory. It turns out I just needed to have Intellij "refresh all Gradle projects" for them to show up in the dependencies dir. – andrew Oct 22 '15 at 09:25
0

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.

Ignacio Tomas Crespo
  • 3,401
  • 1
  • 20
  • 13