Developers' Best Practices » History » Version 5
Alessia Bardi, 29/01/2014 11:38 AM
Update trunk version after releasing. Added links to version management in Maven 3.
| 1 | 1 | Alessia Bardi | h1. Developers' Best Practices |
|---|---|---|---|
| 2 | |||
| 3 | 3 | Claudio Atzori | It is time for D-Net development teams to find a strategy to improve our developement work! |
| 4 | 1 | Alessia Bardi | |
| 5 | The introduction of Jenkins and Nexus helped a lot in terms of code management, but now it is time to establish a set of guidelines to better co-ordinate our teams. |
||
| 6 | The following best practices are inspired by CNR developers' common sense, so we do not assume they are written in stones and applies as they are also in your cases. |
||
| 7 | |||
| 8 | So, you are strongly invited to comment/update this wiki page, so that we can reach a consensus. |
||
| 9 | 3 | Claudio Atzori | |
| 10 | h2. Coding |
||
| 11 | |||
| 12 | Most of the D-Net modules have been migrated to from the old build system ant to maven. This implies some changes to the module directories and files, here's the migration guide: |
||
| 13 | http://ci.research-infrastructures.eu/public/docbook/MavenMigration.html |
||
| 14 | |||
| 15 | Maven compliant D-Net module structure: |
||
| 16 | |||
| 17 | <pre> |
||
| 18 | . |
||
| 19 | ├── pom.xml |
||
| 20 | ├── src |
||
| 21 | │ ├── main |
||
| 22 | │ │ ├── java |
||
| 23 | │ │ │ └── eu |
||
| 24 | │ │ │ └── dnetlib |
||
| 25 | │ │ └── resources |
||
| 26 | │ │ └── eu |
||
| 27 | │ │ └── dnetlib |
||
| 28 | │ └── test |
||
| 29 | │ ├── java |
||
| 30 | │ │ └── eu |
||
| 31 | │ │ └── dnetlib |
||
| 32 | │ └── resources |
||
| 33 | │ └── eu |
||
| 34 | │ └── dnetlib |
||
| 35 | └── target |
||
| 36 | └── classes |
||
| 37 | </pre> |
||
| 38 | |||
| 39 | Hint: consider to define the svn:ignore property, set on the module root |
||
| 40 | |||
| 41 | <pre> |
||
| 42 | cd <MODULE_NAME> |
||
| 43 | svn pe svn:ignore . |
||
| 44 | |||
| 45 | .classpath |
||
| 46 | .project |
||
| 47 | .settings |
||
| 48 | target |
||
| 49 | </pre> |
||
| 50 | 1 | Alessia Bardi | |
| 51 | h2. Branching |
||
| 52 | |||
| 53 | It is always recommended to create a new branch when performing heavy changes to a module, rather than directly into trunk. |
||
| 54 | |||
| 55 | 2 | Claudio Atzori | h2. Use CI: trust Jenkins! |
| 56 | 1 | Alessia Bardi | |
| 57 | The developer should clean the @.m2/repository/eu@ local repository from time to time to be sure that there are no modules installed locally. |
||
| 58 | |||
| 59 | Modules should be downloaded from Nexus in order to properly resolve dependencies. |
||
| 60 | |||
| 61 | 5 | Alessia Bardi | h2. Maven dependencies |
| 62 | |||
| 63 | For information about version conflict resolution with Maven3: |
||
| 64 | * http://docs.codehaus.org/display/MAVEN/Versioning |
||
| 65 | * https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Compatibility+Notes |
||
| 66 | |||
| 67 | Generally speaking, we suggest to use the keyword @LATEST@ to refer to the last available artifact (snapshot or release) for a module. |
||
| 68 | Keep in mind that Maven3 considers: |
||
| 69 | @1.0-alpha-1 < 1.0-beta-1 < 1.0-SNAPSHOT < 1.0 < 1.1-SNAPSHOT@ |
||
| 70 | |||
| 71 | 1 | Alessia Bardi | h2. Release Best Practices |
| 72 | |||
| 73 | h3. When/Why releasing a module? |
||
| 74 | |||
| 75 | * Generally speaking a developer should release a module when the code is mature enough to be used by others. |
||
| 76 | * An early release should be available in case others are relying on a module that is currently under heavy development (i.e., frequent commits that imply frequent snapshot updates), in order to avoid blocking other development activities. |
||
| 77 | * Before updating an interface (e.g., service interfaces) or library (e.g., common and utilities modules) a developer MUST ENSURE there is a release of the current version. |
||
| 78 | |||
| 79 | h3. How to assign a release version number? |
||
| 80 | |||
| 81 | Before releasing a module, you must check which kinds of changes have been performed since the last release. |
||
| 82 | @svn log@ is your friend here :) . |
||
| 83 | Depending on the kind of changes you can decide to increase the artifact version according to the following guidelines: |
||
| 84 | * BIG CHANGES impact the MAJOR version number. Ex. @0.0.1 --> 1.0.0@ |
||
| 85 | ** Examples of big changes are: updates to service interfaces, shared libraries, new functionalities. |
||
| 86 | * MINOR CHANGES impact the MINOR version number. Ex. @1.2.5 --> 1.3.0@ |
||
| 87 | ** Examples of minor changes are: service internals, non-shared code and libraries, important bug fixes. |
||
| 88 | * BUG FIXES impact the BUILD version number. Ex. @1.4.2 --> 1.4.3@ |
||
| 89 | ** Examples are small bug fixes that do not affect other components |
||
| 90 | |||
| 91 | h3. How to release? |
||
| 92 | |||
| 93 | These are the steps for the release of a module, given that developer has a fresh checkout of the module to be released. |
||
| 94 | |||
| 95 | # Ensure that the module to be released and the modules depending on it compile fine on Jenkins (http://ci.research-infrastructures.eu/). |
||
| 96 | # Update and commit the version of the module (trunk) to be released according to the guidelines above. |
||
| 97 | This maven command can be helpful: |
||
| 98 | @mvn versions:set -DnewVersion={release_version}-SNAPSHOT@ |
||
| 99 | # Copy the trunk source code to a release branch: |
||
| 100 | 4 | Claudio Atzori | @svn cp https://svn.driver.../modules/{MODULE_NAME}/trunk https://svn.driver.../modules/{MODULE_NAME}/releases/{release_version}@ |
| 101 | 1 | Alessia Bardi | # Switch to the release branch: |
| 102 | 4 | Claudio Atzori | @svn switch https://svn.driver.../modules/{MODULE_NAME}/releases/{release_version}@ |
| 103 | 1 | Alessia Bardi | # A released module MUST depend and inherit ONLY from released modules. Therefore the pom.xml file MUST be updated as follows: |
| 104 | ## change the parent version to a released version. Current is 0.0.1-alpha. |
||
| 105 | ## change all snapshot dependencies to a released version. Ex. @0.2.3-SNAPSHOT --> 0.2.3@ |
||
| 106 | ## change the artifact version by removing the @-SNAPSHOT@ suffix. |
||
| 107 | # Commit the updated pom.xml. |
||
| 108 | # Ensure the module compiles: @mvn clean compile package -U@ |
||
| 109 | # Create the release build job on Jenkins (http://ci.research-infrastructures.eu/): |
||
| 110 | ## Select "New job" |
||
| 111 | ## Type in the name of the job as |
||
| 112 | @[module name]-release-[version]@. Ex. @dnet-runtime-release-0.0.9@ |
||
| 113 | 4 | Claudio Atzori | ## Select "Create from existing job" and type in @dnet-svn-template-release@, then press OK |
| 114 | ## Modify the repository URL so that it matches the svn public folder of the release branch: |
||
| 115 | 1 | Alessia Bardi | http://svn-public.driver.../modules/{MODULE_NAME}/releases/{release_version} |
| 116 | ## Save, enable the job, start the job, watch it compile, ensure it is deployed on nexus, disable the job again (an artifact on the dnet-release repository cannot be overwritten, hence we disable the job just to be sure they are not fired again by mistake). |
||
| 117 | 5 | Alessia Bardi | # Switch back to trunk: |
| 118 | @svn switch https://svn.driver.../modules/{MODULE_NAME}/trunk@ |
||
| 119 | # Increase the build version number and commit the pom.xml. Example: if the version is @1.2.3-SNAPSHOT@ (it means that you've just released version @1.2.3@), increase the number to @1.2.4-SNAPSHOT@. |
||
| 120 | 1 | Alessia Bardi | |
| 121 | 5 | Alessia Bardi | Possibly a script will be made available to cover the points from 2 to 7, 9, and 10. |