001 package org.apache.maven.scm.provider.synergy.command.tag; 002 003 /* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022 import java.io.File; 023 import java.util.ArrayList; 024 import java.util.List; 025 026 import org.apache.maven.scm.ScmException; 027 import org.apache.maven.scm.ScmFile; 028 import org.apache.maven.scm.ScmFileSet; 029 import org.apache.maven.scm.ScmFileStatus; 030 import org.apache.maven.scm.ScmResult; 031 import org.apache.maven.scm.ScmTagParameters; 032 import org.apache.maven.scm.command.tag.AbstractTagCommand; 033 import org.apache.maven.scm.command.tag.TagScmResult; 034 import org.apache.maven.scm.provider.ScmProviderRepository; 035 import org.apache.maven.scm.provider.synergy.command.SynergyCommand; 036 import org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository; 037 import org.apache.maven.scm.provider.synergy.util.SynergyRole; 038 import org.apache.maven.scm.provider.synergy.util.SynergyUtil; 039 040 /** 041 * @author <a href="mailto:julien.henry@capgemini.com">Julien Henry</a> 042 * @author Olivier Lamy 043 * @version $Id: SynergyTagCommand.java 1333668 2012-05-03 22:37:08Z hboutemy $ 044 */ 045 public class SynergyTagCommand 046 extends AbstractTagCommand 047 implements SynergyCommand 048 { 049 050 protected ScmResult executeTagCommand( ScmProviderRepository repository, ScmFileSet fileSet, String tag, 051 String message ) 052 throws ScmException 053 { 054 return executeTagCommand( repository, fileSet, tag, new ScmTagParameters( message ) ); 055 } 056 057 /** {@inheritDoc} */ 058 protected ScmResult executeTagCommand( ScmProviderRepository repository, ScmFileSet fileSet, String tag, 059 ScmTagParameters scmTagParameters ) 060 throws ScmException 061 { 062 if ( getLogger().isDebugEnabled() ) 063 { 064 getLogger().debug( "executing tag command..." ); 065 } 066 067 SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository; 068 069 if ( getLogger().isDebugEnabled() ) 070 { 071 getLogger().debug( "basedir: " + fileSet.getBasedir() ); 072 } 073 074 String ccmAddr = SynergyUtil.start( getLogger(), repo.getUser(), repo.getPassword(), SynergyRole.BUILD_MGR ); 075 076 try 077 { 078 // Make sure, that all changes made until now are reflected in the prep project 079 // this is especially true for all changes made by maven (ie versions in the poms). 080 SynergyUtil.reconfigureProperties( getLogger(), repo.getProjectSpec(), ccmAddr ); 081 SynergyUtil.reconfigure( getLogger(), repo.getProjectSpec(), ccmAddr); 082 083 SynergyUtil.createBaseline( getLogger(), repo.getProjectSpec(), tag, repo.getProjectRelease(), 084 repo.getProjectPurpose(), ccmAddr ); 085 } 086 finally 087 { 088 SynergyUtil.stop( getLogger(), ccmAddr ); 089 } 090 List<ScmFile> files = new ArrayList<ScmFile>( fileSet.getFileList().size() ); 091 for ( File f : fileSet.getFileList() ) 092 { 093 files.add( new ScmFile( f.getPath(), ScmFileStatus.TAGGED ) ); 094 } 095 return new TagScmResult( "", files ); 096 } 097 098 }