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 package org.apache.maven.plugins.release; 20 21 import javax.inject.Inject; 22 23 import org.apache.maven.plugins.annotations.Mojo; 24 import org.apache.maven.plugins.annotations.Parameter; 25 import org.apache.maven.scm.manager.ScmManager; 26 import org.apache.maven.shared.release.ReleaseManager; 27 28 /** 29 * Perform a release from SCM to a staging repository. 30 * 31 * If no goals are given, these default to <code>deploy</code> or <code>deploy site:stage-deploy</code>, 32 * if the project has a <distributionManagement>/<site> element. 33 * 34 * If the goals contain <code>site-deploy</code> or <code>site:deploy</code>, these 35 * are overridden with <code>site:stage-deploy</code>. 36 * 37 * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a> 38 * @since 2.0-beta-8 39 */ 40 @Mojo(name = "stage", aggregator = true, requiresProject = false) 41 public class StageReleaseMojo extends PerformReleaseMojo { 42 /** 43 * URL of the staging repository to use. 44 * 45 * @since 2.0-beta-8 46 */ 47 @Parameter(property = "stagingRepository", required = true) 48 private String stagingRepository; 49 50 @Inject 51 public StageReleaseMojo(ReleaseManager releaseManager, ScmManager scmManager) { 52 super(releaseManager, scmManager); 53 } 54 55 @Override 56 void createGoals() { 57 if (goals == null) { 58 // set default 59 goals = "deploy"; 60 if (project.getDistributionManagement() != null 61 && project.getDistributionManagement().getSite() != null) { 62 goals += " site:stage-deploy"; 63 } 64 } 65 66 goals = goals.replace("site-deploy", "site:stage-deploy"); 67 goals = goals.replace("site:deploy", "site:stage-deploy"); 68 } 69 70 @Override 71 void setDeploymentRepository() { 72 addArgument("-DaltDeploymentRepository=\"" + stagingRepository + "\""); 73 } 74 }