18

Short version of question: Is there a way of telling gradle not to resolve dependencies? I know I can skip single task with -x switch but resolving dependencies isn't performed though some task I guess, to I don't know how to do it.

Long version: Right now I can run tests from gradle with simple 'gradle test' which performs gathering dependencies, building and running tests.. But I'd also like to run tests using gradle on some other machine which can't download dependencies from maven. I thought that I could just perform some packaging which would download all dependencies to some lib folder, and I could expand tests classpath (in that task) to this folder. The problem is, that gradle still tries to contact maven when I run 'gradle myTests'. Is there a way of preventing resolving dependencies for this single task?

asked Jun 23, 2013 at 14:04
1

2 Answers 2

23

There's the --offline flag. Alternatively, you can declare a flatDir rather than a maven repository whenever the build should be run with "local" dependencies.

answered Jun 23, 2013 at 14:09
Sign up to request clarification or add additional context in comments.

3 Comments

Man you are quick! :) Is it correct if I have defined some maven repositories, and then single flatDir (which will be filled with dependencies downloaded from maven with some task), and if I run some common task, it would look for dependencies in maven repositories first, and if I run it with offline flag, it would use the dependencies form my flatDir?
Might work but I'm not sure. Alternatively you could conditionally define either a maven or a flatDir repo, e.g. based on whether some system property (or even --offline) is set.
This solution has one disadvantage - I have to have multiple versions of jars in my flatDir. I understand the reason (dependency resolution and proper version picking is done after gathering all dependencies), but is there some way around this? I'd really like to switch off dependency resolution and just tell gradle what's the classpath for my task.
0

For my use case, my internet is restricted so I would setup dependencies while I can still have full access. And when I'm restricted, go to Preferences, search for Gradle, and check "Offline work".

Of course I'll have to turn it back on whenever new dependencies are added.

answered Jul 23, 2018 at 14:32

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.