billc.cn
billc.cn

Reputation: 7317

Maven: make sure some code is only included in snapshots (and not release)?

I have some manual tests that needs some helper classes to be included in the WAR generated by Maven. To prevent them from leaking to production, I want to find a way to guarantee they are excluded from the release artifacts.

I already have them in a profile, but there's nothing to prevent anyone from including this profile by mistake when doing a release build.

Upvotes: 2

Views: 35

Answers (1)

I expect you are not in a scenario where EAR files are possible. I would therefore suggest:

  1. Consider your two war files to be totally distinct artifacts generated two different places in your maven build.
  2. Move the test specific classes into a new artifact.
  3. Use overlays to add the test artifact into the release WAR file, generating the test WAR file.

If you have full control of the web servers in question you may also add the test specific classes to the classes provided by the webserver to the application so that on the test web server you have the classes globally defined, and for the production web server they are not present.

Upvotes: 2

Related Questions