588
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
package com.nokia.helium.scm.ant.actions;
|
|
19 |
|
|
20 |
import org.apache.maven.scm.ScmException;
|
|
21 |
import org.apache.maven.scm.command.remove.RemoveScmResult;
|
|
22 |
import org.apache.maven.scm.manager.ScmManager;
|
|
23 |
import org.apache.maven.scm.repository.ScmRepository;
|
|
24 |
import org.apache.tools.ant.BuildException;
|
|
25 |
|
|
26 |
|
|
27 |
/**
|
|
28 |
* Remove a set of file(s) from SCM control.
|
|
29 |
*
|
|
30 |
* <pre>
|
|
31 |
* <hlm:scm verbose="true" scmUrl="scm:${repo.type}:${repo.dir}/test1">
|
|
32 |
* <hlm:remove message="Nothing to remove...">
|
|
33 |
* <fileset dir="${repo.dir}/test1">
|
|
34 |
* <include name="not_in_repo.txt" />
|
|
35 |
* </fileset>
|
|
36 |
* </hlm:remove>
|
|
37 |
* </hlm:scm>
|
|
38 |
* </pre>
|
|
39 |
*
|
|
40 |
* @ant.type name="remove" category="SCM"
|
|
41 |
*/
|
|
42 |
public class RemoveAction extends BaseDirectoryScmAction {
|
|
43 |
private String message;
|
|
44 |
|
|
45 |
public String getMessage() {
|
|
46 |
return message;
|
|
47 |
}
|
|
48 |
|
|
49 |
/**
|
|
50 |
* @param message
|
|
51 |
* the message associated to the change
|
|
52 |
* @ant.required
|
|
53 |
*/
|
|
54 |
public void setMessage(String message) {
|
|
55 |
this.message = message;
|
|
56 |
}
|
|
57 |
|
|
58 |
@Override
|
|
59 |
public void execute(ScmRepository repository) throws ScmException {
|
628
|
60 |
if (message == null) {
|
588
|
61 |
throw new BuildException("message attribute has not been defined.");
|
628
|
62 |
}
|
588
|
63 |
// if (getBasedir() == null)
|
|
64 |
// throw new BuildException("basedir attribute has not been defined.");
|
|
65 |
|
|
66 |
ScmManager scmManager = getTask().getScmManager();
|
|
67 |
RemoveScmResult result;
|
|
68 |
try {
|
|
69 |
result = scmManager.remove(repository, getScmFileSet(), message);
|
|
70 |
} catch (ScmException e) {
|
|
71 |
throw new BuildException("SCM remove action failed: " + e);
|
|
72 |
}
|
|
73 |
|
|
74 |
if (!result.isSuccess()) {
|
|
75 |
throw new BuildException("SCM remove action failed.");
|
|
76 |
}
|
|
77 |
}
|
|
78 |
}
|