Add local WAR file as external dependency


(James Herrera) #1

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 {
  mavenCentral()
  flatDir name: 'coralDependencies', dirs: '../coral/dist'
  flatDir name: 'configurationDependencies', dirs: '../configuration-service/build/libs'
}
    dependencies {
  compile
'javax.servlet:servlet-api:2.5',
           'com.fasterxml.jackson.core:jackson-databind:2.1.3',
           'commons-logging:commons-logging:1.1.3',
           ':coral:4.1.3',
           ':configuration-service:1.0.0-SNAPSHOT'
    testCompile 'junit:junit:4.+'
}

(René Groeschke) #2

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

compile 'coral:4.1.3@war'

(James Herrera) #3

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


(James Herrera) #4

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.


(René Groeschke) #5

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.