├── .github ├── dependabot.yml ├── release-drafter.yml └── workflows │ ├── maven.yml │ ├── release-drafter.yml │ └── stale.yml ├── .gitignore ├── LICENSE.txt ├── README.md ├── pom.xml └── src ├── main ├── java │ └── org │ │ └── codehaus │ │ └── mojo │ │ └── build │ │ ├── AbstractScmMojo.java │ │ ├── CreateMetadataMojo.java │ │ ├── CreateMojo.java │ │ ├── CreateTimestampMojo.java │ │ ├── HgChangeSetMojo.java │ │ ├── HgOutputConsumer.java │ │ ├── JsonOutputFormat.java │ │ ├── OutputFormat.java │ │ ├── PropertiesOutputFormat.java │ │ └── Utils.java └── resources │ └── META-INF │ └── plexus │ └── components.xml ├── site ├── apt │ ├── index.apt │ └── usage.apt.vm ├── fml │ └── faq.fml └── site.xml └── test ├── java └── org │ └── codehaus │ └── mojo │ └── build │ ├── JsonOutputFormatTest.java │ ├── OutputFormatTest.java │ ├── PropertiesOutputFormatTest.java │ ├── TestCreateMojo.java │ └── it │ ├── BuildNumberMojoTest.java │ └── CreateMetadataMojoTest.java ├── projects ├── MBUILDNUM-5 │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── a │ │ │ └── b │ │ │ └── c │ │ │ └── d │ │ │ └── e │ │ │ └── f │ │ │ └── g │ │ │ └── h │ │ │ └── i │ │ │ └── j │ │ │ └── k │ │ │ └── l │ │ │ └── m │ │ │ └── n │ │ │ └── o │ │ │ └── p │ │ │ └── q │ │ │ └── r │ │ │ └── s │ │ │ └── t │ │ │ └── u │ │ │ └── v │ │ │ └── w │ │ │ └── x │ │ │ └── y │ │ │ └── z │ │ │ └── ApacheMavenRocks.java │ └── verify.bsh ├── MBUILDNUM-83 │ └── pom.xml ├── MBUILDNUM-85 │ ├── pom.xml │ └── some.properties ├── MOJO-1372 │ └── pom.xml ├── MOJO-1668 │ ├── dotSvnDir │ │ ├── entries │ │ ├── format │ │ ├── pristine │ │ │ ├── 66 │ │ │ │ └── 665af71baa943cdae96c0623d3c24e6ec712ec9b.svn-base │ │ │ ├── 85 │ │ │ │ └── 85ead35ecb9e8e8eabe052fe4b3156db3e83741e.svn-base │ │ │ └── 8c │ │ │ │ └── 8c5cf4e025a5aa01f7278074c12ac6723ab14533.svn-base │ │ └── wc.db │ └── pom.xml ├── basic-it-clearcase-scm │ └── pom.xml ├── basic-it-git │ ├── dotGitDir │ │ ├── HEAD │ │ ├── config │ │ ├── description │ │ ├── index │ │ ├── info │ │ │ └── exclude │ │ ├── objects │ │ │ ├── 0a │ │ │ │ └── 129e164de5b62edb46d1aa0feef56a34941ac2 │ │ │ ├── 6d │ │ │ │ └── 36c746e82f00c5913954f9178f40224497b2f3 │ │ │ └── d3 │ │ │ │ └── a01ee82b5e7da3c2193fe952858d152ceb6505 │ │ └── refs │ │ │ └── heads │ │ │ └── master │ └── pom.xml ├── basic-it-no-devscm │ ├── dotSvnDir │ │ ├── all-wcprops │ │ ├── entries │ │ ├── format │ │ ├── pristine │ │ │ ├── 66 │ │ │ │ └── 665af71baa943cdae96c0623d3c24e6ec712ec9b.svn-base │ │ │ ├── a7 │ │ │ │ └── a750eb2c5a1c425e5d3886eecde6b6a98bdb399f.svn-base │ │ │ └── b8 │ │ │ │ └── b87a2294a5074b47315f9fac29b4930d2a2b7ae5.svn-base │ │ ├── prop-base │ │ │ ├── goals.txt.svn-base │ │ │ ├── pom.xml.svn-base │ │ │ └── verify.bsh.svn-base │ │ ├── text-base │ │ │ ├── goals.txt.svn-base │ │ │ ├── pom.xml.svn-base │ │ │ ├── prebuild.groovy.svn-base │ │ │ └── verify.bsh.svn-base │ │ └── wc.db │ └── pom.xml ├── basic-it-svnjava │ ├── dotSvnDir │ │ ├── entries │ │ ├── format │ │ ├── pristine │ │ │ ├── 66 │ │ │ │ └── 665af71baa943cdae96c0623d3c24e6ec712ec9b.svn-base │ │ │ ├── 69 │ │ │ │ └── 69cf779236fb30b6c4f2880001ec9dd23bdcd5b8.svn-base │ │ │ └── 76 │ │ │ │ └── 76ff7cf8f7fb9790d8c2819c640d641d4ff2093f.svn-base │ │ └── wc.db │ └── pom.xml ├── basic-it │ ├── dotSvnDir │ │ ├── all-wcprops │ │ ├── entries │ │ ├── format │ │ ├── pristine │ │ │ ├── 42 │ │ │ │ └── 4256c3d83776cf1d5a315b293085a7dc240c92cb.svn-base │ │ │ ├── 66 │ │ │ │ └── 665af71baa943cdae96c0623d3c24e6ec712ec9b.svn-base │ │ │ └── be │ │ │ │ └── be81b1b83de4bd67f35fdab9bd4707604ab1c092.svn-base │ │ ├── prop-base │ │ │ ├── goals.txt.svn-base │ │ │ ├── pom.xml.svn-base │ │ │ └── verify.bsh.svn-base │ │ ├── text-base │ │ │ ├── goals.txt.svn-base │ │ │ ├── pom.xml.svn-base │ │ │ ├── prebuild.groovy.svn-base │ │ │ └── verify.bsh.svn-base │ │ └── wc.db │ └── pom.xml ├── create-metadata-it-no-scm │ └── pom.xml ├── create-metadata-it │ └── pom.xml ├── create-metadata-json-it │ └── pom.xml ├── create-timestamp-it │ └── pom.xml ├── failed-local-change │ ├── dotSvnDir │ │ ├── entries │ │ ├── format │ │ ├── pristine │ │ │ ├── 25 │ │ │ │ └── 25f1c1a58e866ed76b657410f17ca48d4484de36.svn-base │ │ │ ├── 2a │ │ │ │ └── 2afd738d40bbd3cc7e848d611404949c779db22f.svn-base │ │ │ ├── bc │ │ │ │ └── bc297aecdc5665a9e47a19b7876b07cef3a8c161.svn-base │ │ │ └── d8 │ │ │ │ └── d8f6dc5ed1a19e5d6c0fa3f9f8b1a2bd6b76042c.svn-base │ │ └── wc.db │ ├── foo.txt │ └── pom.xml ├── git-basic-it-MBUILDNUM-66 │ ├── .gitignore │ ├── dotGitDir │ │ ├── COMMIT_EDITMSG │ │ ├── HEAD │ │ ├── config │ │ ├── description │ │ ├── hooks │ │ │ ├── applypatch-msg.sample │ │ │ ├── commit-msg.sample │ │ │ ├── post-update.sample │ │ │ ├── pre-applypatch.sample │ │ │ ├── pre-commit.sample │ │ │ ├── pre-push.sample │ │ │ ├── pre-rebase.sample │ │ │ ├── prepare-commit-msg.sample │ │ │ └── update.sample │ │ ├── index │ │ ├── info │ │ │ └── exclude │ │ ├── logs │ │ │ ├── HEAD │ │ │ └── refs │ │ │ │ └── heads │ │ │ │ └── master │ │ ├── objects │ │ │ ├── 31 │ │ │ │ └── ed2f87a271c293b2727ef50e36f871201ff06b │ │ │ ├── 64 │ │ │ │ └── e108d3f1835cc2691abbe3f987743da2447f7e │ │ │ ├── 79 │ │ │ │ └── 4b0e3da190e2acb55f414ff28ba04485af3659 │ │ │ ├── 81 │ │ │ │ └── d25d673c300ee5e802130f1f92fff58d5e1576 │ │ │ ├── 2f │ │ │ │ └── 7896d1d1365eafb0da03d9fe456fac81408487 │ │ │ ├── 4b │ │ │ │ └── 825dc642cb6eb9a060e54bf8d69288fbee4904 │ │ │ ├── a0 │ │ │ │ └── 5cc0d64f5cebad8a332c957dbd6d98024e8e62 │ │ │ ├── b4 │ │ │ │ └── 6131b51b0e59b4fcdf88ee76060aa0d099b36e │ │ │ ├── c5 │ │ │ │ └── ff2ebf8dc0ff4568b1d63905c83fa11942e55e │ │ │ ├── e9 │ │ │ │ └── 2ca4d934e31f2f3b4f7392361b32b46dec7863 │ │ │ └── ee │ │ │ │ └── 58acb27b6636a497c1185f80cd15f76134113f │ │ └── refs │ │ │ └── heads │ │ │ └── master │ └── pom.xml ├── help-it │ └── pom.xml ├── legacy-timestamp-it │ └── pom.xml ├── norevision-it │ └── pom.xml ├── settings.xml └── skip-it │ └── pom.xml └── resources └── svnOutput-1.xml /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "maven" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | - package-ecosystem: "github-actions" 8 | directory: "/" 9 | schedule: 10 | interval: "daily" 11 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | _extends: .github 2 | name-template: '$RESOLVED_VERSION' 3 | tag-template: 'buildnumber-maven-plugin-$RESOLVED_VERSION' 4 | version-resolver: 5 | major: 6 | labels: 7 | - major 8 | minor: 9 | labels: 10 | - minor 11 | - enhancement 12 | patch: 13 | labels: 14 | - patch 15 | default: patch 16 | template: | 17 | ## Changes 18 | 19 | $CHANGES -------------------------------------------------------------------------------- /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | name: GitHub CI 19 | 20 | 21 | on: [push, pull_request] 22 | 23 | jobs: 24 | build: 25 | name: Verify 26 | uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4 27 | -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | on: 3 | push: 4 | branches: 5 | - master 6 | workflow_dispatch: 7 | jobs: 8 | update_release_draft: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: release-drafter/release-drafter@v6 12 | env: 13 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 14 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: 'Close stale PR' 2 | on: 3 | schedule: 4 | - cron: '30 1 * * *' 5 | 6 | jobs: 7 | stale: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/stale@v9 11 | with: 12 | repo-token: ${{ secrets.GITHUB_TOKEN }} 13 | stale-pr-message: 'This PR is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 30 days.' 14 | days-before-stale: 365 15 | days-before-pr-close: 30 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .settings 3 | .classpath 4 | .project 5 | *.iml 6 | .idea/ 7 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2005 Learning Commons, University of Calgary 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a 6 | copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MojoHaus BuildNumber Maven Plugin 2 | 3 | This is the [buildnumber-maven-plugin](http://www.mojohaus.org/buildnumber-maven-plugin/). 4 | 5 | [](https://opensource.org/licenses/MIT) 6 | [](https://search.maven.org/artifact/org.codehaus.mojo/buildnumber-maven-plugin) 7 | [](https://github.com/mojohaus/buildnumber-maven-plugin/actions/workflows/maven.yml?query=branch%3Amaster) 8 | 9 | ## Releasing 10 | 11 | * Make sure `gpg-agent` is running. 12 | * subversion `svn` is also needed for running tests 13 | * Make sure all tests pass `mvn clean verify -Prun-its` 14 | * Execute `mvn -B release:prepare release:perform` 15 | 16 | For publishing the site do the following: 17 | 18 | ``` 19 | cd target/checkout 20 | mvn verify site site:stage scm-publish:publish-scm 21 | ``` 22 | 23 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.codehaus.mojo 7 | mojo-parent 8 | 91 9 | 10 | 11 | buildnumber-maven-plugin 12 | 3.2.2-SNAPSHOT 13 | maven-plugin 14 | 15 | Build Number Maven Plugin 16 | This plugin is designed to give you a build number. So when you might make 100 builds of version 17 | 1.0-SNAPSHOT, you can differentiate between them all. 18 | 19 | https://www.mojohaus.org/buildnumber-maven-plugin/ 20 | 2007 21 | 22 | 23 | 24 | The MIT License 25 | https://spdx.org/licenses/MIT.txt 26 | repo 27 | 28 | 29 | 30 | 31 | 32 | woodj 33 | Julian Wood 34 | woodj@ucalgary.ca 35 | Learning Commons, University of Calgary 36 | https://commons.ucalgary.ca 37 | 38 | Programmer 39 | 40 | 41 | 42 | olamy 43 | Olivier Lamy 44 | olamy@apache.org 45 | 46 | developer 47 | 48 | 49 | 50 | bimargulies 51 | Benson Margulies 52 | bimargulies@apache.org 53 | 54 | developer 55 | 56 | 57 | 58 | khmarbaise 59 | Karl Heinz Marbaise 60 | khmarbaise@apache.org 61 | 62 | developer 63 | 64 | 65 | 66 | 67 | 68 | ${mavenVersion} 69 | 70 | 71 | 72 | scm:git:https://github.com/mojohaus/buildnumber-maven-plugin.git 73 | scm:git:https://github.com/mojohaus/buildnumber-maven-plugin.git 74 | HEAD 75 | https://github.com/mojohaus/buildnumber-maven-plugin/tree/master 76 | 77 | 78 | 79 | GitHub 80 | https://github.com/mojohaus/buildnumber-maven-plugin/issues 81 | 82 | 83 | 84 | 2.1.0 85 | 8 86 | ${mavenVersion} 87 | 3.0.0 88 | 2.0.8 89 | **/it/** 90 | target/staging/${project.artifactId} 91 | 2024-09-03T00:19:36Z 92 | 93 | 94 | 95 | 96 | org.apache.maven 97 | maven-settings 98 | ${mavenVersion} 99 | provided 100 | 101 | 102 | org.apache.maven 103 | maven-core 104 | ${mavenVersion} 105 | provided 106 | 107 | 108 | org.apache.maven 109 | maven-plugin-api 110 | ${mavenVersion} 111 | provided 112 | 113 | 114 | 115 | org.apache.maven.scm 116 | maven-scm-api 117 | ${maven.scm.version} 118 | compile 119 | 120 | 121 | org.apache.maven.scm 122 | maven-scm-manager-plexus 123 | ${maven.scm.version} 124 | compile 125 | 126 | 127 | org.codehaus.plexus 128 | plexus-container-default 129 | 130 | 131 | 132 | 133 | org.apache.maven.scm 134 | maven-scm-provider-svnexe 135 | ${maven.scm.version} 136 | compile 137 | 138 | 139 | org.apache.maven.scm 140 | maven-scm-provider-gitexe 141 | ${maven.scm.version} 142 | compile 143 | 144 | 145 | org.apache.maven.scm 146 | maven-scm-provider-svn-commons 147 | ${maven.scm.version} 148 | compile 149 | 150 | 151 | org.apache.maven.scm 152 | maven-scm-provider-hg 153 | ${maven.scm.version} 154 | compile 155 | 156 | 157 | 158 | com.google.code.maven-scm-provider-svnjava 159 | maven-scm-provider-svnjava 160 | 2.3.0 161 | compile 162 | 163 | 166 | 167 | org.tmatesoft.svnkit 168 | svnkit 169 | 170 | 171 | 172 | 173 | org.tmatesoft.svnkit 174 | svnkit 175 | 1.10.11 176 | compile 177 | 178 | 179 | org.codehaus.plexus 180 | plexus-utils 181 | 4.0.2 182 | 183 | 184 | org.codehaus.plexus 185 | plexus-xml 186 | 3.0.1 187 | 188 | 189 | org.apache.maven.plugin-tools 190 | maven-plugin-annotations 191 | provided 192 | 193 | 194 | 195 | org.sonatype.plexus 196 | plexus-sec-dispatcher 197 | 1.4 198 | compile 199 | 200 | 201 | 202 | io.takari.maven.plugins 203 | takari-plugin-testing 204 | ${takari.plugin.testing.version} 205 | test 206 | 207 | 208 | 209 | io.takari.maven.plugins 210 | takari-plugin-integration-testing 211 | ${takari.plugin.testing.version} 212 | pom 213 | test 214 | 215 | 216 | 217 | com.google.code.gson 218 | gson 219 | 2.13.1 220 | compile 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | org.apache.maven.plugins 230 | maven-surefire-plugin 231 | 232 | false 233 | 234 | ${test.excludes} 235 | 236 | 237 | 238 | 239 | org.apache.maven.plugins 240 | maven-javadoc-plugin 241 | 242 | false 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | run-its 253 | 254 | true 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | org.apache.maven.plugins 263 | maven-dependency-plugin 264 | 265 | 266 | unpack 267 | 268 | unpack 269 | 270 | generate-test-resources 271 | 272 | ${project.build.directory}/maven-installation 273 | 274 | 275 | org.apache.maven 276 | apache-maven 277 | ${maven.it.version} 278 | bin 279 | tar.gz 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | org.apache.maven.plugins 288 | maven-enforcer-plugin 289 | 290 | 291 | org.codehaus.mojo 292 | extra-enforcer-rules 293 | 1.10.0 294 | 295 | 296 | 297 | 298 | enforce-versions 299 | 300 | enforce 301 | 302 | 303 | 304 | 305 | ${mojo.java.target} 306 | 307 | io.takari.* 308 | org.codehaus.plexus:plexus-classworlds 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | io.takari.maven.plugins 319 | takari-lifecycle-plugin 320 | ${takari-lifecycle-plugin.version} 321 | true 322 | 323 | 324 | testProperties 325 | 326 | testProperties 327 | 328 | process-test-resources 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | devlocal 338 | 339 | 340 | 341 | org.codehaus.mojo 342 | buildnumber-maven-plugin 343 | ${project.version} 344 | 345 | 346 | useLastCommittedRevision 347 | 348 | create 349 | 350 | compile 351 | 352 | 353 | javasvn 354 | 355 | true 356 | true 357 | 358 | 359 | 360 | timestampFormat 361 | 362 | create 363 | 364 | test 365 | 366 | 367 | javasvn 368 | 369 | true 370 | yyyy-MM-dd 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/build/AbstractScmMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.build; 2 | 3 | /** 4 | * The MIT License 5 | * 6 | * Copyright (c) 2015 Codehaus 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 9 | * associated documentation files (the "Software"), to deal in the Software without restriction, 10 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 11 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all copies or 15 | * substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 18 | * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | */ 23 | import java.io.File; 24 | 25 | import org.apache.maven.plugin.AbstractMojo; 26 | import org.apache.maven.plugins.annotations.Component; 27 | import org.apache.maven.plugins.annotations.Parameter; 28 | import org.apache.maven.project.MavenProject; 29 | import org.apache.maven.scm.CommandParameter; 30 | import org.apache.maven.scm.CommandParameters; 31 | import org.apache.maven.scm.ScmException; 32 | import org.apache.maven.scm.ScmFileSet; 33 | import org.apache.maven.scm.ScmResult; 34 | import org.apache.maven.scm.ScmTag; 35 | import org.apache.maven.scm.command.info.InfoItem; 36 | import org.apache.maven.scm.command.info.InfoScmResult; 37 | import org.apache.maven.scm.manager.ScmManager; 38 | import org.apache.maven.scm.provider.ScmProviderRepository; 39 | import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost; 40 | import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository; 41 | import org.apache.maven.scm.repository.ScmRepository; 42 | import org.apache.maven.settings.Server; 43 | import org.apache.maven.settings.Settings; 44 | import org.codehaus.plexus.util.StringUtils; 45 | import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher; 46 | import org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException; 47 | 48 | public abstract class AbstractScmMojo extends AbstractMojo { 49 | /** 50 | * @since 1.0-beta-5 51 | */ 52 | @Parameter(defaultValue = "${project.scm.connection}", alias = "readUrlScm", readonly = true) 53 | protected String scmConnectionUrl; 54 | 55 | /** 56 | * @since 1.0-beta-5 57 | */ 58 | @Parameter(defaultValue = "${project.scm.developerConnection}", alias = "urlScm", readonly = true) 59 | protected String scmDeveloperConnectionUrl; 60 | 61 | /** 62 | * @since 1.4 63 | */ 64 | @Parameter(defaultValue = "${project.scm.tag}", readonly = true) 65 | protected String scmTag; 66 | 67 | /** 68 | * The username that is used when connecting to the SCM system. 69 | * 70 | * @since 1.0-beta-1 71 | */ 72 | @Parameter(property = "username") 73 | protected String username; 74 | 75 | /** 76 | * The password that is used when connecting to the SCM system. 77 | * 78 | * @since 1.0-beta-1 79 | */ 80 | @Parameter(property = "password") 81 | protected String password; 82 | 83 | /** 84 | * Issue SCM actions at this local directory 85 | * 86 | * @since 1.0-beta-1 87 | */ 88 | @Parameter(property = "maven.buildNumber.scmDirectory", defaultValue = "${basedir}") 89 | protected File scmDirectory; 90 | 91 | /** 92 | * Max length of a revision id (GIT only) 93 | * 94 | * @since 1.1 95 | */ 96 | @Parameter(property = "maven.buildNumber.shortRevisionLength", defaultValue = "0") 97 | protected int shortRevisionLength = 0; 98 | 99 | /** 100 | * Setting this value allows the build to continue even in the event of an SCM failure. The value set will be used 101 | * as the revision string in the event of a failure to retrieve the revision it from the SCM. 102 | * 103 | * @since 1.0-beta-2 104 | */ 105 | @Parameter(property = "maven.buildNumber.revisionOnScmFailure") 106 | protected String revisionOnScmFailure; 107 | 108 | /** 109 | * whether to retrieve the revision for the last commit, or the last revision of the repository. 110 | * 111 | * @since 1.0-beta-2 112 | */ 113 | @Parameter(property = "maven.buildNumber.useLastCommittedRevision", defaultValue = "false") 114 | private boolean useLastCommittedRevision; 115 | 116 | /** 117 | * Whether to skip this execution. 118 | * 119 | * @since 1.3 120 | */ 121 | @Parameter(property = "maven.buildNumber.skip", defaultValue = "false") 122 | protected boolean skip; 123 | 124 | /** 125 | * Maven Settings 126 | * 127 | * @since 1.4 128 | */ 129 | @Parameter(defaultValue = "${settings}", readonly = true) 130 | protected Settings settings; 131 | 132 | @Parameter(defaultValue = "${project}", required = true, readonly = true) 133 | protected MavenProject project; 134 | 135 | @Component 136 | protected ScmManager scmManager; 137 | 138 | /** 139 | * Ignore error when scm url from pom is empty and replace by scm:scmProvider {@link #scmProvider} 140 | * @since 3.2.1 141 | */ 142 | @Parameter(property = "maven.buildNumber.ignoreEmptyScmUrl", defaultValue = "false") 143 | private boolean ignoreEmptyScmUrl; 144 | 145 | /** 146 | * When scm url is empty, scm provider is needed {@link #ignoreEmptyScmUrl} 147 | * @since 3.2.1 148 | */ 149 | @Parameter(property = "maven.buildNumber.scmProvider", defaultValue = "git") 150 | private String scmProvider; 151 | 152 | /** 153 | * Maven Security Dispatcher 154 | * 155 | * @since 1.4 156 | */ 157 | @Component(hint = "mng-4384") 158 | private SecDispatcher securityDispatcher; 159 | 160 | /** 161 | * Load username password from settings. 162 | */ 163 | private void loadInfosFromSettings(ScmProviderRepositoryWithHost repo) { 164 | if (username == null || password == null) { 165 | String host = repo.getHost(); 166 | 167 | int port = repo.getPort(); 168 | 169 | if (port > 0) { 170 | host += ":" + port; 171 | } 172 | 173 | Server server = this.settings.getServer(host); 174 | 175 | if (server != null) { 176 | setPasswordIfNotEmpty(repo, decrypt(server.getPassword(), host)); 177 | 178 | setUserIfNotEmpty(repo, server.getUsername()); 179 | } 180 | } 181 | } 182 | 183 | private String decrypt(String str, String server) { 184 | try { 185 | return securityDispatcher.decrypt(str); 186 | } catch (SecDispatcherException e) { 187 | getLog().warn("Failed to decrypt password/passphrase for server " + server + ", using auth token as is"); 188 | return str; 189 | } 190 | } 191 | 192 | protected ScmRepository getScmRepository() throws ScmException { 193 | String repoUrl = !StringUtils.isBlank(this.scmConnectionUrl) ? scmConnectionUrl : scmDeveloperConnectionUrl; 194 | ScmRepository repository = scmManager.makeScmRepository( 195 | StringUtils.isBlank(repoUrl) ? (ignoreEmptyScmUrl ? "scm:" + scmProvider + ":" : "") : repoUrl); 196 | 197 | ScmProviderRepository scmRepo = repository.getProviderRepository(); 198 | 199 | if (scmRepo instanceof ScmProviderRepositoryWithHost) { 200 | loadInfosFromSettings((ScmProviderRepositoryWithHost) scmRepo); 201 | } 202 | 203 | setPasswordIfNotEmpty(scmRepo, password); 204 | 205 | setUserIfNotEmpty(scmRepo, username); 206 | 207 | return repository; 208 | } 209 | 210 | private void setPasswordIfNotEmpty(ScmProviderRepository repository, String password) { 211 | if (!StringUtils.isEmpty(password)) { 212 | repository.setPassword(password); 213 | } 214 | } 215 | 216 | private void setUserIfNotEmpty(ScmProviderRepository repository, String user) { 217 | if (!StringUtils.isEmpty(user)) { 218 | repository.setUser(user); 219 | } 220 | } 221 | 222 | protected void checkResult(ScmResult result) throws ScmException { 223 | if (!result.isSuccess()) { 224 | // TODO: improve error handling 225 | getLog().error("Provider message:"); 226 | 227 | getLog().error(result.getProviderMessage()); 228 | 229 | getLog().error("Command output:"); 230 | 231 | getLog().error(result.getCommandOutput()); 232 | 233 | throw new ScmException("Error!"); 234 | } 235 | } 236 | 237 | // TODO this should be rolled into org.apache.maven.scm.provider.ScmProvider and 238 | // org.apache.maven.scm.provider.svn.SvnScmProvider 239 | 240 | /** 241 | * Get info from scm. 242 | * 243 | * @param repository 244 | * @param fileSet 245 | * @return 246 | * @throws ScmException 247 | */ 248 | protected InfoScmResult info(ScmRepository repository, ScmFileSet fileSet) throws ScmException { 249 | CommandParameters commandParameters = new CommandParameters(); 250 | 251 | // only for Git, we will make a test for shortRevisionLength parameter 252 | if (GitScmProviderRepository.PROTOCOL_GIT.equals( 253 | scmManager.getProviderByRepository(repository).getScmType()) 254 | && this.shortRevisionLength > 0) { 255 | getLog().info("ShortRevision tag detected. The value is '" + this.shortRevisionLength + "'."); 256 | if (shortRevisionLength >= 0 && shortRevisionLength < 4) { 257 | getLog().warn( 258 | "shortRevision parameter less then 4. ShortRevisionLength is relaying on 'git rev-parese --short=LENGTH' command, accordingly to Git rev-parse specification the LENGTH value is miminum 4. "); 259 | } 260 | commandParameters.setInt(CommandParameter.SCM_SHORT_REVISION_LENGTH, this.shortRevisionLength); 261 | } 262 | 263 | if (!StringUtils.isBlank(scmTag) && !"HEAD".equals(scmTag)) { 264 | commandParameters.setScmVersion(CommandParameter.SCM_VERSION, new ScmTag(scmTag)); 265 | } 266 | 267 | return scmManager 268 | .getProviderByRepository(repository) 269 | .info(repository.getProviderRepository(), fileSet, commandParameters); 270 | } 271 | 272 | protected String getScmRevision() throws ScmException { 273 | ScmRepository repository = getScmRepository(); 274 | 275 | InfoScmResult scmResult = info(repository, new ScmFileSet(scmDirectory)); 276 | 277 | if (scmResult == null || scmResult.getInfoItems().isEmpty()) { 278 | return (!StringUtils.isEmpty(revisionOnScmFailure)) ? revisionOnScmFailure : null; 279 | } 280 | 281 | checkResult(scmResult); 282 | 283 | InfoItem info = scmResult.getInfoItems().get(0); 284 | 285 | if (useLastCommittedRevision) { 286 | // It seemed the case that for git getLastChangedRevision() 287 | // returns null instead of the last revision in contradiction 288 | // to the above code: scmResult.getInfoItems().get(0); 289 | return info.getLastChangedRevision(); 290 | } 291 | 292 | return info.getRevision(); 293 | } 294 | } 295 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/build/CreateMetadataMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.build; 2 | 3 | /** 4 | * The MIT License 5 | * 6 | * Copyright (c) 2015 Codehaus 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 9 | * associated documentation files (the "Software"), to deal in the Software without restriction, 10 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 11 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all copies or 15 | * substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 18 | * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | */ 23 | import java.io.File; 24 | import java.io.FileOutputStream; 25 | import java.io.IOException; 26 | import java.io.OutputStream; 27 | import java.util.ArrayList; 28 | import java.util.HashMap; 29 | import java.util.List; 30 | import java.util.Map; 31 | import java.util.Properties; 32 | import java.util.TimeZone; 33 | 34 | import org.apache.maven.model.Resource; 35 | import org.apache.maven.plugin.MojoExecutionException; 36 | import org.apache.maven.plugin.MojoFailureException; 37 | import org.apache.maven.plugins.annotations.Component; 38 | import org.apache.maven.plugins.annotations.LifecyclePhase; 39 | import org.apache.maven.plugins.annotations.Mojo; 40 | import org.apache.maven.plugins.annotations.Parameter; 41 | import org.apache.maven.project.MavenProjectHelper; 42 | import org.apache.maven.scm.ScmException; 43 | import org.codehaus.plexus.util.StringUtils; 44 | 45 | /** 46 | * This mojo discovers latest SCM revision, current timestamp, project version, and project name then write them to one 47 | * or more java property files together with a set of user provided properties. It also has option to add the output 48 | * file to resource classpath for jar packaging. 49 | */ 50 | @Mojo( 51 | name = "create-metadata", 52 | defaultPhase = LifecyclePhase.GENERATE_RESOURCES, 53 | requiresProject = true, 54 | threadSafe = true) 55 | public class CreateMetadataMojo extends AbstractScmMojo { 56 | 57 | /** 58 | * Application name 59 | * 60 | * @since 1.4 61 | */ 62 | @Parameter(defaultValue = "${project.name}") 63 | private String applicationName; 64 | 65 | /** 66 | * Java property name to store the project name 67 | * 68 | * @since 1.4 69 | */ 70 | @Parameter(defaultValue = "name") 71 | private String applicationPropertyName; 72 | 73 | /** 74 | * Java property name to store the project version 75 | * 76 | * @since 1.4 77 | */ 78 | @Parameter(defaultValue = "version") 79 | private String versionPropertyName; 80 | 81 | /** 82 | * Version 83 | * 84 | * @since 1.4 85 | */ 86 | @Parameter(defaultValue = "${project.version}") 87 | private String version; 88 | 89 | /** 90 | * Java property name to store the discovered SCM revision value 91 | * 92 | * @since 1.4 93 | */ 94 | @Parameter(defaultValue = "revision") 95 | private String revisionPropertyName; 96 | 97 | /** 98 | * Java property name to store the discovered timestamp value 99 | * 100 | * @since 1.4 101 | */ 102 | @Parameter(defaultValue = "timestamp") 103 | private String timestampPropertyName; 104 | 105 | /** 106 | * java.text.SimpleDateFormat for the discover timestamp, if not given use long integer format 107 | * 108 | * @since 1.4 109 | */ 110 | @Parameter(property = "maven.build.timestamp.format") 111 | private String timestampFormat; 112 | 113 | /** 114 | * The timezone of the generated timestamp. If blank will default to {@link TimeZone#getDefault()} 115 | */ 116 | @Parameter(property = "maven.buildNumber.timestampTimeZone", defaultValue = "") 117 | private String timezone; 118 | 119 | /** 120 | * Output directory 121 | * 122 | * @since 1.4 123 | */ 124 | @Parameter(defaultValue = "${project.build.directory}/generated/build-metadata", required = true) 125 | private File outputDirectory; 126 | 127 | /** 128 | * Output file name 129 | * 130 | * @since 1.4 131 | */ 132 | @Parameter(defaultValue = "build.properties", required = true) 133 | private String outputName; 134 | 135 | /** 136 | * Add outputDirectory to java resource so that outputName will be under runtime classpath. outputName 137 | * can contain '/' 138 | * 139 | * @since 1.4 140 | */ 141 | @Parameter(defaultValue = "false") 142 | private boolean addOutputDirectoryToResources; 143 | 144 | /** 145 | * Install/Deploy to Maven repository 146 | * 147 | * @since 1.4 148 | */ 149 | @Parameter(defaultValue = "false") 150 | private boolean attach; 151 | 152 | /** 153 | * Artifact classifier name when deploying to Maven repository 154 | * 155 | * @since 3.0 156 | */ 157 | @Parameter(defaultValue = "build") 158 | private String classifier; 159 | 160 | /** 161 | * Additional output files 162 | * 163 | * @since 1.4 164 | */ 165 | @Parameter 166 | private List outputFiles = new ArrayList<>(); 167 | 168 | /** 169 | * Additional properties to write out 170 | * 171 | * @since 1.4 172 | */ 173 | @Parameter 174 | private Map properties = new HashMap<>(); 175 | 176 | /** 177 | * Enable output format detection. (Disabled per default for compatibility.) 178 | * 179 | * @since 3.0 180 | */ 181 | @Parameter(defaultValue = "false") 182 | private boolean autoDetectOutputFormat; 183 | 184 | /** 185 | * Maven ProjectHelper. 186 | */ 187 | @Component 188 | private MavenProjectHelper projectHelper; 189 | 190 | public void execute() throws MojoExecutionException, MojoFailureException { 191 | 192 | if (skip) { 193 | getLog().info("Skipping execution."); 194 | return; 195 | } 196 | 197 | Properties props = new Properties(); 198 | props.put(this.applicationPropertyName, applicationName); 199 | props.put(this.versionPropertyName, version); 200 | props.put(this.timestampPropertyName, Utils.createTimestamp(this.timestampFormat, timezone)); 201 | props.put(this.revisionPropertyName, this.getRevision()); 202 | properties.entrySet().forEach(entry -> props.put(entry.getKey(), entry.getValue())); 203 | 204 | File outputFile = new File(outputDirectory, outputName); 205 | outputFiles.add(outputFile); 206 | 207 | for (File file : outputFiles) { 208 | file.getParentFile().mkdirs(); 209 | writeToFile(props, file); 210 | } 211 | 212 | if (attach) { 213 | projectHelper.attachArtifact(this.project, "properties", this.classifier, outputFile); 214 | } 215 | 216 | if (this.addOutputDirectoryToResources) { 217 | Resource resource = new Resource(); 218 | resource.setDirectory(outputDirectory.getAbsolutePath()); 219 | 220 | project.addResource(resource); 221 | } 222 | } 223 | 224 | private void writeToFile(Properties props, File file) throws MojoFailureException { 225 | try { 226 | if (this.autoDetectOutputFormat) { 227 | OutputFormat outputFormat = OutputFormat.getOutputFormatFor(file.getName()); 228 | writeToFile(props, file, outputFormat); 229 | } else { 230 | writeToFile(props, file, OutputFormat.DEFAULT_FORMAT); 231 | } 232 | } catch (IOException e) { 233 | throw new MojoFailureException("Unable to store output to " + file, e); 234 | } 235 | } 236 | 237 | private void writeToFile(Properties props, File file, OutputFormat outputFormat) throws IOException { 238 | try (OutputStream out = new FileOutputStream(file)) { 239 | outputFormat.write(props, out); 240 | } 241 | } 242 | 243 | public String getRevision() throws MojoExecutionException { 244 | try { 245 | return this.getScmRevision(); 246 | } catch (ScmException e) { 247 | if (!StringUtils.isEmpty(revisionOnScmFailure)) { 248 | getLog().warn("Cannot get the revision information from the scm repository, proceeding with " 249 | + "revision of " + revisionOnScmFailure + " : \n" + e.getLocalizedMessage()); 250 | 251 | return revisionOnScmFailure; 252 | } 253 | 254 | throw new MojoExecutionException( 255 | "Cannot get the revision information from the scm repository : \n" + e.getLocalizedMessage(), e); 256 | } 257 | } 258 | } 259 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/build/CreateTimestampMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.build; 2 | 3 | /** 4 | * The MIT License 5 | * 6 | * Copyright (c) 2015 Codehaus 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 9 | * associated documentation files (the "Software"), to deal in the Software without restriction, 10 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 11 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all copies or 15 | * substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 18 | * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | */ 23 | import java.util.TimeZone; 24 | 25 | import org.apache.maven.execution.MavenSession; 26 | import org.apache.maven.plugin.AbstractMojo; 27 | import org.apache.maven.plugins.annotations.LifecyclePhase; 28 | import org.apache.maven.plugins.annotations.Mojo; 29 | import org.apache.maven.plugins.annotations.Parameter; 30 | import org.apache.maven.project.MavenProject; 31 | 32 | /** 33 | * This mojo is designed to give you a timestamp available through one or more properties. Only a single timestamp is 34 | * created for each execution of the mojo. This timestamp can be format into one or more strings which are then saved to 35 | * properties. 36 | * create a timestamp property 37 | * 38 | * @author pgier 39 | * @since 1.0-beta-5 40 | */ 41 | @Mojo(name = "create-timestamp", defaultPhase = LifecyclePhase.INITIALIZE, requiresProject = true, threadSafe = true) 42 | public class CreateTimestampMojo extends AbstractMojo { 43 | /** 44 | * Whether to skip this execution. 45 | * 46 | * @since 1.3 47 | */ 48 | @Parameter(property = "maven.buildNumber.skip", defaultValue = "false") 49 | private boolean skip; 50 | 51 | /** 52 | * The maven session. 53 | */ 54 | @Parameter(defaultValue = "${session}", required = true, readonly = true) 55 | private MavenSession session; 56 | 57 | /** 58 | * You can rename the timestamp property name to another property name if desired. 59 | */ 60 | @Parameter(property = "maven.buildNumber.timestampPropertyName", defaultValue = "timestamp") 61 | private String timestampPropertyName; 62 | 63 | /** 64 | * Apply this java.text.SimpleDateFormat to the timestamp. By default, no formatting is done but the raw number 65 | * value (milliseconds since January 1, 1970, 00:00:00 GMT) is used. 66 | */ 67 | @Parameter(property = "maven.buildNumber.timestampFormat", defaultValue = "") 68 | private String timestampFormat; 69 | 70 | /** 71 | * The timezone of the generated timestamp. If blank will default to {@link TimeZone#getDefault()} 72 | */ 73 | @Parameter(property = "maven.buildNumber.timestampTimeZone", defaultValue = "") 74 | private String timezone; 75 | 76 | /** 77 | * Execute this only once in root project of a multi module build. 78 | */ 79 | @Parameter(defaultValue = "false") 80 | private boolean executeRootOnly; 81 | 82 | public void execute() { 83 | if (skip) { 84 | getLog().info("Skipping execution."); 85 | return; 86 | } 87 | 88 | if (session.getCurrentProject().isExecutionRoot() && !executeRootOnly) { 89 | getLog().info("Skipping because we are not in root module."); 90 | } 91 | 92 | String timestampString = session.getTopLevelProject().getProperties().getProperty(timestampPropertyName); 93 | 94 | // Check if the plugin has already run in the current build. 95 | if (timestampString != null) { 96 | getLog().debug("Using previously created timestamp."); 97 | return; 98 | } 99 | 100 | timestampString = Utils.createTimestamp(timestampFormat, timezone); 101 | 102 | getLog().debug("Storing timestamp property: " + timestampPropertyName + " " + timestampString); 103 | 104 | for (MavenProject project : session.getProjectDependencyGraph().getSortedProjects()) { 105 | getLog().debug("Storing timestamp property in project " + project.getId()); 106 | project.getProperties().setProperty(timestampPropertyName, timestampString); 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/build/HgChangeSetMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.build; 2 | 3 | /** 4 | * The MIT License 5 | * 6 | * Copyright (c) 2015 Codehaus 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 9 | * associated documentation files (the "Software"), to deal in the Software without restriction, 10 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 11 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all copies or 15 | * substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 18 | * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | */ 23 | import java.io.File; 24 | 25 | import org.apache.maven.plugin.AbstractMojo; 26 | import org.apache.maven.plugin.MojoExecutionException; 27 | import org.apache.maven.plugins.annotations.LifecyclePhase; 28 | import org.apache.maven.plugins.annotations.Mojo; 29 | import org.apache.maven.plugins.annotations.Parameter; 30 | import org.apache.maven.project.MavenProject; 31 | import org.apache.maven.scm.ScmException; 32 | import org.apache.maven.scm.ScmResult; 33 | import org.apache.maven.scm.provider.hg.HgUtils; 34 | import org.codehaus.plexus.util.StringUtils; 35 | 36 | /** 37 | * Goal which sets project properties for changeSet and changeSetDate from the current Mercurial repository. 38 | * 39 | * @author Tomas Pollak 40 | * @since 1.0-beta-4 41 | */ 42 | @Mojo(name = "hgchangeset", defaultPhase = LifecyclePhase.INITIALIZE, requiresProject = true, threadSafe = true) 43 | public class HgChangeSetMojo extends AbstractMojo { 44 | /** 45 | * Whether to skip this execution. 46 | * 47 | * @since 1.3 48 | */ 49 | @Parameter(property = "maven.buildNumber.skip", defaultValue = "false") 50 | private boolean skip; 51 | 52 | /** 53 | * The maven project. 54 | */ 55 | @Parameter(defaultValue = "${project}", required = true, readonly = true) 56 | private MavenProject project; 57 | 58 | /** 59 | * Local directory to be used to issue SCM actions 60 | * 61 | * @since 1.0 62 | */ 63 | @Parameter(property = "maven.changeSet.scmDirectory", defaultValue = "${basedir}") 64 | private File scmDirectory; 65 | 66 | /** 67 | * Forces to use last logged changeset/changesetDate from scmDirectory and not current repository 68 | * changeset/changesetDate. 69 | * 70 | * @since 1.5 71 | */ 72 | @Parameter(property = "maven.buildNumber.useLastChangeSetInDirectory", defaultValue = "false") 73 | private Boolean useLastChangeSetInDirectory; 74 | 75 | private void checkResult(ScmResult result) throws MojoExecutionException { 76 | if (!result.isSuccess()) { 77 | getLog().debug("Provider message:"); 78 | getLog().debug(result.getProviderMessage() == null ? "" : result.getProviderMessage()); 79 | getLog().debug("Command output:"); 80 | getLog().debug(result.getCommandOutput() == null ? "" : result.getCommandOutput()); 81 | throw new MojoExecutionException( 82 | "Command failed." + StringUtils.defaultString(result.getProviderMessage())); 83 | } 84 | } 85 | 86 | public void execute() throws MojoExecutionException { 87 | if (skip) { 88 | getLog().info("Skipping execution."); 89 | return; 90 | } 91 | 92 | try { 93 | String previousChangeSet = getChangeSetProperty(); 94 | String previousChangeSetDate = getChangeSetDateProperty(); 95 | if (previousChangeSet == null || previousChangeSetDate == null) { 96 | String changeSet = getChangeSet(); 97 | String changeSetDate = getChangeSetDate(); 98 | getLog().info("Setting Mercurial Changeset: " + changeSet); 99 | getLog().info("Setting Mercurial Changeset Date: " + changeSetDate); 100 | setChangeSetProperty(changeSet); 101 | setChangeSetDateProperty(changeSetDate); 102 | } 103 | } catch (ScmException e) { 104 | throw new MojoExecutionException("SCM Exception", e); 105 | } 106 | } 107 | 108 | protected String getHgCommandOutput(String[] command) throws ScmException, MojoExecutionException { 109 | HgOutputConsumer consumer = new HgOutputConsumer(); 110 | ScmResult result = HgUtils.execute(consumer, scmDirectory, command); 111 | checkResult(result); 112 | return consumer.getOutput(); 113 | } 114 | 115 | protected String getChangeSet() throws ScmException, MojoExecutionException { 116 | return getHgCommandOutput( 117 | useLastChangeSetInDirectory 118 | ? new String[] {"log", "-l1", "--template", "\"{node|short}\"", "."} 119 | : new String[] {"id", "-i"}); 120 | } 121 | 122 | protected String getChangeSetDate() throws ScmException, MojoExecutionException { 123 | return getHgCommandOutput( 124 | useLastChangeSetInDirectory 125 | ? new String[] {"log", "-l1", "--template", "\"{date|isodate}\"", "."} 126 | : new String[] {"log", "-r", ".", "--template", "\"{date|isodate}\""}); 127 | } 128 | 129 | protected String getChangeSetDateProperty() { 130 | return getProperty("changeSetDate"); 131 | } 132 | 133 | protected String getChangeSetProperty() { 134 | return getProperty("changeSet"); 135 | } 136 | 137 | protected String getProperty(String property) { 138 | return project.getProperties().getProperty(property); 139 | } 140 | 141 | private void setChangeSetDateProperty(String changeSetDate) { 142 | setProperty("changeSetDate", changeSetDate); 143 | } 144 | 145 | private void setChangeSetProperty(String changeSet) { 146 | setProperty("changeSet", changeSet); 147 | } 148 | 149 | private void setProperty(String property, String value) { 150 | if (value != null) { 151 | project.getProperties().put(property, value); 152 | } 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/build/HgOutputConsumer.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.build; 2 | 3 | import org.apache.maven.scm.ScmFileStatus; 4 | import org.apache.maven.scm.provider.hg.command.HgConsumer; 5 | 6 | class HgOutputConsumer extends HgConsumer { 7 | 8 | private String output; 9 | 10 | HgOutputConsumer() { 11 | super(); 12 | } 13 | 14 | @Override 15 | public void doConsume(ScmFileStatus status, String line) { 16 | output = line; 17 | } 18 | 19 | String getOutput() { 20 | return output; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/build/JsonOutputFormat.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.build; 2 | 3 | import java.io.*; 4 | import java.nio.charset.StandardCharsets; 5 | import java.util.Properties; 6 | 7 | import com.google.gson.Gson; 8 | import com.google.gson.stream.JsonWriter; 9 | 10 | public class JsonOutputFormat extends OutputFormat { 11 | @Override 12 | public boolean handles(String fileName) { 13 | return fileName.endsWith(".json"); 14 | } 15 | 16 | @Override 17 | public void write(Properties props, OutputStream out) throws IOException { 18 | Gson gson = new Gson(); 19 | try (JsonWriter jsonWriter = gson.newJsonWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8))) { 20 | jsonWriter.beginObject(); 21 | for (Object key : props.keySet()) { 22 | jsonWriter.name((String) key); 23 | jsonWriter.value(props.getProperty((String) key)); 24 | } 25 | jsonWriter.endObject(); 26 | jsonWriter.flush(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/build/OutputFormat.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.build; 2 | 3 | /** 4 | * The MIT License 5 | * 6 | * Copyright (c) 2015 Learning Commons, University of Calgary 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 9 | * associated documentation files (the "Software"), to deal in the Software without restriction, 10 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 11 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all copies or 15 | * substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 18 | * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | */ 23 | import java.io.IOException; 24 | import java.io.OutputStream; 25 | import java.util.Properties; 26 | 27 | public abstract class OutputFormat { 28 | static final OutputFormat DEFAULT_FORMAT = new PropertiesOutputFormat(); 29 | 30 | private static final OutputFormat[] FORMATS = 31 | new OutputFormat[] {new JsonOutputFormat(), OutputFormat.DEFAULT_FORMAT}; 32 | 33 | public static OutputFormat getOutputFormatFor(String fileName) { 34 | for (OutputFormat outputFormat : OutputFormat.FORMATS) { 35 | if (outputFormat.handles(fileName)) { 36 | return outputFormat; 37 | } 38 | } 39 | 40 | return OutputFormat.DEFAULT_FORMAT; 41 | } 42 | 43 | public abstract boolean handles(String fileName); 44 | 45 | public abstract void write(Properties props, OutputStream out) throws IOException; 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/build/PropertiesOutputFormat.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.build; 2 | 3 | /** 4 | * The MIT License 5 | * 6 | * Copyright (c) 2015 Learning Commons, University of Calgary 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 9 | * associated documentation files (the "Software"), to deal in the Software without restriction, 10 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 11 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all copies or 15 | * substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 18 | * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | */ 23 | import java.io.IOException; 24 | import java.io.OutputStream; 25 | import java.util.Properties; 26 | 27 | public class PropertiesOutputFormat extends OutputFormat { 28 | @Override 29 | public boolean handles(String fileName) { 30 | return fileName.endsWith(".properties"); 31 | } 32 | 33 | @Override 34 | public void write(Properties props, OutputStream out) throws IOException { 35 | props.store(out, "Created by build system. Do not modify"); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/build/Utils.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.build; 2 | 3 | /** 4 | * The MIT License 5 | * 6 | * Copyright (c) 2015 Learning Commons, University of Calgary 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 9 | * associated documentation files (the "Software"), to deal in the Software without restriction, 10 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 11 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all copies or 15 | * substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 18 | * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | */ 23 | import java.text.SimpleDateFormat; 24 | import java.util.Calendar; 25 | import java.util.Date; 26 | import java.util.TimeZone; 27 | 28 | import org.apache.commons.lang.StringUtils; 29 | 30 | public class Utils { 31 | private Utils() {} 32 | 33 | public static String createTimestamp(String timestampFormat, String timeZoneId) { 34 | return createTimestamp(timestampFormat, timeZoneId, null); 35 | } 36 | 37 | public static String createTimestamp(String timestampFormat, String timeZoneId, Date now) { 38 | if (null == now) now = Calendar.getInstance().getTime(); 39 | 40 | if (StringUtils.isBlank(timestampFormat)) { 41 | return String.valueOf(now.getTime()); 42 | } else { 43 | SimpleDateFormat dateFormat = new SimpleDateFormat(timestampFormat); 44 | dateFormat.setTimeZone(getTimeZone(timeZoneId)); 45 | return dateFormat.format(now); 46 | } 47 | } 48 | 49 | private static TimeZone getTimeZone(String timeZoneId) { 50 | TimeZone timeZone = TimeZone.getDefault(); 51 | if (StringUtils.isNotBlank(timeZoneId)) { 52 | timeZone = TimeZone.getTimeZone(timeZoneId); 53 | } 54 | return timeZone; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/plexus/components.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | org.sonatype.plexus.components.sec.dispatcher.SecDispatcher 21 | mng-4384 22 | org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher 23 | 24 | 25 | org.sonatype.plexus.components.cipher.PlexusCipher 26 | mng-4384 27 | _cipher 28 | 29 | 30 | 31 | <_configuration-file>~/.m2/settings-security.xml 32 | 33 | 34 | 35 | org.sonatype.plexus.components.cipher.PlexusCipher 36 | mng-4384 37 | org.sonatype.plexus.components.cipher.DefaultPlexusCipher 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/site/apt/index.apt: -------------------------------------------------------------------------------- 1 | ------ 2 | Introduction 3 | ------ 4 | Olivier Lamy 5 | ------ 6 | 7 | Introduction 8 | 9 | This mojo is designed to get a unique build number for each time you build your project. So while your 10 | version may remain constant at 1.0-SNAPSHOT for many iterations until release, you will have a build 11 | number that can uniquely identify each build during that time. The build number is obtained from 12 | scm. You can then place that build number in metadata, which 13 | can be accessed from your app, if desired. 14 | 15 | The mojo also has a couple of extra functions to ensure you get the proper build number. First, your 16 | local repository is checked to make sure it is up to date. Second, your local repository is 17 | automatically updated, so that you get the latest build number. Both these functions can be suppressed, 18 | if desired. 19 | 20 | Optionally, you can configure this mojo to produce a revision based on a timestamp, or on a sequence, 21 | without requiring any interaction with an SCM system. 22 | <> 23 | 24 | 25 | * Goals Overview 26 | 27 | * {{{./create-mojo.html}buildnumber:create}}: Create a build number. 28 | 29 | * {{{./create-timestamp-mojo.html}buildnumber:create-timestamp}}: Create a timestamp. 30 | 31 | * {{{./create-metadata-mojo.html}buildnumber:create-metadata}}: Write build properties into file 32 | 33 | * {{{./hgchangeset-mojo.html}buildnumber:hgchangeset}}: Create properties for changeSet and changeSetDate from a Mercurial repository. 34 | 35 | [] 36 | 37 | 38 | * Usage 39 | 40 | Instructions on how to use the Build Number Maven Plugin can be found on the {{{./usage.html}usage page}}. 41 | 42 | 43 | * Hint 44 | 45 | Starting with version 3.0.0 of the plugin the default behaviour has been changed. 46 | If you define <> with <> the plugin will really only check for modifications 47 | and will set the property <> with the value <>. If there 48 | are no modification this property will be set to <>. 49 | 50 | If you like to fail the build as in previous versions you have to set the supplemental 51 | configuration <> to <> and set <> to to <>. 52 | 53 | ~~ * Examples 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/site/apt/usage.apt.vm: -------------------------------------------------------------------------------- 1 | ------ 2 | Usage 3 | ------ 4 | 5 | Usage 6 | 7 | This plugin works in one of 3 ways: with an SCM, with a sequential build number, or with a timestamp. 8 | 9 | No matter which method you choose, you must include it in your pom: 10 | 11 | +------------------------------------------+ 12 | 13 | 14 | 15 | org.codehaus.mojo 16 | buildnumber-maven-plugin 17 | ${project.version} 18 | 19 | 20 | validate 21 | 22 | create 23 | 24 | 25 | 26 | 27 | true 28 | true 29 | 30 | 31 | 32 | 33 | +------------------------------------------+ 34 | 35 | This will cause the create goal of the buildNumber plugin to be executed during the validate phase. It will first 36 | check to see if you have locally modified files, and will fail if there are any. You can suppress this 37 | behaviour with <<<-Dmaven.buildNumber.doCheck=false>>> (or remove/change the configuration info). 38 | 39 | The buildNumber plugin will then update your local repository. This is done because local revision might not be the same 40 | locally as the last one on some remote server (example for svn: 'svn info' grabs the revision out of your 41 | local repository, and is not necessarily the same as the revision in the remote repository). You should 42 | probably deal with these changes before creating a build in any case. Again, this behaviour can be suppressed 43 | with <<<-Dmaven.buildNumber.doUpdate=false>>>. 44 | 45 | You then need to do something with the revision provided by the plugin. The revision number is available using 46 | <<<$\{buildNumber\}>>> in your pom. For example: 47 | 48 | +------------------------------------------+ 49 | 50 | $\{project.artifactId}-$\{project.version}-r$\{buildNumber} 51 | 52 | +------------------------------------------+ 53 | 54 | or to place in the manifest (META-INF/MANIFEST.mf) of your jar: 55 | 56 | +------------------------------------------+ 57 | 58 | ... 59 | 60 | 61 | org.apache.maven.plugins 62 | maven-jar-plugin 63 | 3.0.2 64 | 65 | 66 | 67 | true 68 | 69 | 70 | ${buildNumber} 71 | 72 | 73 | 74 | 75 | 76 | 77 | +------------------------------------------+ 78 | 79 | or war: 80 | 81 | +------------------------------------------+ 82 | 83 | ... 84 | 85 | 86 | org.apache.maven.plugins 87 | maven-war-plugin 88 | 3.0.0 89 | 90 | 91 | 92 | true 93 | 94 | 95 | ${buildNumber} 96 | 97 | 98 | 99 | 100 | 101 | 102 | +------------------------------------------+ 103 | 104 | The <<<$\{scmBranch\}>>> property is also populated to provide 105 | the SCM branch. 106 | 107 | <> Older version of the jar and war plugin don't require the 108 | manifest/addDefaultImplementationEntries element, and in fact will fail 109 | if present. The new versions require this element. 110 | 111 | You can also configure the plugin to be more flexible. 112 | 113 | +------------------------------------------+ 114 | 115 | 116 | 117 | org.codehaus.mojo 118 | buildnumber-maven-plugin 119 | ${project.version} 120 | 121 | At {1,time} on {1,date}, there was {2} on planet {0,number,integer}. 122 | 123 | 7 124 | timestamp 125 | a disturbance in the Force 126 | 127 | 128 | 129 | 130 | validate 131 | 132 | create 133 | 134 | 135 | 136 | 137 | 138 | 139 | +------------------------------------------+ 140 | 141 | Other more useful configurations might be: 142 | 143 | +------------------------------------------+ 144 | 145 | {0,number}.{1,number}.{2,number} 146 | 147 | buildNumber0 148 | buildNumber1 149 | buildNumber2 150 | 151 | 152 | +------------------------------------------+ 153 | 154 | or: 155 | 156 | +------------------------------------------+ 157 | 158 | yyyy-MM-dd HH:mm:ss 159 | 160 | timestamp 161 | 162 | 163 | +------------------------------------------+ 164 | 165 | The plugin simply uses the 166 | {{{http://java.sun.com/j2se/1.4.2/docs/api/java/text/MessageFormat.html} MessageFormat class}} 167 | to produce <<<$\{buildNumber\}>>>, and thus the above configurations would produce: 168 | 169 | +------------------------------------------+ 170 | At 12:30 PM on Jul 3, 2053, there was a disturbance in the Force on planet 7. 171 | +------------------------------------------+ 172 | 173 | and 174 | 175 | +------------------------------------------+ 176 | 2.0.3 177 | +------------------------------------------+ 178 | 179 | and 180 | 181 | +------------------------------------------+ 182 | 2005-10-06 2:22:55 183 | +------------------------------------------+ 184 | 185 | respectively. 186 | 187 | When you specify the special items of "buildNumber\\d*" or "timestamp", then some magic is performed. For each unique 188 | buildNumber, a properties file ( see {{{./create-mojo.html#buildNumberPropertiesFileLocation}buildNumberPropertiesFileLocation}} ) will be created (or read if it exists) which holds an integer, starting 189 | at 1. That number will be incremented on each access. Of course, the given example is somewhat non-sensical, since it 190 | will increment all 3 numbers on each build, but it shows the type of flexibility available. For each timestamp, you 191 | simply get the current date and time. 192 | 193 | Here is some additional writeup on {{{http://apollo.ucalgary.ca/tlcprojectswiki/index.php/Public/Project_Versioning_-_Best_Practices#Build_Versioning} 194 | how to version your projects with this plugin}}. It even details how to access the version number in your code. 195 | 196 | 197 | * Git short revision ID 198 | 199 | 200 | From the version 1.1 you can specify the length for the Git revision. 201 | To enable this feature you have to specify the new tag << >> in the << >> section. 202 | For exemple: 203 | 204 | +------------------------------------------+ 205 | 206 | 5 207 | 208 | +------------------------------------------+ 209 | 210 | the output of the found git revision will have only 5 characters: 211 | 212 | +------------------------------------------+ 213 | instead of b0c1c69be579175e63eeb1c056d607f01ab61e96 you will have only b0c1c 214 | +------------------------------------------+ 215 | 216 | <> this feature uses internally the <> command and the revision length is set to minimum 4 characters. 217 | So you can't have the revision id shorter then 4 characters. Even if you specify the length between 0 and 4, the plugin will inform you about this situation and the minimum value (4) will be used. 218 | 219 | 220 | * Using svnjava provider 221 | 222 | If you need to execute the plugin on machine without any svn in the path you can configure 223 | the mojo to use the svnjava provider. 224 | 225 | NOTE the svnjava provider use the svnjava scm provider implementation {{{https://github.com/olamy/maven-scm-provider-svnjava}maven-scm-provider-svnjava}} which rely on svnkit version. 226 | 227 | 228 | +-- 229 | 230 | 231 | 232 | org.codehaus.mojo 233 | buildnumber-maven-plugin 234 | ${project.version} 235 | 236 | 237 | validate 238 | 239 | create 240 | 241 | 242 | 243 | 244 | true 245 | true 246 | 247 | javasvn 248 | 249 | 250 | 251 | 252 | 253 | +-- 254 | 255 | 256 | * Using Perforce P4Maven provider 257 | 258 | To use this plugin with {{{https://swarm.workshop.perforce.com/files/guest/dantran/p4maven}Perforce P4Maven Provider}}, 259 | add p4maven-provider to dependencies list. 260 | 261 | +-- 262 | 263 | 264 | 265 | org.codehaus.mojo 266 | buildnumber-maven-plugin 267 | ${project.version} 268 | 269 | 270 | com.perforce.p4maven 271 | p4maven-provider 272 | ${p4maven.version} 273 | 274 | 275 | [...] 276 | 277 | 278 | 279 | +-- 280 | 281 | * Create Build Metadata 282 | 283 | For quick quick discovery of a SCM revision of an snapshot/release artifact available at maven repository, use 284 | buildnumber:create-metadata to deploy a build metadata file associate with a specific artifact of the same project. 285 | 286 | +-- 287 | 288 | 289 | 290 | org.codehaus.mojo 291 | buildnumber-maven-plugin 292 | ${project.version} 293 | 294 | 295 | generate-resources 296 | 297 | create-metadata 298 | 299 | 300 | 301 | 302 | true 303 | 304 | true 305 | 306 | 307 | 308 | 309 | +-- 310 | 311 | -------------------------------------------------------------------------------- /src/site/fml/faq.fml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | General 22 | 23 | 24 | Can the plugin be used on a project without an SCM connection? 25 | 26 | Yes, set the plugin parameter <revisionOnScmFailure> to prevent 27 | the plugin from throwing an exception if SCM information is not found. 28 | The other option is to use -Dmaven.buildNumber.ignoreEmptyScmUrl=true -Dmaven.buildNumber.scmProvider=git/svn/ 29 | Default is git 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/build/JsonOutputFormatTest.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.build; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | import java.util.Map; 6 | import java.util.Properties; 7 | 8 | import com.google.gson.Gson; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | 12 | import static org.hamcrest.CoreMatchers.is; 13 | import static org.junit.Assert.*; 14 | 15 | /** 16 | * Created by conni on 11/10/16. 17 | */ 18 | public class JsonOutputFormatTest { 19 | 20 | private OutputFormat outputFormat = new JsonOutputFormat(); 21 | 22 | private Properties properties = new Properties(); 23 | 24 | private Gson gson = new Gson(); 25 | 26 | @Before 27 | public void before() { 28 | properties.put("key0", "value0"); 29 | properties.put("key1", "value1"); 30 | } 31 | 32 | @Test 33 | public void handlesDotJson() { 34 | assertTrue(outputFormat.handles("file.json")); 35 | } 36 | 37 | @Test 38 | public void doesNotHandleNonJson() { 39 | assertFalse(outputFormat.handles("file.other")); 40 | } 41 | 42 | @Test 43 | public void writesJson() throws IOException { 44 | String s = writePropertiesToString(); 45 | 46 | Map map = gson.fromJson(s, Map.class); 47 | assertThat(map.size(), is(2)); 48 | assertThat(map.get("key0"), is((Object) "value0")); 49 | assertThat(map.get("key1"), is((Object) "value1")); 50 | } 51 | 52 | private String writePropertiesToString() throws IOException { 53 | ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); 54 | outputFormat.write(properties, bytesOut); 55 | return new String(bytesOut.toByteArray(), "UTF-8"); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/build/OutputFormatTest.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.build; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Created by conni on 11/10/16. 9 | */ 10 | public class OutputFormatTest { 11 | 12 | @Test 13 | public void defaultIsPropertiesFormat() { 14 | OutputFormat outputFormat = OutputFormat.getOutputFormatFor("illegal"); 15 | 16 | assertTrue(outputFormat instanceof PropertiesOutputFormat); 17 | } 18 | 19 | @Test 20 | public void jsonForForDotJson() { 21 | OutputFormat outputFormat = OutputFormat.getOutputFormatFor("file.json"); 22 | 23 | assertTrue(outputFormat instanceof JsonOutputFormat); 24 | } 25 | 26 | @Test 27 | public void propertiesForForDotProperties() { 28 | OutputFormat outputFormat = OutputFormat.getOutputFormatFor("file.properties"); 29 | 30 | assertTrue(outputFormat instanceof PropertiesOutputFormat); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/build/PropertiesOutputFormatTest.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.build; 2 | 3 | import java.io.ByteArrayInputStream; 4 | import java.io.ByteArrayOutputStream; 5 | import java.io.IOException; 6 | import java.util.Properties; 7 | 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | 11 | import static org.hamcrest.CoreMatchers.is; 12 | import static org.junit.Assert.assertFalse; 13 | import static org.junit.Assert.assertThat; 14 | import static org.junit.Assert.assertTrue; 15 | 16 | /** 17 | * Created by conni on 11/10/16. 18 | */ 19 | public class PropertiesOutputFormatTest { 20 | 21 | private OutputFormat outputFormat = new PropertiesOutputFormat(); 22 | 23 | private Properties properties = new Properties(); 24 | 25 | @Before 26 | public void before() { 27 | properties.put("key0", "value0"); 28 | properties.put("key1", "value1"); 29 | } 30 | 31 | @Test 32 | public void handlesDotProperties() { 33 | assertTrue(outputFormat.handles("file.properties")); 34 | } 35 | 36 | @Test 37 | public void doesNotHandleNonProperties() { 38 | assertFalse(outputFormat.handles("file.other")); 39 | } 40 | 41 | @Test 42 | public void writesProperties() throws IOException { 43 | byte[] serialized = writeProperties(); 44 | 45 | Properties deserializedProperties = new Properties(); 46 | deserializedProperties.load(new ByteArrayInputStream(serialized)); 47 | 48 | assertThat(deserializedProperties, is(properties)); 49 | } 50 | 51 | private byte[] writeProperties() throws IOException { 52 | ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); 53 | outputFormat.write(properties, bytesOut); 54 | return bytesOut.toByteArray(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/build/it/CreateMetadataMojoTest.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.build.it; 2 | 3 | import java.io.File; 4 | 5 | import io.takari.maven.testing.TestResources; 6 | import io.takari.maven.testing.executor.MavenExecution; 7 | import io.takari.maven.testing.executor.MavenExecutionResult; 8 | import io.takari.maven.testing.executor.MavenRuntime; 9 | import io.takari.maven.testing.executor.MavenRuntime.MavenRuntimeBuilder; 10 | import io.takari.maven.testing.executor.MavenVersions; 11 | import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner; 12 | import org.junit.Assert; 13 | import org.junit.Rule; 14 | import org.junit.Test; 15 | import org.junit.runner.RunWith; 16 | 17 | @RunWith(MavenJUnitTestRunner.class) 18 | @MavenVersions({"3.6.3"}) 19 | public class CreateMetadataMojoTest { 20 | @Rule 21 | public final TestResources resources = new TestResources(); 22 | 23 | public final MavenRuntime maven; 24 | 25 | public CreateMetadataMojoTest(MavenRuntimeBuilder builder) throws Exception { 26 | this.maven = builder.withCliOptions("-B").build(); 27 | } 28 | 29 | @Test 30 | public void testBasicConfiguration() throws Exception { 31 | File projDir = resources.getBasedir("create-metadata-it"); 32 | 33 | MavenExecution mavenExec = maven.forProject(projDir); 34 | MavenExecutionResult result = mavenExec.execute("clean", "test"); 35 | result.assertErrorFreeLog(); 36 | 37 | File testDir = result.getBasedir(); 38 | Assert.assertTrue(new File(testDir, "target/file1.properties").exists()); 39 | Assert.assertTrue(new File(testDir, "target/xxx/file1.properties").exists()); 40 | Assert.assertTrue(new File(testDir, "target/generated/build-metadata/build.properties").exists()); 41 | Assert.assertTrue(new File(testDir, "target/classes/build.properties").exists()); 42 | } 43 | 44 | @Test 45 | public void testBasicJsonConfiguration() throws Exception { 46 | File projDir = resources.getBasedir("create-metadata-json-it"); 47 | 48 | MavenExecution mavenExec = maven.forProject(projDir); 49 | MavenExecutionResult result = mavenExec.execute("clean", "test"); 50 | result.assertErrorFreeLog(); 51 | 52 | File testDir = result.getBasedir(); 53 | Assert.assertTrue(new File(testDir, "target/file1.json").exists()); 54 | Assert.assertTrue(new File(testDir, "target/xxx/file1.json").exists()); 55 | Assert.assertTrue(new File(testDir, "target/generated/build-metadata/build.properties").exists()); 56 | Assert.assertTrue(new File(testDir, "target/classes/build.properties").exists()); 57 | } 58 | 59 | @Test 60 | public void testBasicConfigurationNoScm() throws Exception { 61 | File projDir = resources.getBasedir("create-metadata-it-no-scm"); 62 | 63 | MavenExecution mavenExec = maven.forProject(projDir); 64 | MavenExecutionResult result = mavenExec.withCliOption("-e").execute("clean", "test"); 65 | result.assertErrorFreeLog(); 66 | 67 | File testDir = result.getBasedir(); 68 | Assert.assertTrue(new File(testDir, "target/file1.properties").exists()); 69 | Assert.assertTrue(new File(testDir, "target/xxx/file1.properties").exists()); 70 | Assert.assertTrue(new File(testDir, "target/generated/build-metadata/build.properties").exists()); 71 | Assert.assertTrue(new File(testDir, "target/classes/build.properties").exists()); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/test/projects/MBUILDNUM-5/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-MBUILDNUM-5 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:svn:http://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/it/MBUILDNUM-5 12 | 13 | 14 | 15 | 16 | package 17 | 18 | 19 | 20 | org.codehaus.mojo 21 | buildnumber-maven-plugin 22 | ${it-plugin.version} 23 | 24 | 25 | useLastCommittedRevision 26 | 27 | create 28 | 29 | 30 | true 31 | true 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/test/projects/MBUILDNUM-5/src/main/java/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/ApacheMavenRocks.java: -------------------------------------------------------------------------------- 1 | package a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z; 2 | 3 | /** 4 | * The MIT License 5 | * 6 | * Copyright (c) 2005 Learning Commons, University of Calgary 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 9 | * associated documentation files (the "Software"), to deal in the Software without restriction, 10 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 11 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all copies or 15 | * substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 18 | * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | */ 23 | 24 | public class ApacheMavenRocks 25 | { 26 | public boolean doesIt() 27 | { 28 | return true; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/projects/MBUILDNUM-5/verify.bsh: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | */ 20 | 21 | import java.io.*; 22 | import java.util.*; 23 | import java.util.jar.*; 24 | import org.codehaus.plexus.util.*; 25 | 26 | boolean result = true; 27 | 28 | try 29 | { 30 | File target = new File( basedir, "target" ); 31 | if ( !target.exists() || !target.isDirectory() ) 32 | { 33 | System.err.println( "target file is missing or not a directory." ); 34 | return false; 35 | } 36 | 37 | File artifact = new File ( target, "buildnumber-maven-plugin-MBUILDNUM-5-1.0-SNAPSHOT.jar" ); 38 | if ( !artifact.exists() || artifact.isDirectory() ) 39 | { 40 | System.err.println( "artifact file is missing or a directory." ); 41 | return false; 42 | } 43 | 44 | } 45 | catch( Throwable e ) 46 | { 47 | e.printStackTrace(); 48 | result = false; 49 | } 50 | 51 | return result; 52 | -------------------------------------------------------------------------------- /src/test/projects/MBUILDNUM-83/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-basic-it-svnjava 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:svn:http://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it-svnjava 12 | 13 | 14 | 15 | 16 | package 17 | 18 | 19 | 20 | org.codehaus.mojo 21 | buildnumber-maven-plugin 22 | ${it-plugin.version} 23 | 24 | 25 | org.tmatesoft.svnkit 26 | svnkit 27 | 1.8.3-1 28 | 29 | 30 | 31 | 32 | useLastCommittedRevision 33 | test 34 | 35 | create 36 | 37 | 38 | biiim 39 | 40 | javasvn 41 | 42 | true 43 | 44 | 45 | 46 | timestampFormat 47 | test 48 | 49 | create 50 | 51 | 52 | booom 53 | 54 | javasvn 55 | 56 | true 57 | yyyy-MM-dd 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | org.codehaus.mojo 67 | buildnumber-maven-plugin 68 | 69 | 70 | 71 | org.apache.maven.plugins 72 | maven-jar-plugin 73 | 2.5 74 | 75 | 76 | 77 | true 78 | true 79 | true 80 | 81 | 82 | ${buildNumber} 83 | ${timestamp} 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /src/test/projects/MBUILDNUM-85/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | org.codehaus.mojo.it 5 | buildnumber-maven-plugin-mbuildnum-85 6 | 1.0-SNAPSHOT 7 | 8 | scm:svn:http://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/it/MBUILDNUM-85 9 | 10 | 11 | package 12 | 13 | 14 | org.apache.maven.plugins 15 | maven-scm-plugin 16 | 1.8 17 | 18 | 19 | get-checkout 20 | 21 | checkout 22 | 23 | generate-resources 24 | 25 | 26 | 27 | ${project.build.directory}/checkout 28 | developerConnection 29 | 30 | 31 | 32 | org.codehaus.mojo 33 | properties-maven-plugin 34 | 1.0-alpha-2 35 | 36 | 37 | generate-resources 38 | 39 | write-project-properties 40 | 41 | 42 | ${project.build.directory}/checkout/some.properties 43 | 44 | 45 | 46 | 47 | 48 | org.codehaus.mojo 49 | buildnumber-maven-plugin 50 | ${it-plugin.version} 51 | 52 | 53 | trip-over-modified 54 | 55 | create 56 | 57 | compile 58 | 59 | ${project.build.directory}/checkout 60 | true 61 | false 62 | true 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /src/test/projects/MBUILDNUM-85/some.properties: -------------------------------------------------------------------------------- 1 | this=that 2 | -------------------------------------------------------------------------------- /src/test/projects/MOJO-1372/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-MOJO-1372 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:svn:http://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/it/MOJO-1372 12 | 13 | 14 | 15 | 16 | 17 | org.codehaus.mojo 18 | buildnumber-maven-plugin 19 | ${it-plugin.version} 20 | 21 | 22 | generate-resources 23 | 24 | create 25 | 26 | 27 | ${project.build.directory}/buildNumber.properties 28 | {0,number} 29 | 30 | buildNumber0 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/test/projects/MOJO-1668/dotSvnDir/entries: -------------------------------------------------------------------------------- 1 | 12 2 | -------------------------------------------------------------------------------- /src/test/projects/MOJO-1668/dotSvnDir/format: -------------------------------------------------------------------------------- 1 | 12 2 | -------------------------------------------------------------------------------- /src/test/projects/MOJO-1668/dotSvnDir/pristine/66/665af71baa943cdae96c0623d3c24e6ec712ec9b.svn-base: -------------------------------------------------------------------------------- 1 | clean verify 2 | -------------------------------------------------------------------------------- /src/test/projects/MOJO-1668/dotSvnDir/pristine/85/85ead35ecb9e8e8eabe052fe4b3156db3e83741e.svn-base: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-MOJO-1668 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:svn:http://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/it/MOJO-1668 12 | 13 | 14 | 15 | 16 | 17 | 18 | org.codehaus.mojo 19 | buildnumber-maven-plugin 20 | @pom.version@ 21 | 22 | 23 | com.google.code.maven-scm-provider-svnjava 24 | maven-scm-provider-svnjava 25 | 1.11 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.codehaus.mojo 34 | buildnumber-maven-plugin 35 | 36 | 37 | validate 38 | 39 | create 40 | 41 | 42 | 43 | 44 | false 45 | false 46 | true 47 | 48 | javasvn 49 | 50 | foo 51 | bar 52 | yyyyMMdd_HHmmss 53 | 54 | 55 | 56 | org.apache.maven.plugins 57 | maven-jar-plugin 58 | 59 | 60 | 61 | true 62 | true 63 | true 64 | 65 | 66 | ${buildNumber} 67 | ${timestamp} 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | svn-1.7 78 | 79 | 80 | .svn 81 | 82 | 83 | 84 | 85 | 86 | 87 | org.codehaus.mojo 88 | buildnumber-maven-plugin 89 | @pom.version@ 90 | 91 | 92 | org.tmatesoft.svnkit 93 | svnkit 94 | 1.8.3-1 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /src/test/projects/MOJO-1668/dotSvnDir/pristine/8c/8c5cf4e025a5aa01f7278074c12ac6723ab14533.svn-base: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | */ 20 | 21 | import java.io.*; 22 | import java.util.*; 23 | import java.util.jar.*; 24 | import org.codehaus.plexus.util.*; 25 | 26 | boolean result = true; 27 | 28 | try 29 | { 30 | File target = new File( basedir, "target" ); 31 | if ( !target.exists() || !target.isDirectory() ) 32 | { 33 | System.err.println( "target file is missing or not a directory." ); 34 | return false; 35 | } 36 | 37 | File artifact = new File ( target, "buildnumber-maven-plugin-MOJO-1668-1.0-SNAPSHOT.jar" ); 38 | if ( !artifact.exists() || artifact.isDirectory() ) 39 | { 40 | System.err.println( "artifact file is missing or a directory." ); 41 | return false; 42 | } 43 | 44 | JarFile jar = new JarFile( artifact ); 45 | 46 | Attributes manifest = jar.getManifest().getMainAttributes(); 47 | 48 | String buildDate = manifest.get( new Attributes.Name( "Build-Date" ) ); 49 | if ( buildDate == null || buildDate.length() < 1 ) 50 | { 51 | System.err.println( "No or empty manifest entry buildDate" ); 52 | return false; 53 | } 54 | } 55 | catch( Throwable e ) 56 | { 57 | e.printStackTrace(); 58 | result = false; 59 | } 60 | 61 | return result; 62 | -------------------------------------------------------------------------------- /src/test/projects/MOJO-1668/dotSvnDir/wc.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/buildnumber-maven-plugin/909857a873fe927f4332d585f9db14265851b99d/src/test/projects/MOJO-1668/dotSvnDir/wc.db -------------------------------------------------------------------------------- /src/test/projects/MOJO-1668/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-MOJO-1668 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:svn:http://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/it/MOJO-1668 12 | 13 | 14 | 15 | 16 | 17 | 18 | org.codehaus.mojo 19 | buildnumber-maven-plugin 20 | ${it-plugin.version} 21 | 22 | 23 | com.google.code.maven-scm-provider-svnjava 24 | maven-scm-provider-svnjava 25 | 1.11 26 | 27 | 28 | org.tmatesoft.svnkit 29 | svnkit 30 | 1.8.3-1 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | org.codehaus.mojo 39 | buildnumber-maven-plugin 40 | 41 | 42 | validate 43 | 44 | create 45 | 46 | 47 | 48 | 49 | false 50 | false 51 | true 52 | 53 | javasvn 54 | 55 | foo 56 | bar 57 | yyyyMMdd_HHmmss 58 | 59 | 60 | 61 | org.apache.maven.plugins 62 | maven-jar-plugin 63 | 2.5 64 | 65 | 66 | 67 | true 68 | true 69 | true 70 | 71 | 72 | ${buildNumber} 73 | ${timestamp} 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-clearcase-scm/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-basic-it-clearcase-scm 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:clearcase:mvn_sm_view:load \some-clearcase-path\LATEST 12 | scm:clearcase:mv_sm_view:load \some-clearcase-path\LATEST 13 | 14 | 15 | 16 | 17 | package 18 | 19 | 20 | 21 | org.codehaus.mojo 22 | buildnumber-maven-plugin 23 | ${it-plugin.version} 24 | 25 | 26 | useLastCommittedRevision 27 | test 28 | 29 | create 30 | 31 | 32 | foo 33 | true 34 | 35 | 36 | 37 | 38 | timestampFormat 39 | test 40 | 41 | create 42 | 43 | 44 | foo 45 | true 46 | yyyy-MM-dd 47 | 48 | 49 | 50 | 51 | 52 | 53 | org.apache.maven.plugins 54 | maven-jar-plugin 55 | 2.5 56 | 57 | 58 | 59 | true 60 | true 61 | true 62 | 63 | 64 | ${buildNumber} 65 | ${timestamp} 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-git/dotGitDir/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-git/dotGitDir/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = false 5 | logallrefupdates = true 6 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-git/dotGitDir/description: -------------------------------------------------------------------------------- 1 | Dummy repository to check buildnumber-maven-plugin for Git SCM. 2 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-git/dotGitDir/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/buildnumber-maven-plugin/909857a873fe927f4332d585f9db14265851b99d/src/test/projects/basic-it-git/dotGitDir/index -------------------------------------------------------------------------------- /src/test/projects/basic-it-git/dotGitDir/info/exclude: -------------------------------------------------------------------------------- 1 | # git ls-files --others --exclude-from=.git/info/exclude 2 | # Lines that start with '#' are comments. 3 | # For a project mostly in C, the following would be a good set of 4 | # exclude patterns (uncomment them if you want to use them): 5 | # *.[oa] 6 | # *~ 7 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-git/dotGitDir/objects/0a/129e164de5b62edb46d1aa0feef56a34941ac2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/buildnumber-maven-plugin/909857a873fe927f4332d585f9db14265851b99d/src/test/projects/basic-it-git/dotGitDir/objects/0a/129e164de5b62edb46d1aa0feef56a34941ac2 -------------------------------------------------------------------------------- /src/test/projects/basic-it-git/dotGitDir/objects/6d/36c746e82f00c5913954f9178f40224497b2f3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/buildnumber-maven-plugin/909857a873fe927f4332d585f9db14265851b99d/src/test/projects/basic-it-git/dotGitDir/objects/6d/36c746e82f00c5913954f9178f40224497b2f3 -------------------------------------------------------------------------------- /src/test/projects/basic-it-git/dotGitDir/objects/d3/a01ee82b5e7da3c2193fe952858d152ceb6505: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/buildnumber-maven-plugin/909857a873fe927f4332d585f9db14265851b99d/src/test/projects/basic-it-git/dotGitDir/objects/d3/a01ee82b5e7da3c2193fe952858d152ceb6505 -------------------------------------------------------------------------------- /src/test/projects/basic-it-git/dotGitDir/refs/heads/master: -------------------------------------------------------------------------------- 1 | 6d36c746e82f00c5913954f9178f40224497b2f3 2 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-git/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-basic-it 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:git:https://github.com/mojohaus/buildnumber-maven-plugin/tree/master/src/it/basic-it-git.git 12 | 13 | 14 | 15 | 16 | package 17 | 18 | 19 | 20 | org.codehaus.mojo 21 | buildnumber-maven-plugin 22 | ${it-plugin.version} 23 | 24 | 25 | useLastCommittedRevision 26 | 27 | create 28 | 29 | 30 | 35 | 36 | 37 | 38 | 39 | timestampFormat 40 | 41 | create 42 | 43 | 44 | true 45 | yyyy-MM-dd 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.apache.maven.plugins 53 | maven-jar-plugin 54 | 2.5 55 | 56 | 57 | 58 | true 59 | true 60 | true 61 | 62 | 63 | ${buildNumber} 64 | ${timestamp} 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-no-devscm/dotSvnDir/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 82 4 | /mojo/!svn/ver/20268/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it-no-devscm 5 | END 6 | verify.bsh 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 93 10 | /mojo/!svn/ver/14069/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it-no-devscm/verify.bsh 11 | END 12 | goals.txt 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 92 16 | /mojo/!svn/ver/11640/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it-no-devscm/goals.txt 17 | END 18 | pom.xml 19 | K 25 20 | svn:wc:ra_dav:version-url 21 | V 90 22 | /mojo/!svn/ver/20268/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it-no-devscm/pom.xml 23 | END 24 | prebuild.groovy 25 | K 25 26 | svn:wc:ra_dav:version-url 27 | V 98 28 | /mojo/!svn/ver/19666/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it-no-devscm/prebuild.groovy 29 | END 30 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-no-devscm/dotSvnDir/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 20343 5 | https://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it-no-devscm 6 | https://svn.codehaus.org/mojo 7 | 8 | 9 | 10 | 2014-12-18T05:08:42.386925Z 11 | 20268 12 | dantran 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 52ab4f32-60fc-0310-b215-8acea882cd1b 28 | 29 | verify.bsh 30 | file 31 | 32 | 33 | 34 | 35 | 2015-01-20T01:01:38.962313Z 36 | bd97673b62e6f3094f713835a201da23 37 | 2011-05-19T13:46:22.105253Z 38 | 14069 39 | afloom 40 | has-props 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 1940 62 | 63 | goals.txt 64 | file 65 | 66 | 67 | 68 | 69 | 2015-01-20T01:01:38.962313Z 70 | 55ee58816cee90eff0dd03ac8105b0b6 71 | 2009-02-15T21:01:12.735039Z 72 | 9038 73 | bentmann 74 | has-props 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 13 96 | 97 | pom.xml 98 | file 99 | 100 | 101 | 102 | 103 | 2015-01-20T01:01:38.962313Z 104 | 198b8d9ad87ca89afa1bfdf9c98f0487 105 | 2014-12-18T05:08:42.386925Z 106 | 20268 107 | dantran 108 | has-props 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 2294 130 | 131 | prebuild.groovy 132 | file 133 | 134 | 135 | 136 | 137 | 2015-01-20T01:01:38.962313Z 138 | 21ef75b15aaa10c3d613b1e4de0bdaf4 139 | 2014-04-21T20:58:32.561185Z 140 | 19666 141 | baptiste 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 159 164 | 165 | dotSvnDir 166 | dir 167 | 168 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-no-devscm/dotSvnDir/format: -------------------------------------------------------------------------------- 1 | 12 2 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-no-devscm/dotSvnDir/pristine/66/665af71baa943cdae96c0623d3c24e6ec712ec9b.svn-base: -------------------------------------------------------------------------------- 1 | clean verify 2 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-no-devscm/dotSvnDir/pristine/a7/a750eb2c5a1c425e5d3886eecde6b6a98bdb399f.svn-base: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | */ 20 | 21 | import java.io.*; 22 | import java.util.*; 23 | import java.util.jar.*; 24 | import org.codehaus.plexus.util.*; 25 | 26 | boolean result = true; 27 | 28 | try 29 | { 30 | File target = new File( basedir, "target" ); 31 | if ( !target.exists() || !target.isDirectory() ) 32 | { 33 | System.err.println( "target file is missing or not a directory." ); 34 | return false; 35 | } 36 | 37 | File artifact = new File ( target, "buildnumber-maven-plugin-basic-it-no-devscm-1.0-SNAPSHOT.jar" ); 38 | if ( !artifact.exists() || artifact.isDirectory() ) 39 | { 40 | System.err.println( "artifact file is missing or a directory." ); 41 | return false; 42 | } 43 | 44 | JarFile jar = new JarFile( artifact ); 45 | 46 | Attributes manifest = jar.getManifest().getMainAttributes(); 47 | 48 | String scmRev = manifest.get( new Attributes.Name( "SCM-Revision" ) ); 49 | if ( scmRev == null || scmRev.length() < 1 ) 50 | { 51 | System.err.println( "No manifest entry SCM-Revision" ); 52 | return false; 53 | } 54 | // assert we can parse it as long 55 | Long.parseLong( scmRev ); 56 | 57 | } 58 | catch( Throwable e ) 59 | { 60 | e.printStackTrace(); 61 | result = false; 62 | } 63 | 64 | return result; 65 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-no-devscm/dotSvnDir/pristine/b8/b87a2294a5074b47315f9fac29b4930d2a2b7ae5.svn-base: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-basic-it-no-devscm 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:svn:http://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it 12 | 13 | 14 | 15 | 16 | package 17 | 18 | 19 | 20 | org.codehaus.mojo 21 | buildnumber-maven-plugin 22 | @pom.version@ 23 | 24 | 25 | useLastCommittedRevision 26 | test 27 | 28 | create 29 | 30 | 31 | true 32 | 33 | 34 | 35 | 36 | timestampFormat 37 | test 38 | 39 | create 40 | 41 | 42 | true 43 | yyyy-MM-dd 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.apache.maven.plugins 51 | maven-jar-plugin 52 | 53 | 54 | 55 | true 56 | true 57 | true 58 | 59 | 60 | ${buildNumber} 61 | ${timestamp} 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-no-devscm/dotSvnDir/prop-base/goals.txt.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:eol-style 3 | V 6 4 | native 5 | K 12 6 | svn:keywords 7 | V 23 8 | Author Date Id Revision 9 | END 10 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-no-devscm/dotSvnDir/prop-base/pom.xml.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:eol-style 3 | V 6 4 | native 5 | K 12 6 | svn:keywords 7 | V 23 8 | Author Date Id Revision 9 | END 10 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-no-devscm/dotSvnDir/prop-base/verify.bsh.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:eol-style 3 | V 6 4 | native 5 | K 12 6 | svn:keywords 7 | V 23 8 | Author Date Id Revision 9 | END 10 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-no-devscm/dotSvnDir/text-base/goals.txt.svn-base: -------------------------------------------------------------------------------- 1 | clean verify 2 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-no-devscm/dotSvnDir/text-base/pom.xml.svn-base: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-basic-it-no-devscm 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:svn:http://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it 12 | 13 | 14 | 15 | 16 | package 17 | 18 | 19 | 20 | org.codehaus.mojo 21 | buildnumber-maven-plugin 22 | @pom.version@ 23 | 24 | 25 | useLastCommittedRevision 26 | test 27 | 28 | create 29 | 30 | 31 | true 32 | 33 | 34 | 35 | 36 | timestampFormat 37 | test 38 | 39 | create 40 | 41 | 42 | true 43 | yyyy-MM-dd 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.apache.maven.plugins 51 | maven-jar-plugin 52 | 2.5 53 | 54 | 55 | 56 | true 57 | true 58 | true 59 | 60 | 61 | ${buildNumber} 62 | ${timestamp} 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-no-devscm/dotSvnDir/text-base/prebuild.groovy.svn-base: -------------------------------------------------------------------------------- 1 | File dotSvnDir = new File(basedir, 'dotSvnDir') 2 | assert dotSvnDir.exists() 3 | assert dotSvnDir.isDirectory() 4 | assert dotSvnDir.renameTo(new File(basedir, '.svn')) 5 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-no-devscm/dotSvnDir/text-base/verify.bsh.svn-base: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | */ 20 | 21 | import java.io.*; 22 | import java.util.*; 23 | import java.util.jar.*; 24 | import org.codehaus.plexus.util.*; 25 | 26 | boolean result = true; 27 | 28 | try 29 | { 30 | File target = new File( basedir, "target" ); 31 | if ( !target.exists() || !target.isDirectory() ) 32 | { 33 | System.err.println( "target file is missing or not a directory." ); 34 | return false; 35 | } 36 | 37 | File artifact = new File ( target, "buildnumber-maven-plugin-basic-it-no-devscm-1.0-SNAPSHOT.jar" ); 38 | if ( !artifact.exists() || artifact.isDirectory() ) 39 | { 40 | System.err.println( "artifact file is missing or a directory." ); 41 | return false; 42 | } 43 | 44 | JarFile jar = new JarFile( artifact ); 45 | 46 | Attributes manifest = jar.getManifest().getMainAttributes(); 47 | 48 | String scmRev = manifest.get( new Attributes.Name( "SCM-Revision" ) ); 49 | if ( scmRev == null || scmRev.length() < 1 ) 50 | { 51 | System.err.println( "No manifest entry SCM-Revision" ); 52 | return false; 53 | } 54 | // assert we can parse it as long 55 | Long.parseLong( scmRev ); 56 | 57 | } 58 | catch( Throwable e ) 59 | { 60 | e.printStackTrace(); 61 | result = false; 62 | } 63 | 64 | return result; 65 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-no-devscm/dotSvnDir/wc.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/buildnumber-maven-plugin/909857a873fe927f4332d585f9db14265851b99d/src/test/projects/basic-it-no-devscm/dotSvnDir/wc.db -------------------------------------------------------------------------------- /src/test/projects/basic-it-no-devscm/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-basic-it-no-devscm 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:svn:http://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it 12 | 13 | 14 | 15 | 16 | package 17 | 18 | 19 | 20 | org.codehaus.mojo 21 | buildnumber-maven-plugin 22 | ${it-plugin.version} 23 | 24 | 25 | useLastCommittedRevision 26 | test 27 | 28 | create 29 | 30 | 31 | true 32 | 33 | 34 | 35 | 36 | timestampFormat 37 | test 38 | 39 | create 40 | 41 | 42 | true 43 | yyyy-MM-dd 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.apache.maven.plugins 51 | maven-jar-plugin 52 | 2.5 53 | 54 | 55 | 56 | true 57 | true 58 | true 59 | 60 | 61 | ${buildNumber} 62 | ${timestamp} 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-svnjava/dotSvnDir/entries: -------------------------------------------------------------------------------- 1 | 12 2 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-svnjava/dotSvnDir/format: -------------------------------------------------------------------------------- 1 | 12 2 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-svnjava/dotSvnDir/pristine/66/665af71baa943cdae96c0623d3c24e6ec712ec9b.svn-base: -------------------------------------------------------------------------------- 1 | clean verify 2 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-svnjava/dotSvnDir/pristine/69/69cf779236fb30b6c4f2880001ec9dd23bdcd5b8.svn-base: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | */ 20 | 21 | import java.io.*; 22 | import java.util.*; 23 | import java.util.jar.*; 24 | import org.codehaus.plexus.util.*; 25 | 26 | boolean result = true; 27 | 28 | try 29 | { 30 | File target = new File( basedir, "target" ); 31 | if ( !target.exists() || !target.isDirectory() ) 32 | { 33 | System.err.println( "target file is missing or not a directory." ); 34 | return false; 35 | } 36 | 37 | File artifact = new File ( target, "buildnumber-maven-plugin-basic-it-svnjava-1.0-SNAPSHOT.jar" ); 38 | if ( !artifact.exists() || artifact.isDirectory() ) 39 | { 40 | System.err.println( "artifact file is missing or a directory." ); 41 | return false; 42 | } 43 | 44 | JarFile jar = new JarFile( artifact ); 45 | 46 | Attributes manifest = jar.getManifest().getMainAttributes(); 47 | 48 | String scmRev = manifest.get( new Attributes.Name( "SCM-Revision" ) ); 49 | if ( scmRev == null || scmRev.length() < 1 ) 50 | { 51 | System.err.println( "No or empty manifest entry SCM-Revision" ); 52 | return false; 53 | } 54 | // assert we can parse it as long 55 | Long.parseLong( scmRev ); 56 | 57 | 58 | } 59 | catch( Throwable e ) 60 | { 61 | e.printStackTrace(); 62 | result = false; 63 | } 64 | 65 | return result; 66 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-svnjava/dotSvnDir/pristine/76/76ff7cf8f7fb9790d8c2819c640d641d4ff2093f.svn-base: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-basic-it-svnjava 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:svn:http://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it-svnjava 12 | 13 | 14 | 15 | 16 | package 17 | 18 | 19 | 20 | org.codehaus.mojo 21 | buildnumber-maven-plugin 22 | @pom.version@ 23 | 24 | 25 | useLastCommittedRevision 26 | test 27 | 28 | create 29 | 30 | 31 | 32 | javasvn 33 | 34 | true 35 | 36 | 37 | 38 | timestampFormat 39 | test 40 | 41 | create 42 | 43 | 44 | 45 | javasvn 46 | 47 | true 48 | yyyy-MM-dd 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | org.codehaus.mojo 58 | buildnumber-maven-plugin 59 | 60 | 61 | 62 | org.apache.maven.plugins 63 | maven-jar-plugin 64 | 65 | 66 | 67 | true 68 | true 69 | true 70 | 71 | 72 | ${buildNumber} 73 | ${timestamp} 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | svn-1.7 84 | 85 | 86 | .svn 87 | 88 | 89 | 90 | 91 | 92 | 93 | org.codehaus.mojo 94 | buildnumber-maven-plugin 95 | @pom.version@ 96 | 97 | 98 | org.tmatesoft.svnkit 99 | svnkit 100 | 1.8.3-1 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /src/test/projects/basic-it-svnjava/dotSvnDir/wc.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/buildnumber-maven-plugin/909857a873fe927f4332d585f9db14265851b99d/src/test/projects/basic-it-svnjava/dotSvnDir/wc.db -------------------------------------------------------------------------------- /src/test/projects/basic-it-svnjava/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-basic-it-svnjava 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:svn:http://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it-svnjava 12 | 13 | 14 | 15 | 16 | package 17 | 18 | 19 | 20 | org.codehaus.mojo 21 | buildnumber-maven-plugin 22 | ${it-plugin.version} 23 | 24 | 25 | org.tmatesoft.svnkit 26 | svnkit 27 | 1.8.3-1 28 | 29 | 30 | 31 | 32 | useLastCommittedRevision 33 | test 34 | 35 | create 36 | 37 | 38 | 39 | javasvn 40 | 41 | true 42 | 43 | 44 | 45 | timestampFormat 46 | test 47 | 48 | create 49 | 50 | 51 | 52 | javasvn 53 | 54 | true 55 | yyyy-MM-dd 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | org.codehaus.mojo 65 | buildnumber-maven-plugin 66 | 67 | 68 | 69 | org.apache.maven.plugins 70 | maven-jar-plugin 71 | 2.5 72 | 73 | 74 | 75 | true 76 | true 77 | true 78 | 79 | 80 | ${buildNumber} 81 | ${timestamp} 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /src/test/projects/basic-it/dotSvnDir/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 72 4 | /mojo/!svn/ver/20268/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it 5 | END 6 | verify.bsh 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 82 10 | /mojo/!svn/ver/9446/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it/verify.bsh 11 | END 12 | goals.txt 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 81 16 | /mojo/!svn/ver/9038/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it/goals.txt 17 | END 18 | pom.xml 19 | K 25 20 | svn:wc:ra_dav:version-url 21 | V 80 22 | /mojo/!svn/ver/20268/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it/pom.xml 23 | END 24 | prebuild.groovy 25 | K 25 26 | svn:wc:ra_dav:version-url 27 | V 88 28 | /mojo/!svn/ver/19666/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it/prebuild.groovy 29 | END 30 | -------------------------------------------------------------------------------- /src/test/projects/basic-it/dotSvnDir/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 20342 5 | https://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it 6 | https://svn.codehaus.org/mojo 7 | 8 | 9 | 10 | 2014-12-18T05:08:42.386925Z 11 | 20268 12 | dantran 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 52ab4f32-60fc-0310-b215-8acea882cd1b 28 | 29 | verify.bsh 30 | file 31 | 32 | 33 | 34 | 35 | 2015-01-20T00:21:29.535887Z 36 | 62be18e6f3d28f10b59bf35f37f6f7a1 37 | 2009-04-14T21:37:00.260569Z 38 | 9446 39 | olamy 40 | has-props 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 1930 62 | 63 | goals.txt 64 | file 65 | 66 | 67 | 68 | 69 | 2015-01-20T00:21:29.535887Z 70 | 55ee58816cee90eff0dd03ac8105b0b6 71 | 2009-02-15T21:01:12.735039Z 72 | 9038 73 | bentmann 74 | has-props 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 13 96 | 97 | pom.xml 98 | file 99 | 100 | 101 | 102 | 103 | 2015-01-20T00:21:29.535887Z 104 | 7586f8a68e67e311ce1fe540c8f2ac79 105 | 2014-12-18T05:08:42.386925Z 106 | 20268 107 | dantran 108 | has-props 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 2238 130 | 131 | prebuild.groovy 132 | file 133 | 134 | 135 | 136 | 137 | 2015-01-20T00:21:29.535887Z 138 | 21ef75b15aaa10c3d613b1e4de0bdaf4 139 | 2014-04-21T20:58:32.561185Z 140 | 19666 141 | baptiste 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 159 164 | 165 | dotSvnDir 166 | dir 167 | 168 | -------------------------------------------------------------------------------- /src/test/projects/basic-it/dotSvnDir/format: -------------------------------------------------------------------------------- 1 | 12 2 | -------------------------------------------------------------------------------- /src/test/projects/basic-it/dotSvnDir/pristine/42/4256c3d83776cf1d5a315b293085a7dc240c92cb.svn-base: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | */ 20 | 21 | import java.io.*; 22 | import java.util.*; 23 | import java.util.jar.*; 24 | import org.codehaus.plexus.util.*; 25 | 26 | boolean result = true; 27 | 28 | try 29 | { 30 | File target = new File( basedir, "target" ); 31 | if ( !target.exists() || !target.isDirectory() ) 32 | { 33 | System.err.println( "target file is missing or not a directory." ); 34 | return false; 35 | } 36 | 37 | File artifact = new File ( target, "buildnumber-maven-plugin-basic-it-1.0-SNAPSHOT.jar" ); 38 | if ( !artifact.exists() || artifact.isDirectory() ) 39 | { 40 | System.err.println( "artifact file is missing or a directory." ); 41 | return false; 42 | } 43 | 44 | JarFile jar = new JarFile( artifact ); 45 | 46 | Attributes manifest = jar.getManifest().getMainAttributes(); 47 | 48 | String scmRev = manifest.get( new Attributes.Name( "SCM-Revision" ) ); 49 | if ( scmRev == null || scmRev.length() < 1 ) 50 | { 51 | System.err.println( "No manifest entry SCM-Revision" ); 52 | return false; 53 | } 54 | // assert we can parse it as long 55 | Long.parseLong( scmRev ); 56 | 57 | } 58 | catch( Throwable e ) 59 | { 60 | e.printStackTrace(); 61 | result = false; 62 | } 63 | 64 | return result; 65 | -------------------------------------------------------------------------------- /src/test/projects/basic-it/dotSvnDir/pristine/66/665af71baa943cdae96c0623d3c24e6ec712ec9b.svn-base: -------------------------------------------------------------------------------- 1 | clean verify 2 | -------------------------------------------------------------------------------- /src/test/projects/basic-it/dotSvnDir/pristine/be/be81b1b83de4bd67f35fdab9bd4707604ab1c092.svn-base: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-basic-it 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:svn:http://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it 12 | 13 | 14 | 15 | 16 | package 17 | 18 | 19 | 20 | org.codehaus.mojo 21 | buildnumber-maven-plugin 22 | @pom.version@ 23 | 24 | 25 | useLastCommittedRevision 26 | 27 | create 28 | 29 | 30 | true 31 | 32 | 33 | 34 | 35 | timestampFormat 36 | 37 | create 38 | 39 | 40 | true 41 | yyyy-MM-dd 42 | 43 | 44 | 45 | 46 | 47 | 48 | org.apache.maven.plugins 49 | maven-jar-plugin 50 | 51 | 52 | 53 | true 54 | true 55 | true 56 | 57 | 58 | ${buildNumber} 59 | ${timestamp} 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /src/test/projects/basic-it/dotSvnDir/prop-base/goals.txt.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:eol-style 3 | V 6 4 | native 5 | K 12 6 | svn:keywords 7 | V 23 8 | Author Date Id Revision 9 | END 10 | -------------------------------------------------------------------------------- /src/test/projects/basic-it/dotSvnDir/prop-base/pom.xml.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:eol-style 3 | V 6 4 | native 5 | K 12 6 | svn:keywords 7 | V 23 8 | Author Date Id Revision 9 | END 10 | -------------------------------------------------------------------------------- /src/test/projects/basic-it/dotSvnDir/prop-base/verify.bsh.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:eol-style 3 | V 6 4 | native 5 | K 12 6 | svn:keywords 7 | V 23 8 | Author Date Id Revision 9 | END 10 | -------------------------------------------------------------------------------- /src/test/projects/basic-it/dotSvnDir/text-base/goals.txt.svn-base: -------------------------------------------------------------------------------- 1 | clean verify 2 | -------------------------------------------------------------------------------- /src/test/projects/basic-it/dotSvnDir/text-base/pom.xml.svn-base: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-basic-it 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:svn:http://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it 12 | 13 | 14 | 15 | 16 | package 17 | 18 | 19 | 20 | org.codehaus.mojo 21 | buildnumber-maven-plugin 22 | @pom.version@ 23 | 24 | 25 | useLastCommittedRevision 26 | 27 | create 28 | 29 | 30 | true 31 | 32 | 33 | 34 | 35 | timestampFormat 36 | 37 | create 38 | 39 | 40 | true 41 | yyyy-MM-dd 42 | 43 | 44 | 45 | 46 | 47 | 48 | org.apache.maven.plugins 49 | maven-jar-plugin 50 | 2.5 51 | 52 | 53 | 54 | true 55 | true 56 | true 57 | 58 | 59 | ${buildNumber} 60 | ${timestamp} 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /src/test/projects/basic-it/dotSvnDir/text-base/prebuild.groovy.svn-base: -------------------------------------------------------------------------------- 1 | File dotSvnDir = new File(basedir, 'dotSvnDir') 2 | assert dotSvnDir.exists() 3 | assert dotSvnDir.isDirectory() 4 | assert dotSvnDir.renameTo(new File(basedir, '.svn')) 5 | -------------------------------------------------------------------------------- /src/test/projects/basic-it/dotSvnDir/text-base/verify.bsh.svn-base: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | */ 20 | 21 | import java.io.*; 22 | import java.util.*; 23 | import java.util.jar.*; 24 | import org.codehaus.plexus.util.*; 25 | 26 | boolean result = true; 27 | 28 | try 29 | { 30 | File target = new File( basedir, "target" ); 31 | if ( !target.exists() || !target.isDirectory() ) 32 | { 33 | System.err.println( "target file is missing or not a directory." ); 34 | return false; 35 | } 36 | 37 | File artifact = new File ( target, "buildnumber-maven-plugin-basic-it-1.0-SNAPSHOT.jar" ); 38 | if ( !artifact.exists() || artifact.isDirectory() ) 39 | { 40 | System.err.println( "artifact file is missing or a directory." ); 41 | return false; 42 | } 43 | 44 | JarFile jar = new JarFile( artifact ); 45 | 46 | Attributes manifest = jar.getManifest().getMainAttributes(); 47 | 48 | String scmRev = manifest.get( new Attributes.Name( "SCM-Revision" ) ); 49 | if ( scmRev == null || scmRev.length() < 1 ) 50 | { 51 | System.err.println( "No manifest entry SCM-Revision" ); 52 | return false; 53 | } 54 | // assert we can parse it as long 55 | Long.parseLong( scmRev ); 56 | 57 | } 58 | catch( Throwable e ) 59 | { 60 | e.printStackTrace(); 61 | result = false; 62 | } 63 | 64 | return result; 65 | -------------------------------------------------------------------------------- /src/test/projects/basic-it/dotSvnDir/wc.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/buildnumber-maven-plugin/909857a873fe927f4332d585f9db14265851b99d/src/test/projects/basic-it/dotSvnDir/wc.db -------------------------------------------------------------------------------- /src/test/projects/basic-it/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-basic-it 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:svn:http://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it 12 | 13 | 14 | 15 | 16 | package 17 | 18 | 19 | 20 | org.codehaus.mojo 21 | buildnumber-maven-plugin 22 | ${it-plugin.version} 23 | 24 | 25 | useLastCommittedRevision 26 | 27 | create 28 | 29 | 30 | true 31 | 32 | 33 | 34 | 35 | timestampFormat 36 | 37 | create 38 | 39 | 40 | true 41 | yyyy-MM-dd 42 | 43 | 44 | 45 | 46 | 47 | 48 | org.apache.maven.plugins 49 | maven-jar-plugin 50 | 2.5 51 | 52 | 53 | 54 | true 55 | true 56 | true 57 | 58 | 59 | ${buildNumber} 60 | ${timestamp} 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /src/test/projects/create-metadata-it-no-scm/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | build-metadata-it 8 | 1.0-SNAPSHOT 9 | 10 | 11 | 12 | package 13 | 14 | 15 | 16 | org.codehaus.mojo 17 | buildnumber-maven-plugin 18 | ${it-plugin.version} 19 | 20 | 21 | useLastCommittedRevision 22 | 23 | create-metadata 24 | 25 | 26 | true 27 | UNKNOWN 28 | 29 | 30 | ${project.build.directory}/file1.properties 31 | ${project.build.directory}/xxx/file1.properties 32 | 33 | true 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/test/projects/create-metadata-it/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | build-metadata-it 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:svn:http://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/test/projects/bogus 12 | 13 | 14 | 15 | 16 | package 17 | 18 | 19 | 20 | org.codehaus.mojo 21 | buildnumber-maven-plugin 22 | ${it-plugin.version} 23 | 24 | 25 | useLastCommittedRevision 26 | 27 | create-metadata 28 | 29 | 30 | UNKNOWN 31 | 32 | 33 | ${project.build.directory}/file1.properties 34 | ${project.build.directory}/xxx/file1.properties 35 | 36 | true 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/test/projects/create-metadata-json-it/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | build-metadata-it 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:svn:http://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/test/projects/bogus 12 | 13 | 14 | 15 | 16 | package 17 | 18 | 19 | 20 | org.codehaus.mojo 21 | buildnumber-maven-plugin 22 | ${it-plugin.version} 23 | 24 | 25 | useLastCommittedRevision 26 | 27 | create-metadata 28 | 29 | 30 | true 31 | UNKNOWN 32 | 33 | 34 | ${project.build.directory}/file1.json 35 | ${project.build.directory}/xxx/file1.json 36 | 37 | true 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/test/projects/create-timestamp-it/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-create-timestamp-it 8 | 1.0-SNAPSHOT 9 | 10 | 11 | 12 | package 13 | 14 | 15 | 16 | org.codehaus.mojo 17 | buildnumber-maven-plugin 18 | ${it-plugin.version} 19 | 20 | 21 | useLastCommittedRevision 22 | 23 | create-timestamp 24 | 25 | 26 | datetime 27 | yyyy-MM-dd hh:mm:ss 28 | 29 | 30 | 31 | 32 | 33 | 34 | org.apache.maven.plugins 35 | maven-jar-plugin 36 | 2.5 37 | 38 | 39 | 40 | true 41 | true 42 | true 43 | 44 | 45 | ${datetime} 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/test/projects/failed-local-change/dotSvnDir/entries: -------------------------------------------------------------------------------- 1 | 12 2 | -------------------------------------------------------------------------------- /src/test/projects/failed-local-change/dotSvnDir/format: -------------------------------------------------------------------------------- 1 | 12 2 | -------------------------------------------------------------------------------- /src/test/projects/failed-local-change/dotSvnDir/pristine/25/25f1c1a58e866ed76b657410f17ca48d4484de36.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | def f1 = new File(basedir, 'thefoo.txt'); 21 | f1.append( "abcdefg" ); -------------------------------------------------------------------------------- /src/test/projects/failed-local-change/dotSvnDir/pristine/2a/2afd738d40bbd3cc7e848d611404949c779db22f.svn-base: -------------------------------------------------------------------------------- 1 | invoker.goals = buildnumber:create 2 | #clean test 3 | invoker.buildResult = failure 4 | -------------------------------------------------------------------------------- /src/test/projects/failed-local-change/dotSvnDir/pristine/bc/bc297aecdc5665a9e47a19b7876b07cef3a8c161.svn-base: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-failed-local-change 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:svn:http://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it 12 | 13 | 14 | 15 | 16 | package 17 | 18 | 19 | 20 | org.codehaus.mojo 21 | buildnumber-maven-plugin 22 | @pom.version@ 23 | 24 | true 25 | false 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/test/projects/failed-local-change/dotSvnDir/pristine/d8/d8f6dc5ed1a19e5d6c0fa3f9f8b1a2bd6b76042c.svn-base: -------------------------------------------------------------------------------- 1 | emptyabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefg -------------------------------------------------------------------------------- /src/test/projects/failed-local-change/dotSvnDir/wc.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/buildnumber-maven-plugin/909857a873fe927f4332d585f9db14265851b99d/src/test/projects/failed-local-change/dotSvnDir/wc.db -------------------------------------------------------------------------------- /src/test/projects/failed-local-change/foo.txt: -------------------------------------------------------------------------------- 1 | emptyabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefg -------------------------------------------------------------------------------- /src/test/projects/failed-local-change/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-failed-local-change 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:svn:http://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/it/basic-it 12 | 13 | 14 | 15 | 16 | package 17 | 18 | 19 | 20 | org.codehaus.mojo 21 | buildnumber-maven-plugin 22 | ${it-plugin.version} 23 | 24 | true 25 | false 26 | 27 | 28 | 29 | create 30 | 31 | create 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/COMMIT_EDITMSG: -------------------------------------------------------------------------------- 1 | Bim 2 | # Veuillez saisir le message de validation pour vos modifications. Les lignes 3 | # commençant par '#' seront ignorées, et un message vide abandonne la validation. 4 | # Sur la branche master 5 | # Modifications qui seront validées : 6 | # nouveau fichier: goals.txt 7 | # nouveau fichier: pom.xml 8 | # nouveau fichier: prebuild.groovy 9 | # nouveau fichier: verify.bsh 10 | # 11 | -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = false 5 | logallrefupdates = true 6 | -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/description: -------------------------------------------------------------------------------- 1 | Unnamed repository; edit this file 'description' to name the repository. 2 | -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/hooks/applypatch-msg.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to check the commit log message taken by 4 | # applypatch from an e-mail message. 5 | # 6 | # The hook should exit with non-zero status after issuing an 7 | # appropriate message if it wants to stop the commit. The hook is 8 | # allowed to edit the commit message file. 9 | # 10 | # To enable this hook, rename this file to "applypatch-msg". 11 | 12 | . git-sh-setup 13 | test -x "$GIT_DIR/hooks/commit-msg" && 14 | exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"} 15 | : 16 | -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/hooks/commit-msg.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to check the commit log message. 4 | # Called by "git commit" with one argument, the name of the file 5 | # that has the commit message. The hook should exit with non-zero 6 | # status after issuing an appropriate message if it wants to stop the 7 | # commit. The hook is allowed to edit the commit message file. 8 | # 9 | # To enable this hook, rename this file to "commit-msg". 10 | 11 | # Uncomment the below to add a Signed-off-by line to the message. 12 | # Doing this in a hook is a bad idea in general, but the prepare-commit-msg 13 | # hook is more suited to it. 14 | # 15 | # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') 16 | # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" 17 | 18 | # This example catches duplicate Signed-off-by lines. 19 | 20 | test "" = "$(grep '^Signed-off-by: ' "$1" | 21 | sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { 22 | echo >&2 Duplicate Signed-off-by lines. 23 | exit 1 24 | } 25 | -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/hooks/post-update.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to prepare a packed repository for use over 4 | # dumb transports. 5 | # 6 | # To enable this hook, rename this file to "post-update". 7 | 8 | exec git update-server-info 9 | -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/hooks/pre-applypatch.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to verify what is about to be committed 4 | # by applypatch from an e-mail message. 5 | # 6 | # The hook should exit with non-zero status after issuing an 7 | # appropriate message if it wants to stop the commit. 8 | # 9 | # To enable this hook, rename this file to "pre-applypatch". 10 | 11 | . git-sh-setup 12 | test -x "$GIT_DIR/hooks/pre-commit" && 13 | exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"} 14 | : 15 | -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/hooks/pre-commit.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to verify what is about to be committed. 4 | # Called by "git commit" with no arguments. The hook should 5 | # exit with non-zero status after issuing an appropriate message if 6 | # it wants to stop the commit. 7 | # 8 | # To enable this hook, rename this file to "pre-commit". 9 | 10 | if git rev-parse --verify HEAD >/dev/null 2>&1 11 | then 12 | against=HEAD 13 | else 14 | # Initial commit: diff against an empty tree object 15 | against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 16 | fi 17 | 18 | # If you want to allow non-ASCII filenames set this variable to true. 19 | allownonascii=$(git config --bool hooks.allownonascii) 20 | 21 | # Redirect output to stderr. 22 | exec 1>&2 23 | 24 | # Cross platform projects tend to avoid non-ASCII filenames; prevent 25 | # them from being added to the repository. We exploit the fact that the 26 | # printable range starts at the space character and ends with tilde. 27 | if [ "$allownonascii" != "true" ] && 28 | # Note that the use of brackets around a tr range is ok here, (it's 29 | # even required, for portability to Solaris 10's /usr/bin/tr), since 30 | # the square bracket bytes happen to fall in the designated range. 31 | test $(git diff --cached --name-only --diff-filter=A -z $against | 32 | LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 33 | then 34 | cat <<\EOF 35 | Error: Attempt to add a non-ASCII file name. 36 | 37 | This can cause problems if you want to work with people on other platforms. 38 | 39 | To be portable it is advisable to rename the file. 40 | 41 | If you know what you are doing you can disable this check using: 42 | 43 | git config hooks.allownonascii true 44 | EOF 45 | exit 1 46 | fi 47 | 48 | # If there are whitespace errors, print the offending file names and fail. 49 | exec git diff-index --check --cached $against -- 50 | -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/hooks/pre-push.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # An example hook script to verify what is about to be pushed. Called by "git 4 | # push" after it has checked the remote status, but before anything has been 5 | # pushed. If this script exits with a non-zero status nothing will be pushed. 6 | # 7 | # This hook is called with the following parameters: 8 | # 9 | # $1 -- Name of the remote to which the push is being done 10 | # $2 -- URL to which the push is being done 11 | # 12 | # If pushing without using a named remote those arguments will be equal. 13 | # 14 | # Information about the commits which are being pushed is supplied as lines to 15 | # the standard input in the form: 16 | # 17 | # 18 | # 19 | # This sample shows how to prevent push of commits where the log message starts 20 | # with "WIP" (work in progress). 21 | 22 | remote="$1" 23 | url="$2" 24 | 25 | z40=0000000000000000000000000000000000000000 26 | 27 | IFS=' ' 28 | while read local_ref local_sha remote_ref remote_sha 29 | do 30 | if [ "$local_sha" = $z40 ] 31 | then 32 | # Handle delete 33 | : 34 | else 35 | if [ "$remote_sha" = $z40 ] 36 | then 37 | # New branch, examine all commits 38 | range="$local_sha" 39 | else 40 | # Update to existing branch, examine new commits 41 | range="$remote_sha..$local_sha" 42 | fi 43 | 44 | # Check for WIP commit 45 | commit=`git rev-list -n 1 --grep '^WIP' "$range"` 46 | if [ -n "$commit" ] 47 | then 48 | echo "Found WIP commit in $local_ref, not pushing" 49 | exit 1 50 | fi 51 | fi 52 | done 53 | 54 | exit 0 55 | -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/hooks/pre-rebase.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright (c) 2006, 2008 Junio C Hamano 4 | # 5 | # The "pre-rebase" hook is run just before "git rebase" starts doing 6 | # its job, and can prevent the command from running by exiting with 7 | # non-zero status. 8 | # 9 | # The hook is called with the following parameters: 10 | # 11 | # $1 -- the upstream the series was forked from. 12 | # $2 -- the branch being rebased (or empty when rebasing the current branch). 13 | # 14 | # This sample shows how to prevent topic branches that are already 15 | # merged to 'next' branch from getting rebased, because allowing it 16 | # would result in rebasing already published history. 17 | 18 | publish=next 19 | basebranch="$1" 20 | if test "$#" = 2 21 | then 22 | topic="refs/heads/$2" 23 | else 24 | topic=`git symbolic-ref HEAD` || 25 | exit 0 ;# we do not interrupt rebasing detached HEAD 26 | fi 27 | 28 | case "$topic" in 29 | refs/heads/??/*) 30 | ;; 31 | *) 32 | exit 0 ;# we do not interrupt others. 33 | ;; 34 | esac 35 | 36 | # Now we are dealing with a topic branch being rebased 37 | # on top of master. Is it OK to rebase it? 38 | 39 | # Does the topic really exist? 40 | git show-ref -q "$topic" || { 41 | echo >&2 "No such branch $topic" 42 | exit 1 43 | } 44 | 45 | # Is topic fully merged to master? 46 | not_in_master=`git rev-list --pretty=oneline ^master "$topic"` 47 | if test -z "$not_in_master" 48 | then 49 | echo >&2 "$topic is fully merged to master; better remove it." 50 | exit 1 ;# we could allow it, but there is no point. 51 | fi 52 | 53 | # Is topic ever merged to next? If so you should not be rebasing it. 54 | only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` 55 | only_next_2=`git rev-list ^master ${publish} | sort` 56 | if test "$only_next_1" = "$only_next_2" 57 | then 58 | not_in_topic=`git rev-list "^$topic" master` 59 | if test -z "$not_in_topic" 60 | then 61 | echo >&2 "$topic is already up-to-date with master" 62 | exit 1 ;# we could allow it, but there is no point. 63 | else 64 | exit 0 65 | fi 66 | else 67 | not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` 68 | /usr/bin/perl -e ' 69 | my $topic = $ARGV[0]; 70 | my $msg = "* $topic has commits already merged to public branch:\n"; 71 | my (%not_in_next) = map { 72 | /^([0-9a-f]+) /; 73 | ($1 => 1); 74 | } split(/\n/, $ARGV[1]); 75 | for my $elem (map { 76 | /^([0-9a-f]+) (.*)$/; 77 | [$1 => $2]; 78 | } split(/\n/, $ARGV[2])) { 79 | if (!exists $not_in_next{$elem->[0]}) { 80 | if ($msg) { 81 | print STDERR $msg; 82 | undef $msg; 83 | } 84 | print STDERR " $elem->[1]\n"; 85 | } 86 | } 87 | ' "$topic" "$not_in_next" "$not_in_master" 88 | exit 1 89 | fi 90 | 91 | <<\DOC_END 92 | 93 | This sample hook safeguards topic branches that have been 94 | published from being rewound. 95 | 96 | The workflow assumed here is: 97 | 98 | * Once a topic branch forks from "master", "master" is never 99 | merged into it again (either directly or indirectly). 100 | 101 | * Once a topic branch is fully cooked and merged into "master", 102 | it is deleted. If you need to build on top of it to correct 103 | earlier mistakes, a new topic branch is created by forking at 104 | the tip of the "master". This is not strictly necessary, but 105 | it makes it easier to keep your history simple. 106 | 107 | * Whenever you need to test or publish your changes to topic 108 | branches, merge them into "next" branch. 109 | 110 | The script, being an example, hardcodes the publish branch name 111 | to be "next", but it is trivial to make it configurable via 112 | $GIT_DIR/config mechanism. 113 | 114 | With this workflow, you would want to know: 115 | 116 | (1) ... if a topic branch has ever been merged to "next". Young 117 | topic branches can have stupid mistakes you would rather 118 | clean up before publishing, and things that have not been 119 | merged into other branches can be easily rebased without 120 | affecting other people. But once it is published, you would 121 | not want to rewind it. 122 | 123 | (2) ... if a topic branch has been fully merged to "master". 124 | Then you can delete it. More importantly, you should not 125 | build on top of it -- other people may already want to 126 | change things related to the topic as patches against your 127 | "master", so if you need further changes, it is better to 128 | fork the topic (perhaps with the same name) afresh from the 129 | tip of "master". 130 | 131 | Let's look at this example: 132 | 133 | o---o---o---o---o---o---o---o---o---o "next" 134 | / / / / 135 | / a---a---b A / / 136 | / / / / 137 | / / c---c---c---c B / 138 | / / / \ / 139 | / / / b---b C \ / 140 | / / / / \ / 141 | ---o---o---o---o---o---o---o---o---o---o---o "master" 142 | 143 | 144 | A, B and C are topic branches. 145 | 146 | * A has one fix since it was merged up to "next". 147 | 148 | * B has finished. It has been fully merged up to "master" and "next", 149 | and is ready to be deleted. 150 | 151 | * C has not merged to "next" at all. 152 | 153 | We would want to allow C to be rebased, refuse A, and encourage 154 | B to be deleted. 155 | 156 | To compute (1): 157 | 158 | git rev-list ^master ^topic next 159 | git rev-list ^master next 160 | 161 | if these match, topic has not merged in next at all. 162 | 163 | To compute (2): 164 | 165 | git rev-list master..topic 166 | 167 | if this is empty, it is fully merged to "master". 168 | 169 | DOC_END 170 | -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/hooks/prepare-commit-msg.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to prepare the commit log message. 4 | # Called by "git commit" with the name of the file that has the 5 | # commit message, followed by the description of the commit 6 | # message's source. The hook's purpose is to edit the commit 7 | # message file. If the hook fails with a non-zero status, 8 | # the commit is aborted. 9 | # 10 | # To enable this hook, rename this file to "prepare-commit-msg". 11 | 12 | # This hook includes three examples. The first comments out the 13 | # "Conflicts:" part of a merge commit. 14 | # 15 | # The second includes the output of "git diff --name-status -r" 16 | # into the message, just before the "git status" output. It is 17 | # commented because it doesn't cope with --amend or with squashed 18 | # commits. 19 | # 20 | # The third example adds a Signed-off-by line to the message, that can 21 | # still be edited. This is rarely a good idea. 22 | 23 | case "$2,$3" in 24 | merge,) 25 | /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; 26 | 27 | # ,|template,) 28 | # /usr/bin/perl -i.bak -pe ' 29 | # print "\n" . `git diff --cached --name-status -r` 30 | # if /^#/ && $first++ == 0' "$1" ;; 31 | 32 | *) ;; 33 | esac 34 | 35 | # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') 36 | # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" 37 | -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/hooks/update.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to blocks unannotated tags from entering. 4 | # Called by "git receive-pack" with arguments: refname sha1-old sha1-new 5 | # 6 | # To enable this hook, rename this file to "update". 7 | # 8 | # Config 9 | # ------ 10 | # hooks.allowunannotated 11 | # This boolean sets whether unannotated tags will be allowed into the 12 | # repository. By default they won't be. 13 | # hooks.allowdeletetag 14 | # This boolean sets whether deleting tags will be allowed in the 15 | # repository. By default they won't be. 16 | # hooks.allowmodifytag 17 | # This boolean sets whether a tag may be modified after creation. By default 18 | # it won't be. 19 | # hooks.allowdeletebranch 20 | # This boolean sets whether deleting branches will be allowed in the 21 | # repository. By default they won't be. 22 | # hooks.denycreatebranch 23 | # This boolean sets whether remotely creating branches will be denied 24 | # in the repository. By default this is allowed. 25 | # 26 | 27 | # --- Command line 28 | refname="$1" 29 | oldrev="$2" 30 | newrev="$3" 31 | 32 | # --- Safety check 33 | if [ -z "$GIT_DIR" ]; then 34 | echo "Don't run this script from the command line." >&2 35 | echo " (if you want, you could supply GIT_DIR then run" >&2 36 | echo " $0 )" >&2 37 | exit 1 38 | fi 39 | 40 | if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then 41 | echo "usage: $0 " >&2 42 | exit 1 43 | fi 44 | 45 | # --- Config 46 | allowunannotated=$(git config --bool hooks.allowunannotated) 47 | allowdeletebranch=$(git config --bool hooks.allowdeletebranch) 48 | denycreatebranch=$(git config --bool hooks.denycreatebranch) 49 | allowdeletetag=$(git config --bool hooks.allowdeletetag) 50 | allowmodifytag=$(git config --bool hooks.allowmodifytag) 51 | 52 | # check for no description 53 | projectdesc=$(sed -e '1q' "$GIT_DIR/description") 54 | case "$projectdesc" in 55 | "Unnamed repository"* | "") 56 | echo "*** Project description file hasn't been set" >&2 57 | exit 1 58 | ;; 59 | esac 60 | 61 | # --- Check types 62 | # if $newrev is 0000...0000, it's a commit to delete a ref. 63 | zero="0000000000000000000000000000000000000000" 64 | if [ "$newrev" = "$zero" ]; then 65 | newrev_type=delete 66 | else 67 | newrev_type=$(git cat-file -t $newrev) 68 | fi 69 | 70 | case "$refname","$newrev_type" in 71 | refs/tags/*,commit) 72 | # un-annotated tag 73 | short_refname=${refname##refs/tags/} 74 | if [ "$allowunannotated" != "true" ]; then 75 | echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 76 | echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 77 | exit 1 78 | fi 79 | ;; 80 | refs/tags/*,delete) 81 | # delete tag 82 | if [ "$allowdeletetag" != "true" ]; then 83 | echo "*** Deleting a tag is not allowed in this repository" >&2 84 | exit 1 85 | fi 86 | ;; 87 | refs/tags/*,tag) 88 | # annotated tag 89 | if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 90 | then 91 | echo "*** Tag '$refname' already exists." >&2 92 | echo "*** Modifying a tag is not allowed in this repository." >&2 93 | exit 1 94 | fi 95 | ;; 96 | refs/heads/*,commit) 97 | # branch 98 | if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then 99 | echo "*** Creating a branch is not allowed in this repository" >&2 100 | exit 1 101 | fi 102 | ;; 103 | refs/heads/*,delete) 104 | # delete branch 105 | if [ "$allowdeletebranch" != "true" ]; then 106 | echo "*** Deleting a branch is not allowed in this repository" >&2 107 | exit 1 108 | fi 109 | ;; 110 | refs/remotes/*,commit) 111 | # tracking branch 112 | ;; 113 | refs/remotes/*,delete) 114 | # delete tracking branch 115 | if [ "$allowdeletebranch" != "true" ]; then 116 | echo "*** Deleting a tracking branch is not allowed in this repository" >&2 117 | exit 1 118 | fi 119 | ;; 120 | *) 121 | # Anything else (is there anything else?) 122 | echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 123 | exit 1 124 | ;; 125 | esac 126 | 127 | # --- Finished 128 | exit 0 129 | -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/buildnumber-maven-plugin/909857a873fe927f4332d585f9db14265851b99d/src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/index -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/info/exclude: -------------------------------------------------------------------------------- 1 | # git ls-files --others --exclude-from=.git/info/exclude 2 | # Lines that start with '#' are comments. 3 | # For a project mostly in C, the following would be a good set of 4 | # exclude patterns (uncomment them if you want to use them): 5 | # *.[oa] 6 | # *~ 7 | -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/logs/HEAD: -------------------------------------------------------------------------------- 1 | 0000000000000000000000000000000000000000 b46131b51b0e59b4fcdf88ee76060aa0d099b36e Baptiste Mathus 1398546606 +0200 commit (initial): Initial commit 2 | b46131b51b0e59b4fcdf88ee76060aa0d099b36e c5ff2ebf8dc0ff4568b1d63905c83fa11942e55e Baptiste Mathus 1398546788 +0200 commit: .gitignore... 3 | c5ff2ebf8dc0ff4568b1d63905c83fa11942e55e ee58acb27b6636a497c1185f80cd15f76134113f Baptiste Mathus 1398546802 +0200 commit: Bim 4 | -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/logs/refs/heads/master: -------------------------------------------------------------------------------- 1 | 0000000000000000000000000000000000000000 b46131b51b0e59b4fcdf88ee76060aa0d099b36e Baptiste Mathus 1398546606 +0200 commit (initial): Initial commit 2 | b46131b51b0e59b4fcdf88ee76060aa0d099b36e c5ff2ebf8dc0ff4568b1d63905c83fa11942e55e Baptiste Mathus 1398546788 +0200 commit: .gitignore... 3 | c5ff2ebf8dc0ff4568b1d63905c83fa11942e55e ee58acb27b6636a497c1185f80cd15f76134113f Baptiste Mathus 1398546802 +0200 commit: Bim 4 | -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/2f/7896d1d1365eafb0da03d9fe456fac81408487: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/buildnumber-maven-plugin/909857a873fe927f4332d585f9db14265851b99d/src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/2f/7896d1d1365eafb0da03d9fe456fac81408487 -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/31/ed2f87a271c293b2727ef50e36f871201ff06b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/buildnumber-maven-plugin/909857a873fe927f4332d585f9db14265851b99d/src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/31/ed2f87a271c293b2727ef50e36f871201ff06b -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904: -------------------------------------------------------------------------------- 1 | x+)JMU0` 2 | , -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/64/e108d3f1835cc2691abbe3f987743da2447f7e: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/buildnumber-maven-plugin/909857a873fe927f4332d585f9db14265851b99d/src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/64/e108d3f1835cc2691abbe3f987743da2447f7e -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/79/4b0e3da190e2acb55f414ff28ba04485af3659: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/buildnumber-maven-plugin/909857a873fe927f4332d585f9db14265851b99d/src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/79/4b0e3da190e2acb55f414ff28ba04485af3659 -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/81/d25d673c300ee5e802130f1f92fff58d5e1576: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/buildnumber-maven-plugin/909857a873fe927f4332d585f9db14265851b99d/src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/81/d25d673c300ee5e802130f1f92fff58d5e1576 -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/a0/5cc0d64f5cebad8a332c957dbd6d98024e8e62: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/buildnumber-maven-plugin/909857a873fe927f4332d585f9db14265851b99d/src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/a0/5cc0d64f5cebad8a332c957dbd6d98024e8e62 -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/b4/6131b51b0e59b4fcdf88ee76060aa0d099b36e: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/buildnumber-maven-plugin/909857a873fe927f4332d585f9db14265851b99d/src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/b4/6131b51b0e59b4fcdf88ee76060aa0d099b36e -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/c5/ff2ebf8dc0ff4568b1d63905c83fa11942e55e: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/buildnumber-maven-plugin/909857a873fe927f4332d585f9db14265851b99d/src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/c5/ff2ebf8dc0ff4568b1d63905c83fa11942e55e -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/e9/2ca4d934e31f2f3b4f7392361b32b46dec7863: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/buildnumber-maven-plugin/909857a873fe927f4332d585f9db14265851b99d/src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/e9/2ca4d934e31f2f3b4f7392361b32b46dec7863 -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/ee/58acb27b6636a497c1185f80cd15f76134113f: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/buildnumber-maven-plugin/909857a873fe927f4332d585f9db14265851b99d/src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/objects/ee/58acb27b6636a497c1185f80cd15f76134113f -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/dotGitDir/refs/heads/master: -------------------------------------------------------------------------------- 1 | ee58acb27b6636a497c1185f80cd15f76134113f 2 | -------------------------------------------------------------------------------- /src/test/projects/git-basic-it-MBUILDNUM-66/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-basic-it 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:git:git://fake/path 12 | 13 | 14 | 15 | 16 | package 17 | 18 | 19 | 20 | org.codehaus.mojo 21 | buildnumber-maven-plugin 22 | ${it-plugin.version} 23 | 24 | 25 | 26 | create 27 | 28 | 29 | true 30 | 31 | 32 | 33 | 34 | timestampFormat 35 | 36 | create 37 | 38 | 39 | yyyy-MM-dd 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.apache.maven.plugins 47 | maven-jar-plugin 48 | 2.5 49 | 50 | 51 | 52 | true 53 | true 54 | true 55 | 56 | 57 | ${buildNumber} 58 | ${timestamp} 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /src/test/projects/help-it/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-help-it 8 | 1.0-SNAPSHOT 9 | 10 | 11 | 12 | package 13 | 14 | 15 | 16 | org.codehaus.mojo 17 | buildnumber-maven-plugin 18 | ${it-plugin.version} 19 | 20 | 21 | validate 22 | 23 | help 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/test/projects/legacy-timestamp-it/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-legacy-timestamp-it 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:git:https://github.com/mojohaus/buildnumber-maven-plugin/test/bogus.git 12 | 13 | 14 | 15 | 16 | package 17 | 18 | 19 | 20 | org.codehaus.mojo 21 | buildnumber-maven-plugin 22 | ${it-plugin.version} 23 | 24 | 25 | legacyTimestampFormat 26 | 27 | create 28 | 29 | 30 | true 31 | {0,date,yyyy-MM-dd} 32 | 33 | 34 | 35 | 36 | 37 | 38 | org.apache.maven.plugins 39 | maven-jar-plugin 40 | 2.5 41 | 42 | 43 | 44 | true 45 | true 46 | true 47 | 48 | 49 | ${timestamp} 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/test/projects/norevision-it/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-norevision-it 8 | 1.0-SNAPSHOT 9 | 10 | 11 | scm:svn:http://svn.codehaus.org/mojo/trunk/mojo/buildnumber-maven-plugin/src/it/novivision-it 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | org.codehaus.mojo 20 | buildnumber-maven-plugin 21 | ${it-plugin.version} 22 | 23 | 24 | scm-failure 25 | prepare-package 26 | 27 | create 28 | 29 | 30 | ${project.build.directory} //this directory is not a svn local directory 31 | NOREVISION 32 | 33 | 34 | 35 | no-scm-failure 36 | prepare-package 37 | 38 | create 39 | 40 | 41 | true 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/test/projects/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 11 | 12 | 13 | it-repo 14 | 15 | true 16 | 17 | 18 | 19 | local.central 20 | @localRepositoryUrl@ 21 | 22 | true 23 | 24 | 25 | true 26 | 27 | 28 | 29 | 30 | 31 | local.central 32 | @localRepositoryUrl@ 33 | 34 | true 35 | 36 | 37 | true 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/test/projects/skip-it/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.it 7 | buildnumber-maven-plugin-skip-it 8 | 1.0-SNAPSHOT 9 | 10 | 11 | 12 | package 13 | 14 | 15 | 16 | org.codehaus.mojo 17 | buildnumber-maven-plugin 18 | ${it-plugin.version} 19 | 20 | 21 | useLastCommittedRevision 22 | 23 | create-timestamp 24 | 25 | 26 | true 27 | datetime 28 | yyyy-MM-dd hh:mm:ss 29 | 30 | 31 | 32 | 33 | 34 | 35 | org.apache.maven.plugins 36 | maven-jar-plugin 37 | 2.5 38 | 39 | 40 | 41 | true 42 | true 43 | true 44 | 45 | 46 | ${datetime} 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/test/resources/svnOutput-1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | http://apollo.ucalgary.ca:8800/gdir/trunk 5 | 6 | http://apollo.ucalgary.ca:8800/gdir 7 | 480ea15e-1a36-0410-90fc-99b9ce627977 8 | 9 | 10 | normal 11 | 12 | 13 | woodj 14 | 2007-09-06T19:18:06.472781Z 15 | 16 | 17 | 18 | --------------------------------------------------------------------------------
Yes, set the plugin parameter
to prevent 27 | the plugin from throwing an exception if SCM information is not found.
The other option is to use -Dmaven.buildNumber.ignoreEmptyScmUrl=true -Dmaven.buildNumber.scmProvider=git/svn/ 29 | Default is git