How to compile against classes from a war


(Dan Stine) #1

I have project A that generates a WAR. I have project B that needs to compile against the classes in project A. I cannot figure out how to do this.

I can retrieve the WAR:

dependencies {
    compile 'mygroup:project-a:1.0.4-SNAPSHOT@war'
}

but compilation fails on the classes imported from that WAR.

Is there a way to get WEB-INF/classes on the compile classpath? Or do I have to publish a JAR from project A, in addition to the WAR, and just use that?

Thanks, Dan


(Peter Niederwieser) #2

Your code puts the War on the compile class path, but a Java compiler doesn’t know anything about a War. Unless you want to write code to explode the War and pass its classes and libs to the compiler (which I don’t recommend), you’ll have to publish a Jar.


(Dan Stine) #3

Okay, thanks for the info.