01: package org.andromda.maven.plugin.andromdapp.eclipse;
02:
03: import java.io.File;
04: import java.io.FileWriter;
05:
06: import org.apache.maven.plugin.logging.Log;
07: import org.apache.maven.project.MavenProject;
08: import org.codehaus.plexus.util.IOUtil;
09: import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
10: import org.codehaus.plexus.util.xml.XMLWriter;
11:
12: /**
13: * Writes .project files for Eclipse.
14: *
15: * @author Chad Brandon
16: */
17: public class ProjectWriter extends EclipseWriter {
18: public ProjectWriter(final MavenProject project, final Log logger) {
19: super (project, logger);
20: }
21:
22: /**
23: * Writes the .classpath file for Eclipse.
24: */
25: public void write() throws Exception {
26: final File projectFile = this .getFile(".project");
27: final FileWriter fileWriter = new FileWriter(projectFile);
28: final XMLWriter writer = new PrettyPrintXMLWriter(fileWriter);
29: writer.startElement("projectDescription");
30: writer.startElement("name");
31: writer.writeText(this .project.getArtifactId());
32: writer.endElement();
33: writer.startElement("comment");
34: writer.endElement();
35: writer.startElement("projects");
36: writer.endElement();
37: writer.startElement("buildSpec");
38: writer.startElement("buildCommand");
39: writer.startElement("name");
40: writer.writeText("org.eclipse.jdt.core.javabuilder");
41: writer.endElement();
42: writer.startElement("arguments");
43: writer.endElement();
44: writer.endElement();
45: writer.endElement();
46: writer.startElement("natures");
47: writer.startElement("nature");
48: writer.writeText("org.eclipse.jdt.core.javanature");
49: writer.endElement();
50: writer.endElement();
51: writer.endElement();
52: IOUtil.close(fileWriter);
53: this .logger.info("Project file written --> '" + projectFile
54: + "'");
55: }
56: }
|