| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| CheckinMojo |
|
| 6.0;6 |
| 1 | package org.apache.maven.scm.plugin; | |
| 2 | ||
| 3 | /* | |
| 4 | * Licensed to the Apache Software Foundation (ASF) under one | |
| 5 | * or more contributor license agreements. See the NOTICE file | |
| 6 | * distributed with this work for additional information | |
| 7 | * regarding copyright ownership. The ASF licenses this file | |
| 8 | * to you under the Apache License, Version 2.0 (the | |
| 9 | * "License"); you may not use this file except in compliance | |
| 10 | * with the License. You may obtain a copy of the License at | |
| 11 | * | |
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 13 | * | |
| 14 | * Unless required by applicable law or agreed to in writing, | |
| 15 | * software distributed under the License is distributed on an | |
| 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
| 17 | * KIND, either express or implied. See the License for the | |
| 18 | * specific language governing permissions and limitations | |
| 19 | * under the License. | |
| 20 | */ | |
| 21 | ||
| 22 | import org.apache.maven.plugin.MojoExecutionException; | |
| 23 | import org.apache.maven.scm.ScmException; | |
| 24 | import org.apache.maven.scm.ScmFile; | |
| 25 | import org.apache.maven.scm.command.checkin.CheckInScmResult; | |
| 26 | import org.apache.maven.scm.repository.ScmRepository; | |
| 27 | ||
| 28 | import java.io.IOException; | |
| 29 | ||
| 30 | /** | |
| 31 | * Commit changes to the configured scm url. | |
| 32 | * | |
| 33 | * @author <a href="evenisse@apache.org">Emmanuel Venisse</a> | |
| 34 | * @version $Id: CheckinMojo.java 685670 2008-08-13 20:25:56Z vsiveton $ | |
| 35 | * @goal checkin | |
| 36 | * @aggregator | |
| 37 | */ | |
| 38 | 0 | public class CheckinMojo extends AbstractScmMojo { |
| 39 | /** | |
| 40 | * Commit log. | |
| 41 | * | |
| 42 | * @parameter expression="${message}" | |
| 43 | */ | |
| 44 | private String message; | |
| 45 | ||
| 46 | /** | |
| 47 | * The configured scm url to use. | |
| 48 | * | |
| 49 | * @parameter expression="${connectionType}" default-value="developerConnection" | |
| 50 | */ | |
| 51 | private String connectionType; | |
| 52 | ||
| 53 | /** | |
| 54 | * The version type (branch/tag/revision) of scmVersion. | |
| 55 | * | |
| 56 | * @parameter expression="${scmVersionType}" | |
| 57 | */ | |
| 58 | private String scmVersionType; | |
| 59 | ||
| 60 | /** | |
| 61 | * The version (revision number/branch name/tag name). | |
| 62 | * | |
| 63 | * @parameter expression="${scmVersion}" | |
| 64 | */ | |
| 65 | private String scmVersion; | |
| 66 | ||
| 67 | /** {@inheritDoc} */ | |
| 68 | public void execute() throws MojoExecutionException { | |
| 69 | 0 | super.execute(); |
| 70 | ||
| 71 | 0 | setConnectionType(connectionType); |
| 72 | ||
| 73 | try { | |
| 74 | 0 | ScmRepository repository = getScmRepository(); |
| 75 | ||
| 76 | 0 | CheckInScmResult result = getScmManager().checkIn(repository, getFileSet(), |
| 77 | getScmVersion(scmVersionType, scmVersion), message); | |
| 78 | ||
| 79 | 0 | checkResult(result); |
| 80 | ||
| 81 | 0 | for (ScmFile checkedInFile : result.getCheckedInFiles()) { |
| 82 | 0 | getLog().info("Checked in " + checkedInFile.getPath()); |
| 83 | } | |
| 84 | 0 | } catch (IOException e) { |
| 85 | 0 | throw new MojoExecutionException("Cannot run checkin command : ", e); |
| 86 | 0 | } catch (ScmException e) { |
| 87 | 0 | throw new MojoExecutionException("Cannot run checkin command : ", e); |
| 88 | 0 | } |
| 89 | 0 | } |
| 90 | } |