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


(Gradle FAQ Bot) #1

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


(gheck) #2

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.


(gheck) #3

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

}


(Stig Kleppe-Jørgensen) #4

Think this would work:

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

(Ananta Jena) #5

$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.


(Ananta Jena) #6

$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.


(Peter Niederwieser) #7

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.


(Ananta Jena) #8

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

what will be the probably errors we can get??


(Peter Niederwieser) #9

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?


(Ananta Jena) #10

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


(Peter Niederwieser) #11

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


(Luke Daley) #12

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.