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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. Vaadin Plugin for Eclipse uses Ivy for resolving dependencies in Vaadin
  16. projects, and it should provide you with the basic Ivy configuration.
  17. For an interactive guide, see the instructions at link:https://vaadin.com/maven[vaadin.com/maven].
  18. It automatically generates you the command to create a new project based on archetype selection.
  19. It can also generate dependency declarations for Vaadin dependencies.
  20. [[getting-started.maven.command-line]]
  21. == Working from Command-Line
  22. You can create a new Maven project with the following command (given in one
  23. line):
  24. [subs="normal"]
  25. ----
  26. [prompt]#$# [command]#mvn# archetype:generate \
  27. -DarchetypeGroupId=com.vaadin \
  28. -DarchetypeArtifactId=[replaceable]#vaadin-archetype-application# \
  29. -DarchetypeVersion=[replaceable]#7.x.x# \
  30. -DgroupId=[replaceable]#com.pany# \
  31. -DartifactId=[replaceable]#project-name# \
  32. -Dversion=[replaceable]#0.1# \
  33. -Dpackaging=war
  34. ----
  35. The parameters are as follows:
  36. [parameter]#archetypeGroupId#:: The group ID of the archetype is [literal]#++com.vaadin++# for Vaadin
  37. archetypes.
  38. [parameter]#archetypeArtifactId#:: The archetype ID.
  39. See the list of available archetypes in <<dummy/../../../framework/getting-started-archetypes#getting-started.archetypes,"Overview of Maven Archetypes">>.
  40. [parameter]#archetypeVersion#::
  41. Version of the archetype to use.
  42. This should be [literal]#++LATEST++# for normal Vaadin releases.
  43. For prerelease versions it should be the exact version number, such as [literal]#++7.6.4++#.
  44. [parameter]#groupId#:: A Maven group ID for your project. It is normally your organization domain name
  45. in reverse order, such as com.example. The group ID is also used as a prefix for
  46. the Java package in the sources, so it should be Java compatible - only
  47. alphanumerics and an underscore.
  48. [parameter]#artifactId#:: Identifier of the artifact, that is, your project. The identifier may contain
  49. alphanumerics, minus, and underscore. It is appended to the group ID to obtain
  50. the Java package name for the sources. For example, if the group ID is
  51. com.example and artifact ID is myproject, the project sources would be placed in
  52. com.example.myproject package.
  53. [parameter]#version#:: Initial version number of your application. The number must obey the Maven
  54. version numbering format.
  55. [parameter]#packaging#:: How will the project be packaged. It is normally [literal]#++war++#.
  56. Creating a project can take a while as Maven fetches all the dependencies. The
  57. created project structure is shown in
  58. <<figure.getting-started.maven.archetype.created>>.
  59. [[figure.getting-started.maven.archetype.created]]
  60. .A New Vaadin Project with Maven
  61. image::img/maven-project-created.png[scaledwidth=60%]
  62. [[getting-started.maven.compiling]]
  63. == Compiling and Running the Application
  64. ((("Maven", "compiling", id="term.maven.compiling", range="startofrange")))
  65. Before the application can be deployed, it must be compiled and packaged as a
  66. WAR package. You can do this with the [literal]#++package++# goal as follows:
  67. [subs="normal"]
  68. ----
  69. [prompt]#$# [command]#mvn# package
  70. ----
  71. The location of the resulting WAR package should be displayed in the command
  72. output. You can then deploy it to your favorite application server.
  73. The easiest way to run Vaadin applications with Maven is to use the light-weight Jetty web server.
  74. After compiling the package, all you need to do is type:
  75. [subs="normal"]
  76. ----
  77. [prompt]#$# [command]#mvn# jetty:run
  78. ----
  79. The special goal starts the Jetty server in port 8080 and deploys the
  80. application. You can then open it in a web browser at
  81. http://localhost:8080/project-name.
  82. (((range="endofrange", startref="term.maven.compiling")))
  83. [[getting-started.maven.addons]]
  84. == Using Add-ons
  85. ((("Maven", "using add-ons", id="term.maven.addons", range="startofrange")))
  86. 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.
  87. The instructions are given in <<dummy/../../../framework/addons/addons-maven#addons.maven, "Using Add-ons in a
  88. Maven Project">>.
  89. _In projects that use Vaadin 7.6 or older_, you need to compile the widget set manually.
  90. See the add-on usage instructions.
  91. (((range="endofrange", startref="term.maven.addons")))
  92. (((range="endofrange", startref="term.maven.creating")))