When should scripts be put in /src/main/scripts (maven standard) and when not?

Steve Cohen picture Steve Cohen · Mar 26, 2015 · Viewed 7.4k times · Source

The Maven Standard Directory Layout says that scripts should be placed in src/main/scripts in a maven project. Besides the advantages of "convention over configuration" are there any other advantages of doing it this way? I have a project that builds an executable jar-with-dependencies using the assembly plugin. There are also some useful scripts that go along with it. Are there any tools that take advantage of this layout in building something else, for example, an archive that includes the jar and these scripts in a reasonable location?

[update] In fact, I would go so far as to say that that putting scripts in src/main/scripts is disadvantageous, as far as use with the maven-assembly plugin is concerned.. It appears that EVERYTHING under /src/main (except src/main/java of course) is copied into the root directory of the jar-with-dependencies, as with src/main/resources, where this is useful. But there is no good reason to have scripts in the jar, although it does no particular harm. If, instead of placing them in src/main/scripts, one places them in src/scripts (analogously to the standard src/assembly, which also isn't included), then they are not copied into the jar and can be copied by a later run of the assembly plugin into a larger archive.

Update: It appears that we must distinguish between runtime scripts that are launched from within the java code and others which launch the jar or do other things. For the former, putting them in src/main/scripts may be appropriate. For the latter, inappropriate.

Update: I entered a bug against the maven documentation about this.

Update: The src/main/scripts directory was removed from the Standard Directory Layout documentation due to it being misleading. (Remnants however still remain in Introduction to POM as it's tied to the project.build.scriptSourceDirectory property.)

Answer