1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package nl.toolforge.karma.core.cmd.impl;
20
21 import nl.toolforge.karma.core.cmd.CommandDescriptor;
22 import nl.toolforge.karma.core.cmd.CommandException;
23 import nl.toolforge.karma.core.cmd.CommandResponse;
24 import nl.toolforge.karma.core.cmd.event.MessageEvent;
25 import nl.toolforge.karma.core.cmd.event.SimpleMessage;
26 import org.apache.commons.io.FileUtils;
27
28 import java.io.IOException;
29
30 /***
31 * Removes the modules' build directory.
32 *
33 * @author W.H. Schraal
34 * @author D.A. Smedes
35 *
36 * @version $Id: CleanModule.java,v 1.9 2004/10/09 21:24:25 asmedes Exp $
37 */
38 public class CleanModule extends AbstractBuildCommand {
39
40 private CommandResponse commandResponse = new CommandResponse();
41
42 public CleanModule(CommandDescriptor descriptor) {
43 super(descriptor);
44 }
45
46 public void execute() throws CommandException {
47
48 super.execute();
49
50 try {
51
52 FileUtils.deleteDirectory(getBuildEnvironment().getModuleBuildRootDirectory());
53
54 SimpleMessage message = new SimpleMessage(getFrontendMessages().getString("message.CLEAN_MODULE_SUCCESSFULL"), new Object[]{getCurrentModule()});
55 commandResponse.addEvent(new MessageEvent(this, message));
56
57 } catch (IOException e) {
58 throw new CommandException(CommandException.CLEAN_MODULE_FAILED, new Object[]{e.getLocalizedMessage()});
59 }
60 }
61
62 public CommandResponse getCommandResponse() {
63 return this.commandResponse;
64 }
65 }