I'm completely new to gradle. I've put the following build.gradle together as a means of seeing how dependencies get pulled from a flatDir repository. The 'localrepo' directory contains two files 'a.txt', and 'b.txt' and nothing else. When I run 'gradle dependencies' I get failures:
:dependencies
------------------------------------------------------------
Root project
------------------------------------------------------------
copytest
+--- :a.txt: FAILED
\--- :b.txt: FAILED
BUILD SUCCESSFUL
Total time: 5.506 secs
Why?
Here's my build.gradle:
configurations {
copytest
}
repositories {
flatDir name: 'localRepository', dirs: 'localrepo'
}
dependencies {
copytest ':a.txt'
copytest ':b.txt'
}
task copyTask(type: Copy) {
from configurations.copytest
into 'result'
}
flatDir(configureClosure) Adds an configures a repository which will look for dependencies in a number of local directories. flatDir(args) Adds a resolver that looks into a number of directories for artifacts. The artifacts are expected to be located in the root of the specified directories.
Don't use flatDir!! Instead, use the Maven repository directory layout for your jars, sources jars, javadoc jars and poms. You can then configure a local directory as a maven repository in Gradle and your IDE will automatically find the javadocs and sources.
Gradle adds the dependency to the build output only, for use during runtime. That is, it is not added to the compile classpath. This configuration is deprecated (it's available in AGP 1.0-4.2).
The location for storing modules is called a repository. By specifying the repositories for a project, Gradle can find and retrieve modules. Repositories can be in different forms, such as a local directory or a remote repository.
A flatDir
repo uses a simple heuristic to turn the dependency's module name into the filename to be searched for. If you specify :a.txt
, Gradle will search for a.txt.jar
, or, if you have project.version
set, also for a.txt-theVersion.jar
. To add arbitrary files to a configuration, instead of declaring a flatDir
repo, you can use copytest files("some/path")
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With