1

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.

1 Answer 1

4

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
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. However, instead of disabling bootRepackage. I removed the apply plugin: 'spring-boot' to the sub-projects.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.