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.

README-DEV.md 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. # Development Instructions
  2. To contribute, first refer to [Contributing Code](https://github.com/vaadin/framework/blob/master/CONTRIBUTING.md)
  3. for general instructions and requirements for contributing code to the Vaadin framework.
  4. We appreciate all contributors and want to make submitting changes as easy as possible. If you find any mistakes, unclear parts or out-of-date instructions, please let us know by submitting an issue or a pull request.
  5. #### Table of Contents
  6. 1. [Building a package](#building-a-package)
  7. 1. [About committing changes](#about-committing-changes)
  8. 1. [Eclipse quick setup](#eclipse-quick-setup)
  9. 1. [IntelliJ IDEA quick setup](#intellij-idea-quick-setup)
  10. ## Building a package
  11. The distribution files can be built by running the standard Maven goal `mvn install` in the project root.
  12. ## About committing changes
  13. Despite our best efforts the formatting options aren't always entirely consistent between different development environments, and sometimes we miss inconsistent formatting during code review. When you commit your changes for a pull request, try to make sure that the commit _only contains changes that are relevant to your patch,_ or at least closely affiliated with the relevant changes. Random formatting changes all over the changed file(s) make it difficult to grasp the main purpose of your patch.
  14. ## Eclipse quick setup
  15. For IntelliJ IDEA users, see [IntelliJ IDEA Quick Setup](#intellij-idea-quick-setup).
  16. 1. Decide were you would like your Eclipse workspace to be located.
  17. * This project contains multiple modules and uses configurations that might clash with your existing projects, using a separate workspace is recommended.
  18. * Eclipse Oxygen is recommended, different versions may treat formatting rules differently.
  19. * If you are using Windows, you may wish to keep the workspace path reasonably short (e.g. `C:\dev\<workspaceName>`) to avoid problems with too long file paths.
  20. 1. Start Eclipse with your chosen workspace and set up [workspace preferences](#workspace-preferences).
  21. 1. Clone the repository within your selected workspace using Eclipse's clone wizard, using your favorite Git tool, or in command-line running
  22. <code>git clone https://github.com/vaadin/framework.git</code> command.
  23. * Eclipse's clone wizard can be found within Git perspective (*Window* -> *Perspectives* -> *Open Perspective* -> *Git*). _Only_ clone the project at this stage, do not let the clone wizard import projects as well.
  24. * If using Windows, you might also want to add these Git settings: `core.autocrlf=false` and `core.fileMode=false`. You can do this in Eclipse by right-clicking the repository in Git perspective, clicking *Properties*, then *Add Entry...* and using key `core.autocrlf` and value `false` etc.
  25. * If too long file paths become a problem you may also need `core.longpaths=true`.
  26. 1. Import the project into Eclipse as a Maven project. Use *File* -> *Import* -> *Maven* -> *Existing Maven Projects*.
  27. 1. Select the *framework* folder (where you cloned the project).
  28. * It is not necessary to import all the modules, but it is recommended to include at least the root module, `vaadin-uitest` module, and any modules you may wish to make changes to. You can import more modules when needed by repeating these last steps.
  29. 1. Click “Finish” to complete the import of Vaadin Framework.
  30. ### Workspace preferences
  31. The following preferences need to be set to keep the project consistent. You need to do this especially to be able to contribute changes to the project.
  32. #### General
  33. 1. Open *Window* -> *Preferences* (Windows) or *Eclipse* -> *Preferences* (Mac)
  34. 1. Go to *General* -> *Workspace*
  35. - Set *Text file encoding* to *UTF-8*
  36. - Set *New text file line delimiter* to *Unix*
  37. 1. Go to *XML* -> *XML Files* -> *Editor*
  38. - Ensure the settings are follows:
  39. - Line width: 72
  40. - Format comments: true
  41. - Join lines: true
  42. - Insert whitespace before closing empty end-tags: true
  43. - Indent-using spaces: true
  44. - Indentation size: 4
  45. 1. Go to *Java* -> *Compiler* -> *Errors*
  46. - Switch *Serializable class without serialVersionUID* to *Ignore*
  47. 1. Go to *Java* -> *Installed JREs*
  48. - Select a Java 8 JDK as the default
  49. #### Configuration files
  50. 1. Open *Window* -> *Preferences* (Windows) or *Eclipse* -> *Preferences* (Mac)
  51. 1. Go to *Java* -> *Code Style* -> *Clean Up*
  52. - Import [eclipse/VaadinCleanup.xml](/eclipse/VaadinCleanup.xml)
  53. 1. Go to *Java* -> *Code Style* -> *Formatter*
  54. - Import [eclipse/VaadinJavaConventions.xml](/eclipse/VaadinJavaConventions.xml)
  55. #### Save actions
  56. 1. Open *Window* -> *Preferences* (Windows) or *Eclipse* -> *Preferences* (Mac)
  57. 1. Go to *Java* -> *Editor* -> *Save Actions*
  58. - Check *Perform the selected actions on save*
  59. - Check *Format source code*
  60. - Select *Format edited lines*
  61. - Check *Organize imports*
  62. - Check *Additional actions*
  63. - Click *Configure*
  64. 1. In tab *Code Organizing*
  65. - Check *Remove trailing whitespace*
  66. - Select *All lines*
  67. - Uncheck everything else
  68. 1. In tab *Code Style*
  69. - Check *Use blocks in if/while/for/do statements*
  70. - Select *Always*
  71. - Uncheck everything else
  72. 1. In tab *Member Accesses*
  73. - Check *Use 'this' qualifier for field accesses*
  74. - Select *Only if necessary*
  75. - Check *Use 'this' qualifier for method accesses*
  76. - Select *Only if necessary*
  77. - Uncheck everything else
  78. 1. In tab *Missing Code*
  79. - Check *Add missing Annotations*
  80. - Check *'@Override'*
  81. - Check *Implementations of interface methods (1.6 or higher)*
  82. - Check *'@Deprecated'*
  83. 1. In tab *Unnecessary Code*
  84. - Check *Remove unused imports* and *Remove unnecessary casts*, uncheck everything else.
  85. 1. Click *OK*
  86. After that is done, you should have 9 of 28 save actions activated and listed as such:
  87. * Remove 'this' qualifier for non static field accesses
  88. * Remove 'this' qualifier for non static method accesses
  89. * Convert control statement bodies to block
  90. * Remove unused imports
  91. * Add missing '@Override' annotations
  92. * Add missing '@Override' annotations to implementations of interface methods
  93. * Add missing '@Deprecated' annotations
  94. * Remove unnecessary casts
  95. * Remove trailing white spaces on all lines
  96. ### Getting started
  97. Run <code>install</code> maven goal for the project root to get started.
  98. In Eclipse this is done by right-clicking on the project root in Project Explorer and choosing *Run As* -> *Maven Build...*. If you choose to skip tests you may need to run the <code>install</code> maven goal for `vaadin-uitest` project separately.
  99. * Note that the first compilation takes a while to finish as Maven downloads dependencies used in the projects.
  100. Now the project should compile without further configuration.
  101. ### Compiling the default widgetset and themes
  102. * Compile the default widgetset by running <code>install</code> maven goal in `vaadin-client-compiled` module root.
  103. In Eclipse this is done by right clicking on `vaadin-client-compiled` project in Project Explorer and choosing *Run As* -> *Maven Build...*.
  104. You don't need to do this separately if you have already run <code>install</code> for the root project after your latest changes.
  105. * Compile the default themes by running <code>install</code> maven goal in `vaadin-themes` module root.
  106. In Eclipse this is done by right clicking on `vaadin-themes` project in Project Explorer and choosing *Run As* -> *Maven Build...*.
  107. You don't need to do this separately if you have already run <code>install</code> for the root project after your latest changes.
  108. ### Running a UI test
  109. #### Using DevelopmentServerLauncher (recommended)
  110. 1. In a Project Explorer navigate to *vaadin-uitest/src/main/java/com/vaadin/launcher*
  111. 1. Right-click file DevelopmentServerLauncher.java
  112. 1. Open *Run As* -> *Java Application*
  113. 1. Open URL [http://localhost:8888/run/&lt;testUI&gt;](http://localhost:8888/run/<testUI>)
  114. #### Using Jetty
  115. 1. In a Project Explorer right-click *vaadin-uitest*
  116. 1. Open *Run As* -> *Maven build...*
  117. 1. Type in <code>jetty:run-exploded</code> into *Goals* and click *Run*
  118. 1. Open URL [http://localhost:8888/run/&lt;testUI&gt;](http://localhost:8888/run/<testUI>)
  119. For full instructions please visit [README-TESTS.md](README-TESTS.md).
  120. ## IntelliJ IDEA quick setup
  121. For Eclipse users, see [Eclipse Quick Setup](#eclipse-quick-setup).
  122. 1. Install and run IDEA. Ultimate Edition is better but Community Edition should also work.
  123. 1. Ensure if Git and Maven plugins are installed, properly configured and enabled.
  124. 1. Clone the repository, using menu VCS -> Checkout from Version Control -> Git -> Git Repository URL -> https://github.com/vaadin/framework.git.
  125. When the repository is cloned, do **NOT** open it as a project.
  126. * If you are using Windows, you may wish to keep the workspace path reasonably short (e.g. `C:\dev\<workspaceName>`) to avoid problems with too long file paths.
  127. 1. Open cloned repository as a maven object. Use File -> Open and choose root _pom.xml_ file
  128. 1. Have a coffee break while IDEA is loading dependencies and indexing the project
  129. 1. Run Maven targets <code>clean</code> and <code>install</code> using *Maven Projects* tool window to compile the whole project
  130. Unfortunately there is no easy way to replicate [Eclipse workspace preferences](#workspace-preferences) in their entirety in IDEA, but you can use [Eclipse Code Formatter plugin](https://plugins.jetbrains.com/plugin/6546-eclipse-code-formatter) to import [eclipse/VaadinCleanup.xml](/eclipse/VaadinCleanup.xml) and [eclipse/VaadinJavaConventions.xml](/eclipse/VaadinJavaConventions.xml) as a starting point.
  131. ### Running a specific UI test
  132. 1. Open *Maven Projects*
  133. 1. Open *vaadin-uitest* -> *Plugins* -> *jetty* -> *jetty:run-exploded*
  134. 1. Open URL [http://localhost:8888/run/&lt;testUI&gt;](http://localhost:8888/run/<testUI>)
  135. For full instructions please visit [README-TESTS.md](README-TESTS.md).
  136. ### Running a development server
  137. 1. Open *Run* menu and click *Edit Configurations*
  138. 1. Click green ***+*** sign at top left corner, select *Maven* from popup
  139. 1. In the run configuration page, set any name for the configuration, select *vaadin-uitest* project folder as *Working directory*
  140. 1. Type <code>exec:exec@run-development-server</code> into *Command line* and save the configuration
  141. 1. Run the configuration and open URL [http://localhost:8888/run/&lt;testUI&gt;](http://localhost:8888/run/<testUI>)
  142. ### Running a development server in a debug mode
  143. 1. Type <code>exec:exec@debug-development-server</code> into *Command line* and save the configuration
  144. 1. In the same dialog, create new "Remote" debug configuration, using *localhost* and *Port 5005*
  145. 1. Start both configurations and open URL [http://localhost:8888/run/&lt;testUI&gt;](http://localhost:8888/run/<testUI>)