| 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.manifest.ManifestException; |
| 25 |
|
import org.apache.tools.ant.BuildException; |
| 26 |
|
import org.apache.tools.ant.Project; |
| 27 |
|
|
| 28 |
|
import java.io.File; |
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
public class DocModule extends AbstractBuildCommand { |
| 38 |
|
|
| 39 |
|
private static final String JAVADOC_OUTPUT_DIR = "module.javadoc.outputdir"; |
| 40 |
|
private static final String MODULE_NAME = "module.name"; |
| 41 |
|
private static final String MODULE_STATE = "module.state"; |
| 42 |
|
private static final String MODULE_SRC = "module.src"; |
| 43 |
|
|
| 44 |
0 |
protected CommandResponse response = new CommandResponse(); |
| 45 |
|
|
| 46 |
|
public DocModule(CommandDescriptor descriptor) { |
| 47 |
0 |
super(descriptor); |
| 48 |
0 |
} |
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
public void execute() throws CommandException { |
| 55 |
|
|
| 56 |
0 |
super.execute(); |
| 57 |
|
|
| 58 |
0 |
File srcDir = getBuildEnvironment().getModuleSourceDirectory(); |
| 59 |
|
|
| 60 |
0 |
if (!srcDir.exists()) { |
| 61 |
0 |
throw new CommandException(CommandException.NO_SRC_DIR, class="keyword">new Object[]{module, "src/java"}); |
| 62 |
|
} |
| 63 |
|
|
| 64 |
0 |
Project project = getAntProject("doc-module.xml"); |
| 65 |
|
|
| 66 |
0 |
project.setProperty(JAVADOC_OUTPUT_DIR, getBuildEnvironment().getModuleJavadocDirectory().getPath()); |
| 67 |
0 |
project.setProperty(MODULE_NAME, module.getName()); |
| 68 |
0 |
project.setProperty(MODULE_STATE, getCurrentManifest().getState(module).toString()); |
| 69 |
0 |
project.setProperty(MODULE_SRC, srcDir.getPath()); |
| 70 |
|
|
| 71 |
|
try { |
| 72 |
0 |
project.executeTarget("run"); |
| 73 |
0 |
} catch (BuildException b) { |
| 74 |
0 |
throw new CommandException(b, CommandException.BUILD_FAILED, class="keyword">new Object[]{module}); |
| 75 |
0 |
} |
| 76 |
0 |
} |
| 77 |
|
|
| 78 |
|
public CommandResponse getCommandResponse() { |
| 79 |
0 |
return response; |
| 80 |
|
} |
| 81 |
|
|
| 82 |
|
protected File getSourceDirectory() throws ManifestException { |
| 83 |
0 |
return new File(getCurrentModule().getBaseDir(), "src/java"); |
| 84 |
|
} |
| 85 |
|
} |