pjz
pjz

Reputation: 43067

How do I add another project's build artifacts into a .war using gradle?

Related to How do I add a .properties file into my WAR using gradle? but not quite:

I've got one project, call it 'webclient' that produces:

build/out/WEB-INF/deploy/foo
build/out/client/bar.js
build/out/clientDebug/baz.js

and then I've got a war project, call it 'server' that I'm trying to include the above into the a few different directories by doing:

war {
    from files(project(':webclient').file('build/out/WEB-INF')) {
        into('xxx')
    }
    from files(project(':webclient').file('build/out/client')) {
        into('yyy')
    }
    from files(project(':webclient').file('build/out/clientDebug')) {
        into('zzz')
    }
}

...but that doesn't work. I end up with all the contents under zzz/ ! Am I doing something wrong? bug in gradle (1.0-m6, btw)?

Upvotes: 3

Views: 2231

Answers (1)

Rene Groeschke
Rene Groeschke

Reputation: 28653

I didn't digged deeper in the details, but the files() method seems to cause the problems here. The following workaround should do the trick for you:

war{     
    from (project(':shared').file('build/out/WEB-INF')) {    
        into('xxx')
    }
    from (project(':shared').file('build/out/client')) {
        into('yyy')
    }
    from (project(':shared').file('build/out/clientDebug')) {
        into('zzz')
    }
}

Upvotes: 5

Related Questions