1 package org.apache.maven.plugins.scm;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import java.io.File;
22
23 import org.apache.maven.scm.ScmFileSet;
24 import org.apache.maven.scm.command.diff.DiffScmResult;
25 import org.apache.maven.scm.manager.ScmManager;
26 import org.apache.maven.scm.repository.ScmRepository;
27 import org.codehaus.plexus.util.FileUtils;
28
29 /**
30 * A bean for using the Maven SCM API because wrangling objects in Jelly is no fun.
31 *
32 * @author <a href="mailto:brett@apache.org">Brett Porter</a>
33 */
34 public class ScmDiffBean
35 extends ScmPatternBean
36 {
37 private String patchFile;
38
39 private String startRevision;
40
41 private String endRevision;
42
43 public void diff()
44 throws Exception
45 {
46 ScmManager scmManager = lookupScmManager();
47
48 ScmRepository repository = getScmRepository( scmManager );
49
50 ScmFileSet fileSet = new ScmFileSet( new File( getWorkingDirectory() ), getIncludes(), getExcludes() );
51 DiffScmResult result = scmManager.getProviderByRepository( repository ).diff( repository, fileSet,
52 startRevision, endRevision );
53 checkResult( result );
54
55 FileUtils.fileWrite( patchFile, result.getPatch() );
56 }
57
58 public void setPatchFile( String patchFile )
59 {
60 this.patchFile = patchFile;
61 }
62
63 public String getPatchFile()
64 {
65 return patchFile;
66 }
67
68 public String getStartRevision()
69 {
70 return startRevision;
71 }
72
73 public void setStartRevision( String startRevision )
74 {
75 this.startRevision = startRevision;
76 }
77
78 public String getEndRevision()
79 {
80 return endRevision;
81 }
82
83 public void setEndRevision( String endRevision )
84 {
85 this.endRevision = endRevision;
86 }
87 }