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.checkin.CheckInScmResult;
|
|
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 |
* Check in a specific set of files to the repository.
|
|
29 |
*
|
|
30 |
* <pre>
|
|
31 |
* <hlm:scm verbose="true" scmUrl="scm:${repo.type}:${repo.dir}/test1">
|
|
32 |
* <hlm:checkin message="Adding not_in_repo.txt...">
|
|
33 |
* <fileset dir="${repo.dir}/test1">
|
|
34 |
* <include name="not_in_repo.txt" />
|
|
35 |
* <exclude name="** /.${repo.type}/**" / >
|
|
36 |
* </fileset >
|
|
37 |
* </hlm:checkin >
|
|
38 |
* </hlm:scm>
|
|
39 |
* </pre>
|
|
40 |
*
|
|
41 |
* @ant.type name="checkin" category="SCM"
|
|
42 |
*/
|
|
43 |
public class CheckinAction extends BaseDirectoryScmAction {
|
|
44 |
private String message;
|
|
45 |
|
|
46 |
public String getMessage() {
|
|
47 |
return message;
|
|
48 |
}
|
|
49 |
|
|
50 |
/**
|
|
51 |
* @param message
|
|
52 |
* the message associated to the commit.
|
|
53 |
* @ant.required
|
|
54 |
*/
|
|
55 |
public void setMessage(String message) {
|
|
56 |
this.message = message;
|
|
57 |
}
|
|
58 |
|
|
59 |
@Override
|
|
60 |
public void execute(ScmRepository repository) throws ScmException {
|
|
61 |
ScmManager scmManager = getTask().getScmManager();
|
|
62 |
|
628
|
63 |
if (message == null) {
|
588
|
64 |
throw new BuildException(
|
|
65 |
"'message attribute has not been defined.'");
|
628
|
66 |
}
|
588
|
67 |
|
|
68 |
CheckInScmResult result;
|
|
69 |
try {
|
|
70 |
result = scmManager.checkIn(repository, getScmFileSet(), message);
|
|
71 |
} catch (ScmException e) {
|
|
72 |
throw new BuildException("SCM checkin action failed.");
|
|
73 |
}
|
|
74 |
|
|
75 |
if (!result.isSuccess()) {
|
|
76 |
throw new BuildException("SCM checkin action failed.");
|
|
77 |
}
|
|
78 |
}
|
|
79 |
}
|