including dependencies in an archive

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

including dependencies in an archive

Phil Messenger
hello,

I'm attempting to include my projects dependencies in a Zip archive (this is a child project). I've got the following stanza in my build.gradle file:

dists
{
        tar {
                tarFileSet(dir: "ImageTranscoderServer/src/bin") {
                        include('*.sh')
                        prefix = '/bin'
                }
                files(dependencies.resolve("runtime"))
        }
}

now it seems that this closure is evaluated immediately, which means that the dependencies.resolve call is executed before the dependencies are actually set, so I just get a blank list of dependencies.

How should I be including my dependencies in a bundle/archive?

Phil.
Reply | Threaded
Open this post in threaded view
|

Re: including dependencies in an archive

Phil Messenger
Ah, so I've managed to get this working, kind of. The problem I'm hitting now is that when I resolve the dependencies I get a failure on a sibling project:

dependencies {
        addMavenStyleRepo('miniweb_proxy', 'http://10.0.0.4:9999/repository')
        compile "log4j:log4j:1.2.12"
        compile "dom4j:dom4j:1.6.1"
        compile "org.apache.mina:mina-core:1.1.6"
        compile "org.slf4j:slf4j-log4j12:1.5.0"
        compile "org.springframework:spring-core:2.5"
        compile "miniweb:Utils:1.0.9"
        compile project(":ImageTranscoderCore")
        compile "commons-httpclient:commons-httpclient:3.1"
}

dists
{
        dependsOn('libs')
        println project.dependencies.resolve('compile').dump()

        tar {

        println project.dependencies.resolve('compile');
                tarFileSet(dir: "ImageTranscoderServer/src/bin") {
                        include('*.sh')
                        prefix = '/bin'    
                }
        }
}

dies on the second line of the dists closure (println project...).

:: problems summary ::
:::: WARNINGS
                module not found: miniweb#ImageTranscoderCore;1.0.1-SNAPSHOT

        ==== clientModule: tried

        ==== build-resolver: tried

          /home/phil/workspaces2/ImageTranscoderRoot/.gradle/build-resolver/miniweb/ImageTranscoderCore/1.0.1-SNAPSHOT/ivys/ivy.xml

          -- artifact miniweb#ImageTranscoderCore;1.0.1-SNAPSHOT!ImageTranscoderCore.jar:

          /home/phil/workspaces2/ImageTranscoderRoot/.gradle/build-resolver/miniweb/ImageTranscoderCore/1.0.1-SNAPSHOT/jars/ImageTranscoderCore.jar

        ==== miniweb_proxy_poms: tried

          http://10.0.0.4:9999/repository/miniweb/ImageTranscoderCore/1.0.1-SNAPSHOT/ImageTranscoderCore-1.0.1-SNAPSHOT.pom

          -- artifact miniweb#ImageTranscoderCore;1.0.1-SNAPSHOT!ImageTranscoderCore.jar:

          http://10.0.0.4:9999/repository/miniweb/ImageTranscoderCore/1.0.1-SNAPSHOT/ImageTranscoderCore-1.0.1-SNAPSHOT.jar

        ==== miniweb_proxy_jars: tried


:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS

Build aborted abnormally.  Run with -s option to get stacktrace. Run with -d option to get all debug info including stacktrace.
Exception is:
org.gradle.api.GradleException: Not all dependencies could be resolved! Buildscript=build_gradle in line(s): 24 22 18
Reply | Threaded
Open this post in threaded view
|

Re: including dependencies in an archive

Phil Messenger
Phil Messenger wrote
Ah, so I've managed to get this working, kind of. The problem I'm hitting now is that when I resolve the dependencies I get a failure on a sibling project:
...
                module not found: miniweb#ImageTranscoderCore;1.0.1-SNAPSHOT

        ==== clientModule: tried

        ==== build-resolver: tried
Ok, so it turns out that to get this to work I need to setup a closure that gets executed when the task is executed, not when the project file is evaluated.

dists
{

        dependsOn 'libs'

        tar().doFirst { task ->
                                task.configure {
                                                                dependency code here
                                }
                             }
}

does the trick.