Reputation: 451
I have a WEBAPP MULTI PROJECT Gradle build with the below structure. I'm also using SPRING FRAMEWORK. I can't get the webapp to run in Jetty though as my bean files (dao-beans.xml) cannot be found. If I copy the bean files to the webapp build dir they're found but then Spring fails to instantiate my classes as it cannot find the classes on the classpath. What am I doing wrong?
+-- build.gradle
+-- dao-impl
¦ +-- src
¦ +-- main
¦ ¦ +-- java
¦ ¦ +-- resources
¦ ¦ +-- dao-beans.xml
¦ +-- test
¦ +-- java
+-- gradle.properties
+-- presenter
¦ +-- build.gradle
¦ +-- src
¦ +-- main
¦ ¦ +-- java
¦ ¦ +-- resources
¦ ¦ ¦ +-- beans.xml
¦ ¦ +-- webapp
¦ ¦ +-- WEB-INF
¦ ¦ +-- web.xml
¦ +-- test
¦ +-- java
+-- settings.gradle
Presenter's build.gradle:
apply plugin: "jetty"
apply plugin: "war"
jettyRun {
httpPort = 8080
scanIntervalSeconds = 3
}
War structure:
├── META-INF
│ └── MANIFEST.MF
└── WEB-INF
├── classes
│ ├── beans.xml
│ ├── *.classes
│ └── logback.xml
├── lib
│ ├── *.jar
└── web.xml
Upvotes: 3
Views: 1504
Reputation: 4631
You need to make your 'dao-impl' a free standing Java project (so the top level project builds it).
New file dao-impl/build.gradle
apply plugin: "java"
Instruct the top level project about the sub-project.
Then in existing presenter/build.gradle file add a dependency on that other project:
dependencies {
...
compile project(':dao-impl').sourceSets.main.output
}
This should cause the JAR to be emitted in the deployed Jetty in the usual place WEB-INF/lib/dao-impl-x.y.z.jar (it might be better to do away with the .sourceSets.main.output if possible, but both forms should work)
Upvotes: 1