001package org.andromda.maven.plugin.andromdapp.eclipse; 002 003import java.io.File; 004import java.io.FileWriter; 005import org.apache.maven.plugin.logging.Log; 006import org.apache.maven.project.MavenProject; 007import org.codehaus.plexus.util.IOUtil; 008import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter; 009import org.codehaus.plexus.util.xml.XMLWriter; 010 011/** 012 * Writes .project files for Eclipse. 013 * 014 * @author Chad Brandon 015 */ 016public class ProjectWriter 017 extends EclipseWriter 018{ 019 /** 020 * @param project 021 * @param logger 022 */ 023 public ProjectWriter( 024 final MavenProject project, 025 final Log logger) 026 { 027 super(project, logger); 028 } 029 030 /** 031 * Writes the .classpath file for Eclipse. 032 * @throws Exception 033 */ 034 public void write() 035 throws Exception 036 { 037 final File projectFile = this.getFile(".project"); 038 final FileWriter fileWriter = new FileWriter(projectFile); 039 final XMLWriter writer = new PrettyPrintXMLWriter(fileWriter); 040 writer.startElement("projectDescription"); 041 writer.startElement("name"); 042 writer.writeText(this.project.getArtifactId()); 043 writer.endElement(); 044 writer.startElement("comment"); 045 writer.endElement(); 046 writer.startElement("projects"); 047 writer.endElement(); 048 writer.startElement("buildSpec"); 049 writer.startElement("buildCommand"); 050 writer.startElement("name"); 051 writer.writeText("org.eclipse.jdt.core.javabuilder"); 052 writer.endElement(); 053 writer.startElement("arguments"); 054 writer.endElement(); 055 writer.endElement(); 056 writer.endElement(); 057 writer.startElement("natures"); 058 writer.startElement("nature"); 059 writer.writeText("org.eclipse.jdt.core.javanature"); 060 writer.endElement(); 061 writer.endElement(); 062 writer.endElement(); 063 IOUtil.close(fileWriter); 064 this.logger.info("Project file written --> '" + projectFile + '\''); 065 } 066}