When you do a maven build you might have seen the jars coming along with your mule Archive.
But is the addition of all the jar dependencies useful while you create your zip or it should depend on the runtime environment?
The simple answer to this question is yes it should depend on the runtime environment in which you are running your mule application, but how do we specify the different attributes to add/remove the zip files, the answer to this lies in POM file.
In your pom.xml you have the option to specify the scopes for the dependencies, below are some of the popular scopes which can be used to make sure only the essential jars are added to your mule archive and which would, in turn, help you to –
1. Make sure you use the latest/platform compatible jars for your application.
2. Reduction in size/de-duplication of the jars for the application.
3. Making the versioning more consistent.
Below are some of the Scopes of the mule in maven –
- Compile Scope(Default Scope) – The compile scope is the default scope in the maven for mule, it means that the dependency is required all the time, dependency needs to be included in the application package. The best example of this would be external libraries used by the application.
- Runtime – This scope indicates that the dependencies are only required at runtime and not for the compilation. Example for this type of dependency is log4j
- Test – This scope indicates that the dependency is only required while running the tests.
- e.g. unit test framework libraries.
- Provided – This means that the dependency would be provided by the container or the JDK at the runtime and we need not specify the jars explicitly with our archive.
- e.g. mule cloud hub provides various jars which need not be included with our application.
- libraries stored in $MULE_HOME/conf/lib/opt