John
John

Reputation: 1360

Gradle multiple project build ClassNotFound on deploy

My web app is build using two projects one that contains the api and second web part. In Eclipse I am able to use classes from project-api in project-web however in deploy I have exception:

Caused by: java.lang.ClassNotFoundException: project.api.TestApi

This is my main build.gradle file:

sourceCompatibility = 1.7

subprojects {
    apply plugin: 'java' 
}

This is build.gradle from api:

apply plugin: 'java'
apply plugin: 'eclipse'

repositories {
    mavenCentral()
}

dependencies {

}

And this is part of my build.gradle from web:

dependencies {
    compile project(':project-api')
...
}

If I go and see web app libraries I can't see anything like project-api.jar. Wham am I doing wrong? UPDATE: It is issue only in eclipse. If I run gradlew war and deploy this manually to tomcat I can deploy it without any issued. project-api.jar is included in war. I tried already to run few times

`gradlew clean cleanEclipse eclipse` 

but it doesn't help. I also try to reimport projects in eclipse but still the same. EDIT: This project is a spring mvc app and I just discovered that when I build war from gradle I am able to deploy war manually without any errors. Issue is only when trying to deploy via eclipse. EDIT: Here is settings.gradle

rootProject.name = 'project'
include 'project-test'
include 'project-web'
include 'project-api'

Upvotes: 1

Views: 1664

Answers (1)

dlee
dlee

Reputation: 78

You need to convert the dependencies of the deployable project to a "faceted project".

Project properties -> Project Facets -> Convert to faceted form...

Then mark each dependency as a "Utility Module".

Upvotes: 1

Related Questions