PageRenderTime 47ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/documentation/src/main/asciidoc/contributing/basics.adoc

http://github.com/infinispan/infinispan
AsciiDoc | 269 lines | 195 code | 74 blank | 0 comment | 0 complexity | 7cb82e0a5168aadaf6d02b73457e4034 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.1
  1. == The Basics
  2. In this chapter we quickly walk through the basics on contributing; future chapters go into more depth.
  3. === Prequisites
  4. |=============
  5. | Java 8 | Infinispan is baselined on Java 8 (we build with Oracle JDK, OpenJDK and IBM JDK)
  6. | Maven 3.2 | The Infinispan build uses Maven, and you should be using at least Maven 3.2
  7. | Git | The Infinispan source code is stored in Git.
  8. |=============
  9. === Issue Management
  10. Infinispan uses JIRA for issue management, hosted on link:$$http://issues.jboss.org/browse/ISPN$$[issues.jboss.org].
  11. You can log in using your jboss.org username and password.
  12. ==== Reporting Issues
  13. If you need to create a new issue then follow these steps.
  14. . Choose between
  15. * _Feature Request_ if you want to request an enhancement or new feature for Infinispan
  16. * _Bug_ if you have discovered an issue
  17. * _Task_ if you wish to request a documentation, sample or process (e.g. build system) enhancement or issue
  18. . Then enter a _Summary_ , describing briefly the problem - please try to be descriptive!
  19. . You should *not* set _Priority_.
  20. . Now, enter the version you are reporting an issue against in the _Affects Version_ field, and leave the _Fix Version_ field blank.
  21. . In the _Environment_ text area, provide as much detail as possible about your environment (e.g. Java runtime and version, operating system, any network topology which is relevant).
  22. . In the _Description_ field enter a detailed description of your problem or request.
  23. . If the issue has been discussed on the forums or the mailing list, enter a reference in the _Forum Reference_ field
  24. . Finally, hit _Create_
  25. ==== Versioning Guidelines
  26. [WARNING]
  27. ====
  28. Only Infinispan contributors should set the _Fix Version_ field.
  29. ====
  30. When setting the _Fix Version_ field for bugs and issues in JIRA, the following guidelines apply:
  31. Version numbers are defined as `${major}.${minor}.${micro}.${modifier}`. For example, `4.1.0.Beta1` would be:
  32. |===============
  33. |major|4
  34. |minor|1
  35. |micro|0
  36. |modifier|Beta1
  37. |===============
  38. If the issue relates to a _Task_ or _Feature Request_, please ensure that the `.Final` version is included in the _Fixed In_ field.
  39. For example, a new feature should contain `4.1.0.Beta1`, `4.1.0.Final` if it is new for 4.1.0 and was first made public in beta1.
  40. For example, see link:$$https://issues.jboss.org/browse/ISPN-299$$[ISPN-299] .
  41. If the issue relates to a bug which affected a previous Final version, then the _Fixed In_ field should also contain the Final version which contains the fix, in addition to any Alpha, Beta or CR release.
  42. For example, see link:$$https://issues.jboss.org/browse/ISPN-546$$[ISPN-546].
  43. If the issue pertains to a bug in the current release, then the Final version should not be in the _Fixed In_ field.
  44. For example, a bug found in 4.1.0.Alpha2 (but not in 4.1.0.Alpha1) should be marked as fixed in 4.1.0.Alpha3, but not in 4.1.0.Final.
  45. For example, see link:$$https://issues.jboss.org/browse/ISPN-416$$[ISPN-416].
  46. === Version control
  47. Infinispan uses link:$$http://git-scm.com$$[git], hosted on link:$$http://github.com$$[GitHub], for version control.
  48. You can find the upstream git repository at link:$$https://github.com/infinispan$$[]. To clone the repository:
  49. ----
  50. $ git clone git@github.com:infinispan/infinispan.git
  51. ----
  52. or to clone your fork:
  53. ----
  54. $ git clone git@github.com:YOUR_GITHB_USERNAME/infinispan.git
  55. ----
  56. ==== Setting up your IDE
  57. Maven supports generating IDE configuration files for easy setup of a project.
  58. This is tested on Eclipse, IntelliJ IDEA and Netbeans.
  59. ===== Eclipse
  60. Before we import the project, we need to clone the project as described above.
  61. . Install the m2eclipse plugin if you have not already installed it. This is bundled with Eclipse from version "Indigo" 3.7.
  62. For older versions follow instructions on link:$$http://eclipse.org/m2e/$$[].
  63. . Import the Infinispan maven project. Select File -> Import in your eclipse workbench. Select the Existing Maven Project importer.
  64. +
  65. image::images/import_maven1.png[]
  66. . Select the root directory of your Infinispan checkout.
  67. +
  68. image::images/import_maven2.png[]
  69. . Select Infinispan modules that you want to import.
  70. . Finally, from Infinispan 5.0 onwards, annotation processing is used to allow log messages to be internationalized. This processing can be done directly from Eclipse as part of compilation but it requires some set up:
  71. .. Open the properties for infinispan-core and locate Annotation Processing
  72. .. Tick Enable project specific settings
  73. .. Enter `target/generated-sources/annotations` as the `Generated source` directory
  74. +
  75. image::images/ann_proc_eclipse.png[]
  76. . Code Formatting. From the menu Window -> Preferences -> Java -> Code Style -> Formatter. Import link:$$https://raw.github.com/infinispan/infinispan/master/ide-settings/eclipse/formatter.xml$$[formatter.xml]
  77. . Code templates. From the menu Window -> Preferences -> Java -> Code Style -> Code Templates. Import link:$$https://raw.github.com/infinispan/infinispan/master/ide-settings/eclipse/codetemplates.xml$$[codetemplates.xml]
  78. Some modules use Scala, if you plan contributing to one of these modules it's worth installing the link:$$http://scala-ide.org/$$[Scala IDE]. After installing it you need to add "Scala Nature" to a few project of the projects (from the project context menu Configuration -> Add Scala Nature), at the moment these projects are:
  79. . infinispan-server-core
  80. . infinispan-server-hotrod
  81. . infinispan-server-memcached
  82. . infinispan-server-rest
  83. ===== IntelliJ IDEA
  84. ====== Importing
  85. When you start link:http://www.jetbrains.com/idea/[IntelliJ IDEA], you will be greeted by a screen as shown below:
  86. image::images/idea-12-import.jpg[]
  87. If you have already obtained a copy of the Infinispan sources via Github (see _'Source Control'_), then follow: _Import Project -> /directory/to/downloaded/sources_ .
  88. IntelliJ will automatically make use of Maven to import the project since it will detect a `pom.xml` file in the base directory.
  89. If you have not obtained the sources already, you can use the Git integration in IntelliJ IDEA 12. Click on _Check out from Version Control -> Github_.
  90. After entering your Github credentials, you will then be prompted to enter the git repository URL along with the location that you want to check out the source code to.
  91. image::images/idea-12-git.png[]
  92. ====== Compiler settings
  93. From Infinispan 5.0 onwards, annotation processing is used to allow log messages to be internationalized.
  94. This processing can be done directly from IntelliJ as part of compilation but it requires some set up:
  95. . Go to Preferences -> Compiler -> Annotation Processor" and click on _Enable annotation processing_
  96. . Add an annotation processor with "Processor FQN Name" as `org.jboss.logging.LoggingToolsProcessor`
  97. . In "Processed Modules", add all modules except the root and the parent modules.
  98. image::images/idea-12-annotations.png[]
  99. TIP: There can sometimes be issues with the generated logging classes on rebuild (particularly when you switch Git branches).
  100. If these issues do crop up then simply run `mvn clean install -DskipTests` on the command line to clear them out.
  101. TIP: If you are running a multi-core environment (e.g. quad-core or above) then you can follow the instructions on making use of parallelized compilation in IntelliJ 12. Information on how to do this can be found link:$$http://blogs.jetbrains.com/idea/2012/12/intellij-idea-12-compiler-twice-as-fast/$$[here] .
  102. ====== Scala Plugin
  103. You will need to download the Scala plugin for IntelliJ as well. This can be done in _Project Settings -> Plugins -> Browse Repositories_.
  104. Then run a search for 'Scala'. JetBrains themselves are the vendor for this plugin and more information on it can be found link:$$http://confluence.jetbrains.net/display/SCA/Scala+Plugin+for+IntelliJ+IDEA$$[here] .
  105. image::images/idea-12-scala.png[]
  106. You will then have to configure the Scala plugin to use the Scala compiler for Scala files and the Java compiler for Java files. You can do this by going into _Settings -> Compiler -> Scala Compiler_ . Be sure to add the Scala compiler bundle as shown in the screenshot below.
  107. image::images/idea-12-scala2.png[]
  108. ====== Code Style
  109. Download the code style JAR file from link:https://github.com/infinispan/infinispan/blob/master/ide-settings/intellij/IntelliJ_IDEA_Code_Style.jar?raw=true[here] and import this into IntelliJ IDEA.
  110. === Builds
  111. Infinispan uses link:$$http://maven.apache.org/$$[Maven] for builds. Make sure you have Maven 3 installed, and properly configured.
  112. For more information, read <<_building_infinispan,the Maven chapter>>.
  113. ==== Continuous Integration
  114. Infinispan uses link:$$http://www.jetbrains.com/teamcity$$[TeamCity] for continuous integration.
  115. TeamCity polls GitHub for updates and runs whenever updates are available.
  116. You can check the status of the latest builds link:$$http://ci.infinispan.org/overview.html$$[here] .
  117. === Testing
  118. Infinispan uses link:http://testng.org/doc/index.html[TestNG] for unit and functional tests, and all Infinispan tests are run in parallel.
  119. For more information see the chapter on the test suite; this chapter gives advice on writing tests which can safely execute in parallel.
  120. === Communicating with other Infinispan contributors
  121. Infinispan contributors use a mix of technologies to communicate.
  122. Visit link:$$http://infinispan.org/community/$$[this page] to learn more.
  123. === Style Requirements
  124. Infinispan uses the link:$$http://en.wikipedia.org/wiki/Indent_style#K.26R_style$$[K&amp;R code style] for all Java source files, with two exceptions:
  125. . use 3 spaces instead of a tab character for indentations.
  126. . braces start on the same line for class, interface and method declarations as well as code blocks.
  127. In addition, sure all link:$$http://en.wikipedia.org/wiki/Newline$$[new line characters] used must be LF (UNIX style line feeds). Most good IDEs allow you to set this, regardless of operating system used.
  128. All patches or code committed must adhere to this style. Code style settings which can be imported into IntelliJ IDEA and Eclipse are committed in the project sources, in link:$$https://github.com/infinispan/infinispan/blob/master/ide-settings/$$[ide-settings] .
  129. ==== Spelling
  130. Ensure correct spelling in code, comments, Javadocs, etc. (use _American English_ spelling).
  131. It is recommended that you use a spellchecker plugin for your IDE.
  132. ==== Check-in comments
  133. Please ensure any commit comments use <<_comments, this format>> if related to a task or issue in JIRA.
  134. This helps JIRA pick out these checkins and display them on the issue, making it very useful for back/forward porting fixes.
  135. If your comment does not follow this format, your commit may not be merged into upstream.
  136. === Logging
  137. Infinispan follows the JBoss logging standards, which can be found link:$$https://community.jboss.org/wiki/LoggingStandards$$[here] .
  138. From Infinispan 5.0 onwards, Infinispan uses JBoss Logging to abstract over the logging backend.
  139. Infinispan supports localization of log message for categories of INFO or above as explained in link:$$http://community.jboss.org/docs/16738$$[the JBoss Logging guidelines] .
  140. As a developer, this means that for each INFO, WARN, ERROR and FATAL message your code emits, you need to modify the Log class in your module and add an explicit method for it with the right annotations.
  141. For example:
  142. [source,java]
  143. ----
  144. @LogMessage(level = INFO)
  145. @Message(value = "An informative message: %s - %s", id = 600)
  146. void fiveTransactionsHaveCompleted(String param1, String param2);
  147. ----
  148. And then, instead of calling `log.info(...)`, you call the method, for example `log.fiveTransactionsHaveCompleted(param1, param2)`.
  149. If what you're trying to log is an error or similar message and you want an exception to be logged as cause, simply use `@Cause` annotation:
  150. [source,java]
  151. ----
  152. @LogMessage(level = ERROR)
  153. @Message(value = "An error message: %s", id = 600)
  154. void anErrorMessage(String param1, @Cause IllegalStateException e);
  155. ----
  156. The last thing to figure out is which id to give to the message. Each module that logs something in production code that could be internationalized has been given an id range, and so the messages should use an available id in the range for the module where the log call resides. Here are the id range assignments per module:
  157. [options="header"]
  158. |===============
  159. |Module name|Id range
  160. |core|1 - 1000
  161. |tree|2001 - 3000
  162. |bdbje cache store|2001 - 3000
  163. |cassandra cache store|3001 - 4000
  164. |hotrod client|4001 - 5000
  165. |server core|5001 - 6000
  166. |server hotrod|6001 - 7000
  167. |cloud cache store|7001 - 8000
  168. |jdbc cache store|8001 - 9000
  169. |jdbm cache store|9001 - 10000
  170. |remote cache store|10001 - 11000
  171. |server memcached|11001 - 12000
  172. |server rest|12001 - 13000
  173. |server websocket|13001 - 14000
  174. |query|14001 - 14800
  175. |query-dsl|14801 - 15000
  176. |lucene directory|15001 - 16000
  177. |<no longer used>|16001 - 17000
  178. |cdi integration|17001 - 18000
  179. |hbase cache store|18001 - 19000
  180. |cli interpreter|19001 - 20000
  181. |cli client|20001 - 21000
  182. |mongodb cache store|21001 - 22000
  183. |rest cache store|22001 - 23000
  184. |leveldb cache store|23001 - 24000
  185. |couchbase cache store|24001 - 25000
  186. |redis cache store|25001 - 26000
  187. |extended statistics|25001 - 26000
  188. |infinispan directory provider|26001 - 27000
  189. |scripting|26001 - 27000
  190. |tasks|27001 - 28000
  191. |remote query server|28001 - 28500
  192. |object filter|28501 - 29000
  193. |===============
  194. NOTE: When editing the above table, remember to update the README-i18n.txt file in the project sources!
  195. NOTE: You will need to enable annotation processing in order to be able to compile Infinispan and have the logger implementation generated.