user1254460
user1254460

Reputation: 1

Different POM Files for production environment

Team here have built the project in test environment and hence pom files have jars used for testing as dependencies.

However, same pom file is being used in production and hence the Jars used for testing are getting into production which is not a good practice.

Question - Is it not possible to have a pom files with the testing jars not listed as dependencies and build the code?

Team here said that it is not possible...

Upvotes: 0

Views: 710

Answers (2)

khmarbaise
khmarbaise

Reputation: 97379

Are they aware of the difference between src/test/resources and src/main/resources (and src/test/java and src/main/java) which can be used to separate test and production configuration. For this you use the same pom file. Furthermore the dependencies should be defined if they are used for test (test) or if the are used for production code.

Upvotes: 0

lwe
lwe

Reputation: 2625

Set a <scope> for the dependency, for junit for example we add a dependency like:

<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.10</version>
  <scope>test</scope>
</dependency>

From the maven docs http://maven.apache.org/pom.html#Dependencies

test - this scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases.

Upvotes: 2

Related Questions