1

My project has a dependency for which the scope must be set to provided. But when I run the project from my local environment, the scope must be compile. Is there anyway I can define the scope as provided in my pom, but override it when I run from my local environment?

ab11
  • 19,770
  • 42
  • 120
  • 207
  • You can use a Maven property that you override on the command line. There was a question about that, searching... – Tunaki Apr 22 '16 at 19:00
  • Like this http://stackoverflow.com/a/2848792/1743880 or this (better) http://stackoverflow.com/questions/13876165/how-to-override-maven-property-in-command-line. Also http://stackoverflow.com/q/13708738/1743880 – Tunaki Apr 22 '16 at 19:02

1 Answers1

0

I think the best approach would be using maven profiles, in this way you can leave dependency with proper scope in main dependencies tag and re-declare it whithin your "local" profile.

Then you just have to invoke

mvn clean package -Plocal

to run the build triggering local profile and therefore getting the dependency with the modified scope.

In this way standard build is unaffected and you can run all your build locally with all needed changes as well

  • No, not the best approach at all. Profiles are last resort. There is a better way to deal with that without using a profile. – Tunaki Apr 22 '16 at 19:52