Reputation: 952
I am completely stupified by a compilation error package sg.ncl.service.authentication.data.jpa does not exist
that should not be happening.
I have a Gradle multi-project that I am trying to update to Spring Boot 1.4.0. The repository is located at https://github.com/nus-ncl/services-in-one/tree/DEV-483.
Update: 1: Whenever I use any of following commands:
./gradlew clean build
./gradlew clean assemble check
./gradlew clean assemble test
They would result in the following errors.
D:\git\services-in-one\service-registration\src\test\java\sg\ncl\service\registration\logic\RegistrationServiceTest.java:16: error: package sg.ncl.service.authentication.data.jpa does not exist
import sg.ncl.service.authentication.data.jpa.CredentialsEntity;
^
D:\git\services-in-one\service-registration\src\test\java\sg\ncl\service\registration\Util.java:4: error: package sg.ncl.service.authentication.data.jpa does not exist
import sg.ncl.service.authentication.data.jpa.CredentialsEntity;
^
D:\git\services-in-one\service-registration\src\test\java\sg\ncl\service\registration\Util.java:120: error: cannot find symbol
public static CredentialsEntity getCredentialsEntity() {
^
symbol: class CredentialsEntity
location: class Util
D:\git\services-in-one\service-registration\src\test\java\sg\ncl\service\registration\Util.java:127: error: cannot find symbol
public static CredentialsEntity getInvalidCredentialsEntity() {
^
symbol: class CredentialsEntity
location: class Util
D:\git\services-in-one\service-registration\src\test\java\sg\ncl\service\registration\web\RegistrationControllerTest.java:22: error: package sg.ncl.service.authentication.data.jpa does not exist
import sg.ncl.service.authentication.data.jpa.CredentialsEntity;
^
5 errors
:service-registration:compileTestJava FAILED
But when I use any of the following commands, the compilation error does not occur.
./gradlew clean :service-registration:build
./gradlew clean :service-registration:compileTestJava
./gradlew clean compileTestJava
./gradlew clean check
Update 2: Interestingly, if I use ./gradlew :service-registration:build build
, there are no errors.
I realize that I am unable to come up with a simplified example and apologize for the inconvenience. However, I would appreciate any help I can get on this problem.
Upvotes: 1
Views: 890
Reputation: 116071
As of Boot 1.4, executable jar files store compiled classes in BOOT-INF/classes
. This means that they aren't accessible when simply adding the jar to the classpath. You are packaging your module as an executable jar file and also trying to use it as a dependency. When you use it as a dependency its jar is added to the classpath. If the jar has been repackaged into an executable archive its classes are not visible and the compilation failure occurs.
The simplest change is to disable repackaging of your project's jar:
bootRepackage {
enabled = false
}
Upvotes: 4