4

I am trying to create a basic archetype with maven , for the moment I know how to create the architecture with mvn archetype:generate , however I would like toadd dependencies throughout mvn console.

Is it possibile to add the dependencies from the command line not from the pom file?

I would like to make this because an interesting option is to create a simple architecture with .bat file.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
jc1992
  • 644
  • 3
  • 10
  • 24
  • check here :https://maven.apache.org/guides/mini/guide-creating-archetypes.html – lesnar Nov 10 '16 at 14:58
  • I am using local and external repository for this example @Roxy – jc1992 Nov 10 '16 at 15:00
  • 1
    Wouldn't adding dependencies through command-line instead pom file defeat the whole purpose of repeatable builds? – Jiri Tousek Nov 10 '16 at 15:03
  • 1
    what's the use case? I am trying to understand why a `.bat` would suit you better than the `pom.xml` file – blurfus Nov 10 '16 at 15:33
  • Possible duplicate of [Can I add maven repositories in the command line?](http://stackoverflow.com/questions/71030/can-i-add-maven-repositories-in-the-command-line) – Chandana Kumara Nov 10 '16 at 15:43
  • The case , is to create a bat to generate an automatically structure of the project. – jc1992 Nov 10 '16 at 15:55
  • 1
    @jcsa An archetype must have a pre-defined structure, that's the point of using an archetype. If you want to dynamically add dependencies... you'll need to create your own compelete tooling for that, that isn't supported in archetypes -- probably for good reasons: as commented above, this kills any reproducible builds. – Tunaki Nov 10 '16 at 17:15
  • Ah ! , okey I understand now :) – jc1992 Nov 11 '16 at 08:58

1 Answers1

1

There is nothing out there in the official documentation at least. The dependencies coming in the generated pom.xml is determined by the archetypeArtifactId option. For example, -DarchetypeArtifactId=maven-archetype-j2ee-simple or -DarchetypeArtifactId=maven-archetype-webapp or any other archetype

Example

Project generated using -DarchetypeArtifactId=maven-archetype-webapp pom.xml comes only with JUnit dependency

so-random-dude
  • 15,277
  • 10
  • 68
  • 113