Maven scopes vs. Gradle configurations

Click for: original source

Andres Amiray blog post about comparison of Maven and Gradle. Both Maven and Gradle are popular choices when it comes to building Java projects. These tools share common traits but there are some key differences that make you more productive depending on a particular scenario.

Scopes and configurations are used by each tool to define dependencies and how they affect different classpaths, such as the compilation and runtime classpaths.

Maven defines 6 scopes and Gradle on the other hand defines a few more. Article then explains the behaviour for each scope in detail, e.g.

  • Compile - dependencies are available in all classpaths of a project
  • Provided - indicates you expect the JDK or a container to provide the dependency at runtime
  • Runtime - dependency is not required for compilation, but is for execution
  • Test - dependency available for the test compilation and execution phase only
  • System - you have to provide the JAR which contains it explicitly
  • Import - dependency to be replaced with the effective list of dependencies in the specified POM’s section

The article also pays specific attention to subtle difference between production scopes and test scope and why it could be a problem. In the article you can find plenty of configuration files and configuration comparison for both tools. Interesting!

[Read More]

Tags scala programming