You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

getting-started-maven.asciidoc 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. ---
  2. title: Creating a Project with Maven
  3. order: 200
  4. layout: page
  5. ---
  6. [[getting-started.maven]]
  7. = Creating a Project with Maven
  8. ((("Maven", "creating a project", id="term.maven.creating", range="startofrange")))
  9. In previous sections, we looked into creating a Vaadin Maven project in different IDEs.
  10. In this section, we look how to create such a project on command-line.
  11. You can then import such a project in your IDE.
  12. In addition to regular Maven, you can use any Maven-compatible build or
  13. dependency management system, such as Ivy or Gradle. For Gradle, see the
  14. link:https://github.com/johndevs/gradle-vaadin-plugin[Gradle Vaadin Plugin].
  15. For an interactive guide, see the instructions at link:https://vaadin.com/maven[vaadin.com/maven].
  16. It automatically generates you the command to create a new project based on archetype selection.
  17. It can also generate dependency declarations for Vaadin dependencies.
  18. [[getting-started.maven.command-line]]
  19. == Working from Command-Line
  20. You can create a new Maven project with the following command (given in one
  21. line):
  22. [subs="normal"]
  23. ----
  24. [prompt]#$# [command]#mvn# archetype:generate \
  25. -DarchetypeGroupId=com.vaadin \
  26. -DarchetypeArtifactId=[replaceable]#vaadin-archetype-application# \
  27. -DarchetypeVersion=[replaceable]#8.x.x# \
  28. -DgroupId=[replaceable]#com.pany# \
  29. -DartifactId=[replaceable]#project-name# \
  30. -Dversion=[replaceable]#0.1# \
  31. -Dpackaging=war
  32. ----
  33. The parameters are as follows:
  34. [parameter]#archetypeGroupId#:: The group ID of the archetype is [literal]#++com.vaadin++# for Vaadin
  35. archetypes.
  36. [parameter]#archetypeArtifactId#:: The archetype ID.
  37. See the list of available archetypes in <<dummy/../../../framework/getting-started-archetypes#getting-started.archetypes,"Overview of Maven Archetypes">>.
  38. [parameter]#archetypeVersion#::
  39. Version of the archetype to use.
  40. For prerelease versions it should be the exact version number, such as [literal]#++8.0.0.beta2++#.
  41. [parameter]#groupId#:: A Maven group ID for your project. It is normally your organization domain name
  42. in reverse order, such as com.example. The group ID is also used as a prefix for
  43. the Java package in the sources, so it should be Java compatible - only
  44. alphanumerics and an underscore.
  45. [parameter]#artifactId#:: Identifier of the artifact, that is, your project. The identifier may contain
  46. alphanumerics, minus, and underscore. It is appended to the group ID to obtain
  47. the Java package name for the sources. For example, if the group ID is
  48. com.example and artifact ID is myproject, the project sources would be placed in
  49. com.example.myproject package.
  50. [parameter]#version#:: Initial version number of your application. The number must obey the Maven
  51. version numbering format.
  52. [parameter]#packaging#:: How will the project be packaged. It is normally [literal]#++war++#.
  53. Creating a project can take a while as Maven fetches all the dependencies.
  54. [[getting-started.maven.compiling]]
  55. == Compiling and Running the Application
  56. ((("Maven", "compiling", id="term.maven.compiling", range="startofrange")))
  57. Before the application can be deployed, it must be compiled and packaged as a
  58. WAR package. You can do this with the [literal]#++package++# goal as follows:
  59. [subs="normal"]
  60. ----
  61. [prompt]#$# [command]#mvn# package
  62. ----
  63. The location of the resulting WAR package should be displayed in the command
  64. output. You can then deploy it to your favorite application server.
  65. The easiest way to run Vaadin applications with Maven is to use the light-weight Jetty web server.
  66. After compiling the package, all you need to do is type:
  67. [subs="normal"]
  68. ----
  69. [prompt]#$# [command]#mvn# jetty:run
  70. ----
  71. The special goal starts the Jetty server in port 8080 and deploys the
  72. application. You can then open it in a web browser at
  73. http://localhost:8080/project-name.
  74. (((range="endofrange", startref="term.maven.compiling")))
  75. [[getting-started.maven.addons]]
  76. == Using Add-ons
  77. ((("Maven", "using add-ons", id="term.maven.addons", range="startofrange")))
  78. If you use Vaadin add-ons from the http://vaadin.com/directory[Vaadin Directory], you need to add them as dependencies in the project POM.
  79. The instructions are given in <<dummy/../../../framework/addons/addons-maven#addons.maven, "Using Add-ons in a
  80. Maven Project">>.
  81. _In projects that use Vaadin 7.6 or older_, you need to compile the widget set manually.
  82. See the add-on usage instructions.
  83. (((range="endofrange", startref="term.maven.addons")))
  84. (((range="endofrange", startref="term.maven.creating")))