Looking for a way to download into cache all the dependencies enumerated in verification-metadata.xml of a Gradle project without actual executing of the tasks requiring those dependencies.
For instance, if the dependencies cache is empty and we run gradle assembly, it would cause downloading artifacts required for "assembly" and all previous tasks. Since some tasks could take several minutes to end, it would be good to avoid the execution itself and just stop after downloading the dependencies.
Related
Is Maven safe for concurrent execution? i.e. can I have several
mvn compile
command running in separate directories at the same time, each of which may be updating $HOME/.m2?
The local repository is NOT safe for concurrent maven instances (see link: https://issues.apache.org/jira/plugins/servlet/mobile#issue/MNG-2802 )
This is a common problem on Continuous Build/Integration systems.
Although at first glace this doesn't affect the 'compile' phase, as the compile phase depends on dependency resolution and the updating of the local repository with downloaded artifacts it is still an issue.
I'm building a big project using Tycho.
Trying to build offline after one online build is successful, but every time I build, it costs me about 20mins to resolve dependencies.
For other reasons, build fails and I have to try many times. The wasted time got me crazy. Is there any way I can skip the "Resolving dependencies" step?
Once you build your project, i.e. you hit the install lifecycle phase, Maven will have the dependencies pasted under your local repository.
Unless you force dependencies reloading, Maven will go for an offline installation since all dependencies are there (that is the main purpose of saving artifacts locally).
That is the second build should be faster and straightforward.
If you are working within Eclipse, make sure it is using a local copy of Maven. Otherwise, the -o option should be fine if no snapshot dependencies are there:
mvn -o
We are new to Gradle and dependency resolution. I am in the process of creating pom.xml files for all our internally-generated artifacts and want to set up a job in our Jenkins server to verify the dependencies are properly defined and not conflicting (i.e. LibA requires x-1.0.jar, LibB requires x-1.1.jar, and AppY requires both LibA and LibB).
As such, I've set up a dummy project in SVN that simply includes a bunch of our internal artifacts as dependencies. Following TTD, I intentionally included some errors in the declarations (i.e. group and name, but not version). Sure enough, those dependencies can't be found.
But when I run this build with gradle (i.e. gradle dependencies) it includes all the failure messages but still says the build succeeded! Not good!
How can I, using Gradle/Jenkins, set up an automated job that will verify all dependencies are found?
There is no built-in task that resolves all dependencies and fails if a dependency isn't found. (IDE tasks are graceful in case of missing dependencies.) But you can easily write your own:
task resolveDependencies {
doLast {
configurations.all { it.resolve() }
}
}
gradle dependencies by design displays Gradle project dependencies reporting (if applicable) if given dependency cannot be resolved (a red text FAILED next to an unresolved dependency). To get an error use some task that depends on resolving dependencies for given configuration(s) like gradle check.
Updated. Gradle is smart in determining if given tasks are required to be executed. Therefor in case there is no source files to compile (compilation requires dependent classes/JARs to be resolved) gradle check can notice that executing compileJava/compileTestJava tasks is not needed (tasks are skipped as up-to-date). You can force it by adding any Java source file into src/main/test (tests requires also production dependencies (from compile configuration)).
This is just a workaround, there is probably a better way to do that (and I hope someone else will present it here).
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?
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.
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.
We use the maven dependency plugin (with maven3) to unzip dependencies at runtime for running a set of tests. However, because the number of dependencies and their size is large it can take upto 30 minutes for the download to finish (not all teams are on LAN). I checked with the maven docs and maven only downloads dependencies that belong to seperate groups in parallel. Is there any way that I can force maven or maybe the maven dependency plugin to download these dependencies in parallel?
Have you already tried to use
mvn -T3.0C phase