Possible Duplicate:
Selecting class by Maven build profile
I have two packages called com.app.util and com.app.mock. The mock package has some or all of the same classes that are implemented also in the util package. Is it possible to select which of the package is in use by the selected maven profile? I would like to use the mock package and the classes in the test profile but not in the release profile. Also I would like that only the classes that are found in the mock package are used and otherwise the build would default to util package classes. If this is not possible, what is the best way to do this kind of class “overriding” during the build?
Thanks!
You can exclude classes from the compilation. But maybe you are better of to separate the dependencies between packages into different maven modules. There would be an API module, a mock module that depends on the API module and a normal implementation module that also depends on the API module. For tests you declare a dependency with scope
teston the mock module. For packaging the application you declare a dependency on the implementation module.