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 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. ---
  2. title: Using Vaadin with Maven
  3. order: 6
  4. layout: page
  5. ---
  6. [[getting-started.maven]]
  7. = Using Vaadin with Maven
  8. ((("Maven", "creating a project", id="term.maven.creating", range="startofrange")))
  9. Maven is a commonly used build and dependency management system. The Vaadin core
  10. library and all Vaadin add-ons are available through Maven. You can use a Maven
  11. with a front-end from Eclipse or NetBeans, or by using the command-line as
  12. described in this section.
  13. In addition to regular Maven, you can use any Maven-compatible build or
  14. dependency management system, such as Ivy or Gradle. For Gradle, see the
  15. link:https://github.com/johndevs/gradle-vaadin-plugin[Gradle Vaadin Plugin].
  16. Vaadin Plugin for Eclipse uses Ivy for resolving dependencies in Vaadin
  17. projects, and it should provide you with the basic Ivy configuration.
  18. For an interactive guide, see the instructions at link:https://vaadin.com/maven[vaadin.com/maven].
  19. It automatically generates you the command to create a new project based on archetype selection.
  20. It can also generate dependency declarations for Vaadin dependencies.
  21. [[getting-started.maven.command-line]]
  22. == Working from Command-Line
  23. You can create a new Maven project with the following command (given in one
  24. line):
  25. [subs="normal"]
  26. ----
  27. [prompt]#$# [command]#mvn# archetype:generate \
  28. -DarchetypeGroupId=com.vaadin \
  29. -DarchetypeArtifactId=[replaceable]#vaadin-archetype-application# \
  30. -DarchetypeVersion=[replaceable]#7.x.x# \
  31. -DgroupId=[replaceable]#your.company# \
  32. -DartifactId=[replaceable]#project-name# \
  33. -Dversion=[replaceable]#0.1# \
  34. -Dpackaging=war
  35. ----
  36. The parameters are as follows:
  37. [parameter]#archetypeGroupId#:: The group ID of the archetype is [literal]#++com.vaadin++# for Vaadin
  38. archetypes.
  39. [parameter]#archetypeArtifactId#:: The archetype ID.
  40. Vaadin 7 currently supports the following archetypes:
  41. `vaadin-archetype-application`;;
  42. A single-module project for simple applications.
  43. Good for quick demos and trying out Vaadin.
  44. `vaadin-archetype-application-multimodule`;;
  45. A complete Vaadin application development setup.
  46. It features separate production and development profiles.
  47. `vaadin-archetype-application-example`;;
  48. An example CRUD web application using multi-module project setup.
  49. `vaadin-archetype-widget`;;
  50. A multi-module project for a new Vaadin add-on.
  51. It has two modules: one for the add-on and another for a demo application.
  52. `vaadin-archetype-touchkit`;;
  53. A mobile development starter project using Vaadin TouchKit.
  54. See <<dummy/../../../touchkit/touchkit-overview#touchkit.overview,"Vaadin TouchKit">>.
  55. Notice that this archetype uses the AGPL-licensed version of TouchKit, which requires that your project must also be licensed under the AGPL license.
  56. `vaadin-archetype-liferay-portlet`;;
  57. A portlet development setup for the open-source Liferay portal.
  58. [parameter]#archetypeVersion#:: Version of the archetype to use. This should be [literal]#++LATEST++# for normal
  59. Vaadin releases. For prerelease versions it should be the exact version number,
  60. such as [literal]#++7.5.3++#.
  61. [parameter]#groupId#:: A Maven group ID for your project. It is normally your organization domain name
  62. in reverse order, such as com.example. The group ID is also used as a prefix for
  63. the Java package in the sources, so it should be Java compatible - only
  64. alphanumerics and an underscore.
  65. [parameter]#artifactId#:: Identifier of the artifact, that is, your project. The identifier may contain
  66. alphanumerics, minus, and underscore. It is appended to the group ID to obtain
  67. the Java package name for the sources. For example, if the group ID is
  68. com.example and artifact ID is myproject, the project sources would be placed in
  69. com.example.myproject package.
  70. [parameter]#version#:: Initial version number of your application. The number must obey the Maven
  71. version numbering format.
  72. [parameter]#packaging#:: How will the project be packaged. It is normally [literal]#++war++#.
  73. Creating a project can take a while as Maven fetches all the dependencies. The
  74. created project structure is shown in
  75. <<figure.getting-started.maven.archetype.created>>.
  76. [[figure.getting-started.maven.archetype.created]]
  77. .A New Vaadin Project with Maven
  78. image::img/maven-project-created.png[scaledwidth=60%]
  79. [[getting-started.maven.compiling]]
  80. == Compiling and Running the Application
  81. ((("Maven", "compiling", id="term.maven.compiling", range="startofrange")))
  82. Before the application can be deployed, it must be compiled and packaged as a
  83. WAR package. You can do this with the [literal]#++package++# goal as follows:
  84. [subs="normal"]
  85. ----
  86. [prompt]#$# [command]#mvn# package
  87. ----
  88. The location of the resulting WAR package should be displayed in the command
  89. output. You can then deploy it to your favorite application server.
  90. The easiest way to run Vaadin applications with Maven is to use the light-weight
  91. Jetty web server. After compiling the package, all you need to do is type:
  92. [subs="normal"]
  93. ----
  94. [prompt]#$# [command]#mvn# jetty:run
  95. ----
  96. The special goal starts the Jetty server in port 8080 and deploys the
  97. application. You can then open it in a web browser at
  98. http://localhost:8080/project-name.
  99. (((range="endofrange", startref="term.maven.compiling")))
  100. [[getting-started.maven.addons]]
  101. == Using Add-ons and Custom Widget Sets
  102. ((("Maven", "using add-ons", id="term.maven.addons", range="startofrange")))
  103. If you use Vaadin add-ons that include a widget set or make your custom widgets,
  104. you need to enable widget set compilation in the POM. The required configuration
  105. is described in
  106. <<dummy/../../../framework/addons/addons-maven#addons.maven,"Using Add-ons in a
  107. Maven Project">>.
  108. (((range="endofrange", startref="term.maven.addons")))
  109. (((range="endofrange", startref="term.maven.creating")))