Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to prevent gradle from downloading dependencies

Tags:

gradle

  1. We would like to have a script that does "svn update" and if the depedency.gradle file is in that list of updates, we would like to run a task that ONLY updates dependencies so the developers machine is up to date. What would that task be? I don't see it when running "gradle tasks". Looking for an updatejars or something.

  2. When we build our project, we don't want it to check for jar updates at all!!!! most because that only needs to be done in 2 situations which are #1 above and when someone is updating the dependency.gradle file themselves. For the second thing, they can just run "gradle updatejars" once I know the answer to question #1 that is.

Any ideas? I am just getting into gradle and we really want to keep a consistent environment where when we run our update script, it gets the source code AND the jars in one atomic sweep and we are no longer bothered by checking the repositories every build.

It would be nice to know how to do it by changing the build.gradle file if possible. If not, is there a command line option? (The build.gradle obviously would give me a command line option which is why I prefer that method as I could say compile does not depend on downloading jars).

like image 224
Dean Hiller Avatar asked Apr 14 '12 19:04

Dean Hiller


People also ask

Does Gradle download dependencies every time?

First of all, Gradle has a local cache to store downloaded dependencies. If your new project requires some dependency, which was already used by some other project and stored in cache, then no need to download them again.

Where does Gradle download dependencies from?

Gradle declares dependencies on JAR files inside your project's module_name /libs/ directory (because Gradle reads paths relative to the build.gradle file). This declares a dependency on version 12.3 of the "app-magic" library, inside the "com.example.android" namespace group.

Why does Gradle download every time?

Basically it downloads the Gradle build files for your current project according to its version and this whole work is done by your gradle wrapper which actually looks towards the basic requirement for your project and downloads the files according to that so whenever you are going to use any another projects of same ...

Why does Gradle sync every time?

It uses much of internet bandwidth and takes time to import or create a project.


1 Answers

Regarding the second question. As far as I understand, Gradle will not attempt to do remote lookups or try to download the jar if it is already in the local cache. This should be true for jars declared with a static version, e.g. testCompile 'junit:junit:4.10'.

If you have dynamic versions, e.g. 1.+ or 1.0-SNAPSHOT, etc. then Gradle has to do a check every now and then. You can fine tune the cache expiry for such dependencies.

To make sure Gradle does not do remote lookups you can also use --offline option. See this doc for details.

With regard to svn update, you have at least 3 options:

  1. Try to use an SvnKit plugin for Gradle

  2. Use the ant svn task (here's how to do svn checkout)

  3. Run external command from Gradle. Use the ExecPlugin or just implement it yourself using Groovy API.

like image 161
rodion Avatar answered Nov 13 '22 14:11

rodion