Issue
I'm trying to use maven package
on a maven project that contains source code, that's located on my local machine. I've added them as dependencies in my IDE (In my case IntelliJ), however whenever I try to build my project, it gives me the error message
/location/to/package/and/Class.java:[##,##] error: cannot find symbol
symbol: variable SomeRandomClass
location: class SomeClassThatTheVariableWasLocatedIn
What I'm asking is if there's a way of making a specific package e.g. my.package
and all of its contents from (including sub packages), from generating errors.
PS: The package that needs to be excluded should be the one from the project that hasn't been added as a dependency in Maven.
Solution
There is no way to do that.
It is the Java compiler (rather than Maven) that is complaining about the missing symbols. It simply cannot compile the classes that refer to the missing packages. The Java language does not allow this. The missing symbols have to be available when you compile your code.
You have three choices:
Create a new maven artifact to contain the "missing" packages, and add dependencies to the other modules that require them.
Move the "missing" packages into an existing module.
Don't attempt to build the classes with the missing dependencies.
Answered By - Stephen C
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)