How can I gather all my project's dependencies into a folder?

I want to put all the jars my project needs into a folder, how can I do that?

If I just want the dependencies unique to my tests (because I put the application dependencies elsewhere) is there a way to do that.

task copyRuntimeLibs(type: Copy) {

into “WebContent/WEB-INF/lib”

from configurations.testRuntime

}

Would pull the application libraries (e.g. hibernate) as well as the test libs (e.g. junit) right?

What I want is just the subset that is unique to the tests (e.g. junit, but NOT hibernate). The idea I am pursuing is to have checked in flatDir repositories that take precedence, but make it easy to add new libs, and keep the test-only stuff segregated from the stuff that gets deployed with the application.

argh cut and paste error… and update/edit post doesn’t seem to work. The above should read

task copyRuntimeLibs(type: Copy) {

into “lib”

from configurations.testRuntime

}

Think this would work:

task copyRuntimeLibs(type: Copy) {
    into "lib"
    from configurations.testRuntime - configurations.runtime
  }

$buildDir/output/lib should be already exist otherwise while copying it may give error

so tell me how to create a folder under $buildDir directory.

$buildDir/output/lib should be already exist otherwise while copying it may give error

so tell me how to create a folder under $buildDir directory.

Why do you keep asking the same question? As I’ve stated before, the directory will be created automatically. If this doesn’t work for you, and you want us to look into your problem, then you’ll have to provide detailed information as outlined in my previous answers to your questions.

i need i thing to know…if a folderis not created sucessfully : new file (“temp”).

what will be the probably errors we can get??

I don’t understand the question. If directories can’t be created, every task that tries to create one may fail. Have you verified that the operating system user under which Gradle is running has the necessary file system permissions?

will check the same. My query is if a directory is not successfully created,gradle build will fail at that point or proceeded to execute other statements/tasks

Usually the build will fail immediately, but ultimately it depends on how the task is implemented.

To gather all the dependencies, you can just “copy” the configuration that represents the dependencies you want.

For example, to copy all the compile time and runtime dependencies you could do something like:

task copyToLib(type: Copy) {
    into "$buildDir/output/lib"
    from configurations.runtime
}

Because the runtime configuration includes all of the compile time dependencies.

1 Like