001package 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 022import java.io.File; 023import java.util.ArrayList; 024import java.util.List; 025 026import org.apache.maven.scm.ScmException; 027import org.apache.maven.scm.ScmFile; 028import org.apache.maven.scm.ScmFileSet; 029import org.apache.maven.scm.ScmFileStatus; 030import org.apache.maven.scm.ScmResult; 031import org.apache.maven.scm.ScmTagParameters; 032import org.apache.maven.scm.command.tag.AbstractTagCommand; 033import org.apache.maven.scm.command.tag.TagScmResult; 034import org.apache.maven.scm.provider.ScmProviderRepository; 035import org.apache.maven.scm.provider.synergy.command.SynergyCommand; 036import org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository; 037import org.apache.maven.scm.provider.synergy.util.SynergyRole; 038import 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 * 044 */ 045public 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}