Throw maven exception

I want to eliminate one dependency when I deploy, I need it when I use the jar locally, but it shouldn't be in the deployed jar. is there a way to do this?

+2


source to share


3 answers


<profile>
    <id> localProfile </id>
    <activation>
        <property>
            <name>! deploy </name>
        </property>
    </activation>
    <dependencies>
        <dependency>
            ...
        </dependency>
    </dependencies>
</profile>

when i run it with



mvn deploy -D deploy = 0

jar does not have this dependency

+1


source


It depends on what you mean by "using the jar locally".

If you mean that you don't want the jar to be included in any packages, you can set the scope to a dependency provided

. This scope is only available in the compilation and test class, and is not transitive. Dependency on this area will not be included in the war / ears.



<dependency>
  <groupId>some.groupid</groupId>
  <artifactId>my-dependency</artifactId>
  <version>1.0.0</version>
  <scope>provided</scope>
</dependency>

      

If you mean that you do not want the jar to be added to a distribution built with a build plugin, you can customize the build to exclude a specific dependency.

+3


source


Perhaps a good solution is to install the dependency with <scope>provided</scope>

. This way the dependency will not be deployed.

However, locally, you will need to add the dependency to your classpath ...

0


source







All Articles