| 1 |
-------------- |
| 2 |
Maven SCM Jazz Provider - Working with the Release Plugin |
| 3 |
-------------- |
| 4 |
Chris Graham |
| 5 |
-------------- |
| 6 |
2012-03-19 |
| 7 |
-------------- |
| 8 |
|
| 9 |
~~ Licensed to the Apache Software Foundation (ASF) under one |
| 10 |
~~ or more contributor license agreements. See the NOTICE file |
| 11 |
~~ distributed with this work for additional information |
| 12 |
~~ regarding copyright ownership. The ASF licenses this file |
| 13 |
~~ to you under the Apache License, Version 2.0 (the |
| 14 |
~~ "License"); you may not use this file except in compliance |
| 15 |
~~ with the License. You may obtain a copy of the License at |
| 16 |
~~ |
| 17 |
~~ http://www.apache.org/licenses/LICENSE-2.0 |
| 18 |
~~ |
| 19 |
~~ Unless required by applicable law or agreed to in writing, |
| 20 |
~~ software distributed under the License is distributed on an |
| 21 |
~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 22 |
~~ KIND, either express or implied. See the License for the |
| 23 |
~~ specific language governing permissions and limitations |
| 24 |
~~ under the License. |
| 25 |
|
| 26 |
~~ NOTE: For help with the syntax of this file, see: |
| 27 |
~~ http://maven.apache.org/doxia/references/apt-format.html |
| 28 |
|
| 29 |
Using the Release Plugin with the Jazz SCM provider. |
| 30 |
|
| 31 |
Maven Releases |
| 32 |
|
| 33 |
The normal Maven process of creating a release using the Maven Release Plugin |
| 34 |
involves a two step process. |
| 35 |
|
| 36 |
The first step, <<<mvn release:prepare>>> consists of the following phases: |
| 37 |
|
| 38 |
* check-poms |
| 39 |
|
| 40 |
* scm-check-modifications |
| 41 |
|
| 42 |
* check-dependency-snapshots |
| 43 |
|
| 44 |
* create-backup-poms |
| 45 |
|
| 46 |
* map-release-versions |
| 47 |
|
| 48 |
* input-variables |
| 49 |
|
| 50 |
* map-development-versions |
| 51 |
|
| 52 |
* rewrite-poms-for-release |
| 53 |
|
| 54 |
* generate-release-poms |
| 55 |
|
| 56 |
* run-preparation-goals |
| 57 |
|
| 58 |
* scm-commit-release |
| 59 |
|
| 60 |
* scm-tag |
| 61 |
|
| 62 |
* rewrite-poms-for-development |
| 63 |
|
| 64 |
* remove-release-poms |
| 65 |
|
| 66 |
* run-completion-goals |
| 67 |
|
| 68 |
* scm-commit-development |
| 69 |
|
| 70 |
* end-release |
| 71 |
|
| 72 |
[] |
| 73 |
|
| 74 |
The tag operation should, as per good SCM practices and Maven best practices, |
| 75 |
create a tag of just that module, and any sub modules in a multi-module project. |
| 76 |
|
| 77 |
The second step, <<<mvn release:perform>>>, consists of the following phases: |
| 78 |
|
| 79 |
* verify-completed-prepare-phases |
| 80 |
|
| 81 |
* checkout-project-from-scm |
| 82 |
|
| 83 |
* run-perform-goals |
| 84 |
|
| 85 |
[] |
| 86 |
|
| 87 |
The <<<scm create snapshot>>> command, used to implement the Maven SCM Tag command, |
| 88 |
creates an implicit baseline of *ALL* components within the repository workspace. |
| 89 |
For this reason, it is *very strongly* recommended that only a single component |
| 90 |
reside in the repository workspace being used to perform the release. |
| 91 |
|
| 92 |
A simple suggestion is to use a naming standard of: \<ComponentName\>BuildWorkspace |
| 93 |
for Repository Workspace names used to perform releases. |
| 94 |
|
| 95 |
Or, put in a Maven context, tagging multiple projects at the same time, |
| 96 |
makes absolutely no sense. |
| 97 |
|
| 98 |
Now, the question becomes, how do we organise our repository workspaces? |
| 99 |
|
| 100 |
Repository Workspace Organisation |
| 101 |
|
| 102 |
A suggestion of how a developer can work with Maven, multiple components |
| 103 |
and multiple developers is shown below. |
| 104 |
|
| 105 |
[images/FlowDiagram.png] Developer Repository Workspaces, Release Repository Workspaces and Streams. |
| 106 |
|
| 107 |
The important thing to note, is that a developer can have multiple components, |
| 108 |
multiple flow targets. They can quite easily use the usual <<<mvn clean install>>> |
| 109 |
from their Eclipse workspace. |
| 110 |
|
| 111 |
They should not, however, attempt to run the release plugin from these environments. |
| 112 |
|
| 113 |
It is very strongly recommended that a separate repository workspace, containing just one |
| 114 |
component, the component to be released, be set up for exactly this purpose. |
| 115 |
This repository workspace should only have one flow target, which would normally be a stream. |
| 116 |
Should the repository workspace have multiple flow targets, the flow target marked as "current" |
| 117 |
will be the one where the changes are flowed to. |
| 118 |
However, this provider also works perfectly well with a standalone repository workspace, ie, |
| 119 |
no flow targets. |
| 120 |
|
| 121 |
This means that the <<<scm>>> settings in the pom must to be configured for the build repository |
| 122 |
workspace, not the developer's repository workspace. As the developers should not be performing |
| 123 |
a release, this will not effect them; they will not need to modify the <<<scm>>> |
| 124 |
section in the pom to point to their specific repository workspace. |
| 125 |
|
| 126 |
This is what the <<<scm>>> section of the pom.xml file could look like: |
| 127 |
|
| 128 |
+-- |
| 129 |
<scm> |
| 130 |
<url>https://rtc:9444/jazz:GPDBBuildWorkspace</url> |
| 131 |
<connection>scm:jazz:https://rtc:9444/jazz:GPDBBuildWorkspace</connection> |
| 132 |
<developerConnection>scm:jazz:https://rtc:9444/jazz:GPDBBuildWorkspace</developerConnection> |
| 133 |
</scm> |
| 134 |
+-- |
| 135 |
|
| 136 |
As the username and password are not in the pom.xml, they must be obtained from the user's <<<settings.xml>>> file. |
| 137 |
This is a sample of what the <<<server>>> section of the settings.xml file could look like: |
| 138 |
|
| 139 |
+-- |
| 140 |
<servers> |
| 141 |
|
| 142 |
<server> |
| 143 |
<id>rtc:9444</id> |
| 144 |
<username>build</username> |
| 145 |
<password>build</password> |
| 146 |
</server> |
| 147 |
|
| 148 |
</servers> |
| 149 |
+-- |
| 150 |
|
| 151 |
In this example, we are using the <<<build>>> user. The GPDBBuildWorkspace would be owned by the <<<build>>> user. |
| 152 |
|
| 153 |
Working with Multiple Streams |
| 154 |
|
| 155 |
The next step in the normal evolution of a software project would be to start development work on the next release or |
| 156 |
version of the software. Let's call it Release 2. Ordinarily, you would create a branch to operate in. In Jazz SCM, we |
| 157 |
create a Stream. |
| 158 |
|
| 159 |
The image below illustrates how this can be achieved: |
| 160 |
|
| 161 |
[images/FlowDiagramWithMultipleStreams.png] Developer Repository Workspaces, Release Repository Workspaces with Multiple Streams. |
| 162 |
|
| 163 |
All of the initial repository workspaces flow into the development stream (all implicitly Release 1). When the new |
| 164 |
stream for release 2 has been created, the (Release 1) Development Stream is modified so that it has a flow target |
| 165 |
of the Release 2 Development Stream. The repository workspaces for the Release 2 work are then created and their |
| 166 |
flow targets flow back to the Release 2 Development Stream. |
| 167 |
|
| 168 |
The repository workspaces for the build are again created, and the <<<scm>>> section of the pom.xml file could look like: |
| 169 |
|
| 170 |
+-- |
| 171 |
<scm> |
| 172 |
<url>https://rtc:9444/jazz:GPDBBuildR2Workspace</url> |
| 173 |
<connection>scm:jazz:https://rtc:9444/jazz:GPDBBuildR2Workspace</connection> |
| 174 |
<developerConnection>scm:jazz:https://rtc:9444/jazz:GPDBBuildR2Workspace</developerConnection> |
| 175 |
</scm> |
| 176 |
+-- |
| 177 |
|
| 178 |
Working with the Release Plugin |
| 179 |
|
| 180 |
We are able to use the <<<release:prepare>>> and <<<release:perform>>> goals in the one invocation, |
| 181 |
however, due to the sandbox within a sandbox issues discussed, we need to use the <<<workingDirectory>>> |
| 182 |
option. |
| 183 |
|
| 184 |
Here is a sample: |
| 185 |
|
| 186 |
+-- |
| 187 |
mvn -B -Dresume=false -DworkingDirectory=/tmp/maven release:prepare release:perform |
| 188 |
+-- |
| 189 |
|