1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.maven.plugin.eclipse.writers.rad; |
20 | |
|
21 | |
import java.io.File; |
22 | |
import java.io.FileOutputStream; |
23 | |
import java.io.IOException; |
24 | |
import java.io.OutputStreamWriter; |
25 | |
import java.io.Writer; |
26 | |
|
27 | |
import org.apache.maven.artifact.repository.ArtifactRepository; |
28 | |
import org.apache.maven.plugin.MojoExecutionException; |
29 | |
import org.apache.maven.plugin.eclipse.Constants; |
30 | |
import org.apache.maven.plugin.eclipse.EclipseSourceDir; |
31 | |
import org.apache.maven.plugin.eclipse.Messages; |
32 | |
import org.apache.maven.plugin.eclipse.writers.AbstractEclipseWriter; |
33 | |
import org.apache.maven.plugin.eclipse.writers.wtp.AbstractWtpResourceWriter; |
34 | |
import org.codehaus.plexus.util.IOUtil; |
35 | |
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter; |
36 | |
import org.codehaus.plexus.util.xml.XMLWriter; |
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | 0 | public class RadWebsiteConfigWriter |
44 | |
extends AbstractEclipseWriter |
45 | |
{ |
46 | |
|
47 | |
private static final String WEBSITE_CONFIG_FILENAME = ".website-config"; |
48 | |
|
49 | |
private static final String WEBSITE_CONFIG_STRUCTURE = "structure"; |
50 | |
|
51 | |
private static final String WEBSITE_CONFIG_VERSION = "version"; |
52 | |
|
53 | |
private static final String WEBSITE_CONFIG_WEBSITE = "website"; |
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
public void write() |
65 | |
throws MojoExecutionException |
66 | |
{ |
67 | |
Writer w; |
68 | 0 | if ( Constants.PROJECT_PACKAGING_WAR.equalsIgnoreCase( config.getPackaging() ) ) |
69 | |
{ |
70 | |
try |
71 | |
{ |
72 | 0 | w = |
73 | |
new OutputStreamWriter( new FileOutputStream( new File( config.getEclipseProjectDirectory(), |
74 | |
WEBSITE_CONFIG_FILENAME ) ), "UTF-8" ); |
75 | |
} |
76 | 0 | catch ( IOException ex ) |
77 | |
{ |
78 | 0 | throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); |
79 | 0 | } |
80 | 0 | XMLWriter writer = new PrettyPrintXMLWriter( w, "UTF-8", null ); |
81 | 0 | writeModuleTypeFacetCore( writer ); |
82 | 0 | IOUtil.close( w ); |
83 | |
} |
84 | 0 | } |
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
private void writeModuleTypeFacetCore( XMLWriter writer ) |
92 | |
{ |
93 | 0 | writer.startElement( WEBSITE_CONFIG_WEBSITE ); |
94 | 0 | writer.addAttribute( WEBSITE_CONFIG_VERSION, "600" ); |
95 | 0 | writer.startElement( WEBSITE_CONFIG_STRUCTURE ); |
96 | 0 | writer.endElement(); |
97 | 0 | writer.endElement(); |
98 | 0 | } |
99 | |
} |