1

Sonatype's Maven:The Complete Reference says that a compile scoped dependency is on all classpaths and is packaged with the artifact.

Compile is the default scope; all dependencies are compile-scoped if a scope is not supplied. compile dependencies are available in all classpaths, and they are packaged.

I can't see that they are packaged though . . . doesn't this mean that they should be contained in the jar file? If not, what does it mean?

chad
  • 7,369
  • 6
  • 37
  • 56

1 Answers1

1

You are correct. Compiled scope dependencies does not get packaged with the output jar. (with JAR plugin). I think the 'package' refers to the end product (binary executable).

I came across this stackOverflow thread (How can I create an executable jar with dependencies using Maven?). Here they are packaging all the dependencies to build a executable out of Main class. In that case you need all the compile time dependencies in your packaged executable. (since JAVA lazy loads it is not a must, but preferable to have all the compile time dependencies)

Community
  • 1
  • 1
  • 2
    I don't think that the 'package' refers to the end product executable as you describe it. I say this because the "provided" scope, as discussed in the same book, is described as a scope where the dependencies are not packaged into the WAR artifact. The WAR and JAR are both produced during the package phase . . . perhaps the answer is that a Jar package never puts the dependencies in the artifact. This would lead me to conclude that for a JAR's there is NO difference between compile and provided scope . . . how do you feel about that statement ;) – chad Jan 20 '12 at 16:28
  • I think your argument is a valid one. Provided scope only makes sense when the packaging type is war (there can be other packaging types too). – Pradeep Fernando Jan 20 '12 at 17:34