StormeHawke
StormeHawke

Reputation: 6207

Gradle: How to add resource (not lib) jars to root of war?

In the continuing saga of attempting to migrate from an insanely complicated ant build to gradle - We have some resource jar files for 'javahelp' that I'm generating. They contain no classes. I need to add the output of the project that creates these resource jars to the root of my war (not to WEB-INF/lib).

My attempted solution:

apply plugin: 'war'

//Move files into position for the mmplEar project
task stage(overwrite: true, dependsOn: war) << {
}

war {
    from project(':help:schedwincli').buildDir.absolutePath + '/libs'
    include '*.jar'
}

dependencies {
    //Ensure the jar is generated, but we don't want it in the lib dir
    providedCompile project(':help:schedwincli')
}

This compiles and runs, and the :help:schedwincli does run and generate the needed jar, however when I open up my war file, the expected jar is not present anywhere in the war. Suggestions?

Edit

I made the changes suggested by Peter below, but now I get this error:

Could not find property 'resources' on configuration container.

This is where it says it's failing:

from '../../runtime', /*Fails on this line*/
    '../../runtime/html',
    '../../runtime/html/Jboss',
    '../../runtime/props',
    '../../runtime/props/Jboss',
    '../../scripts',
    '../../../proj/runtime',
    '../../../proj/runtime/html',
    '../../../proj/runtime/html/Jboss',
    '../../../proj/runtime/props',
    '../../../proj/runtime/props/Jboss',
    configurations.resources
include '*.css'
include '*.gif'
include '*.html'
include '*.jpg'
include '*.jnlp'
include '*.props'
include '*.properties'
include 'jsps/**'
include '*.jar'
include 'log4j/**'
include 'setupLdap.cmd'
include 'spreadsheets/*.xlsx'

Upvotes: 1

Views: 3103

Answers (1)

Peter Niederwieser
Peter Niederwieser

Reputation: 123900

You want something like:

configurations {
    resources 
}

dependencies {
    resources project(':help:schedwincli')
}

war {
    from configurations.resources
}

Upvotes: 5

Related Questions