Add local WAR file as external dependency

I have a project that is acting as an intermediary between two others. This project has multiple flatDir dependencies. One dependency is a simple jar file, which loads with no problems. The other dependency is a war file containing a mid sized web app. Gradle keeps ignoring the war in the local filesystem and attempts to look for it in Maven Central. Interestingly, if I rename the war file to .jar, Gradle will find it but doesn’t load any classes. I still land up with a bunch of package not found errors. Is there a way to add dependencies from a local war file?

Here’s my repo and dep config:

repositories {
  flatDir name: 'coralDependencies', dirs: '../coral/dist'
  flatDir name: 'configurationDependencies', dirs: '../configuration-service/build/libs'
    dependencies {
    testCompile 'junit:junit:4.+'

can you try to specify the extension of your artifact explicity:

compile 'coral:4.1.3@war'

No luck. I did notice that it forces gradle to search for a war.

I found a workaround. This may be due the to structure of my classes folder in the web app. The package folder structure is nested 2 directories deep. If I jar the classes folder only using the package folder structure, it works and pulls in my dependency.

ah you mean you can’t add a “war” file to your classpath? no this doesn’t work out of the box because of what you just described. the layout within the war is not what java expects on it’s classpath.