View Javadoc
1   package org.apache.maven.scm.provider.synergy.command.tag;
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 java.io.File;
23  import java.util.ArrayList;
24  import java.util.List;
25  
26  import org.apache.maven.scm.ScmException;
27  import org.apache.maven.scm.ScmFile;
28  import org.apache.maven.scm.ScmFileSet;
29  import org.apache.maven.scm.ScmFileStatus;
30  import org.apache.maven.scm.ScmResult;
31  import org.apache.maven.scm.ScmTagParameters;
32  import org.apache.maven.scm.command.tag.AbstractTagCommand;
33  import org.apache.maven.scm.command.tag.TagScmResult;
34  import org.apache.maven.scm.provider.ScmProviderRepository;
35  import org.apache.maven.scm.provider.synergy.command.SynergyCommand;
36  import org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository;
37  import org.apache.maven.scm.provider.synergy.util.SynergyRole;
38  import org.apache.maven.scm.provider.synergy.util.SynergyUtil;
39  
40  /**
41   * @author <a href="mailto:julien.henry@capgemini.com">Julien Henry</a>
42   * @author Olivier Lamy
43   *
44   */
45  public class SynergyTagCommand
46      extends AbstractTagCommand
47      implements SynergyCommand
48  {
49      
50      protected ScmResult executeTagCommand( ScmProviderRepository repository, ScmFileSet fileSet, String tag,
51                                             String message )
52          throws ScmException
53      {
54          return executeTagCommand( repository, fileSet, tag, new ScmTagParameters( message ) );
55      }
56  
57      /** {@inheritDoc} */
58      protected ScmResult executeTagCommand( ScmProviderRepository repository, ScmFileSet fileSet, String tag,
59                                             ScmTagParameters scmTagParameters )
60          throws ScmException
61      {
62          if ( getLogger().isDebugEnabled() )
63          {
64              getLogger().debug( "executing tag command..." );
65          }
66  
67          SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
68  
69          if ( getLogger().isDebugEnabled() )
70          {
71              getLogger().debug( "basedir: " + fileSet.getBasedir() );
72          }
73  
74          String ccmAddr = SynergyUtil.start( getLogger(), repo.getUser(), repo.getPassword(), SynergyRole.BUILD_MGR );
75  
76          try
77          {
78          	// Make sure, that all changes made until now are reflected in the prep project
79          	// this is especially true for all changes made by maven (ie versions in the poms).
80          	SynergyUtil.reconfigureProperties( getLogger(), repo.getProjectSpec(), ccmAddr );
81          	SynergyUtil.reconfigure( getLogger(), repo.getProjectSpec(), ccmAddr);
82          	
83              SynergyUtil.createBaseline( getLogger(), repo.getProjectSpec(), tag, repo.getProjectRelease(),
84                                          repo.getProjectPurpose(), ccmAddr );
85          }
86          finally
87          {
88              SynergyUtil.stop( getLogger(), ccmAddr );
89          }
90          List<ScmFile> files = new ArrayList<ScmFile>( fileSet.getFileList().size() );
91          for ( File f : fileSet.getFileList() )
92          {
93              files.add( new ScmFile( f.getPath(), ScmFileStatus.TAGGED ) );
94          }
95          return new TagScmResult( "", files );
96      }
97  
98  }