Afgan
Afgan

Reputation: 1070

How to exclude some dependency in maven-compiler-plugin?

Guys I need to find out some way to include or exclude dependency while compile my code in maven (maven-compiler-plugin), I don't want to include all dependency in my class path, just few of them which will be used by java class file to be compile.

Is there any to do this ?

Upvotes: 1

Views: 1812

Answers (1)

Neil Mason
Neil Mason

Reputation: 96

You need to set the scope of the dependency to provided. This will make maven assume that the dependencies will be available at run-time. e.g.

<dependency>
  <groupId>group-a</groupId>
  <artifactId>artifact-b</artifactId>
  <version>1.0</version>
  <scope>provided</scope>
</dependency>

It is explained much better here -

Dependency scope

Upvotes: 2

Related Questions