Search code examples
jbossjettygradlenetflix

Gradle - How to extract dependencies from magical cache?


I am looking at a project configured with gradle (netflix/karyon on github), and able to build the war easily ("gradle war"). So far that's as good as it gets.

Where's the war? That's easy enough, just do find . -type f \( -name "*.war" \) ... guess maybe the debug flag would have told me that too?

What's in the war? Only the code for the example project, which is great, nice and lightweight. What you would expect.

Where are the dependencies? Nowhere in site. I do have a pretty good idea that they are in a magical cache somewhere in the hidden gradle dot directory.

How do I get a list of dependencies?

I guess I could 'gradle clean && gradle war > out' and examine the out file for maven.org GETs? I tried "gradle dependencies" and it "built successful" but with no dependencies listed.

I also tried the eclipse plugin, which "worked", creating a .project file. But that's all it did. Did not add anything to the buildpath, and no libs to speak of.

Yes I know it runs because I can run the webapp successfully using the gradle jetty plugin. (Also magic)

So questions:

  1. Is there a gradle command for "figure out dependencies and list them or better yet extract them to a directory"

  2. Why doesn't the eclipse plugin just work? (A) what do I need to do to get the source correctly identified during the eclipsify step, and (B) just a question, how does Eclipse know the magic location and encoding of the jar files?

  3. Is there a jboss plugin for gradle? Or a best practice for migrating a working gradle/jetty project to a working gradle/jboss project that won't cause premature aging?


Solution

  • Looks to me like karyon is a multilevel project and the root project has no dependencies hence you get no output with gradle dependencies gives no output for the root project. So you should probably go with gradle :karyon-core:dependencies to get something more interesting.

    Gradle keeps dependencies in its cache which is located in ~/.gradle/caches/artifacts-<number>/filestore but it's cache for all projects not just a particular one. If you really need to copy all dependencies to a directory you can use a copy similar to this one:

    task copyDeps(type: Copy) {
        from configurations.compile
        into "$projectDir/deps"
    }
    

    And then gradle copyDeps will copy all compile dependencies into deps directory of your project.

    If you insist on having all your dependencies in a lib directory then you need to specify a flat dir repository:

    repositories {
        flatDir {
            dirs 'lib'
        }
    }
    

    Unfortunately I cannot help you with the other two questions.