1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.apache.maven.plugin.eclipse;
16
17 import java.io.File;
18 import java.net.MalformedURLException;
19 import java.net.URL;
20
21 import org.apache.maven.plugin.MojoExecutionException;
22 import org.apache.maven.plugin.eclipse.writers.workspace.EclipseWorkspaceWriter;
23 import org.apache.maven.plugins.annotations.Mojo;
24 import org.apache.maven.plugins.annotations.Parameter;
25
26
27
28
29
30
31
32
33 @Mojo( name = "configure-workspace", requiresProject = false )
34 public class ConfigureWorkspaceMojo
35 extends AbstractWorkspaceMojo
36 {
37
38
39
40 @Parameter( property = "eclipse.workspaceCodeStylesURL" )
41 private String workspaceCodeStylesURL;
42
43
44
45
46
47 @Parameter( property = "eclipse.workspaceActiveCodeStyleProfileName" )
48 private String workspaceActiveCodeStyleProfileName;
49
50 public void execute()
51 throws MojoExecutionException
52 {
53 WorkspaceConfiguration config = new WorkspaceConfiguration();
54 config.setWorkspaceDirectory( new File( this.getWorkspace() ) );
55 config.setLocalRepository( this.getLocalRepository() );
56
57 if ( this.workspaceCodeStylesURL != null )
58 {
59 try
60 {
61 config.setCodeStylesURL( new URL( workspaceCodeStylesURL ) );
62 }
63 catch ( MalformedURLException e )
64 {
65 throw new MojoExecutionException( e.getMessage(), e );
66 }
67
68 config.setActiveStyleProfileName( workspaceActiveCodeStyleProfileName );
69
70 }
71
72 new EclipseWorkspaceWriter().init( this.getLog(), config ).write();
73 }
74
75 }