Coverage Report - org.apache.maven.plugin.eclipse.ConfigureWorkspaceMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
ConfigureWorkspaceMojo
0%
0/12
0%
0/2
4
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
 3  
  * agreements. See the NOTICE file distributed with this work for additional information regarding
 4  
  * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
 5  
  * "License"); you may not use this file except in compliance with the License. You may obtain a
 6  
  * copy of the License at
 7  
  * 
 8  
  * http://www.apache.org/licenses/LICENSE-2.0
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software distributed under the License
 11  
  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing permissions and limitations under
 13  
  * the License.
 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  
 
 24  
 /**
 25  
  * Configures The following Eclipse Workspace features:
 26  
  * <ul>
 27  
  * <li>Adds the classpath variable MAVEN_REPO to Eclipse.</li>
 28  
  * <li>Optionally load Eclipse code style file via a URL.</li>
 29  
  * </ul>
 30  
  * 
 31  
  * @goal configure-workspace
 32  
  * @requiresProject false
 33  
  */
 34  0
 public class ConfigureWorkspaceMojo
 35  
     extends AbstractWorkspaceMojo
 36  
 {
 37  
     /**
 38  
      * Point to a URL containing code styles content.
 39  
      * 
 40  
      * @parameter expression="${eclipse.workspaceCodeStylesURL}"
 41  
      */
 42  
     private String workspaceCodeStylesURL;
 43  
 
 44  
     /**
 45  
      * Name of a profile in <code>workspaceCodeStylesURL</code> to activate. Default is the first profile name in the
 46  
      * code style file in <code>workspaceCodeStylesURL</code>
 47  
      * 
 48  
      * @parameter expression="${eclipse.workspaceActiveCodeStyleProfileName}"
 49  
      */
 50  
     private String workspaceActiveCodeStyleProfileName;
 51  
 
 52  
     public void execute()
 53  
         throws MojoExecutionException
 54  
     {
 55  0
         WorkspaceConfiguration config = new WorkspaceConfiguration();
 56  0
         config.setWorkspaceDirectory( new File( this.getWorkspace() ) );
 57  0
         config.setLocalRepository( this.getLocalRepository() );
 58  
 
 59  0
         if ( this.workspaceCodeStylesURL != null )
 60  
         {
 61  
             try
 62  
             {
 63  0
                 config.setCodeStylesURL( new URL( workspaceCodeStylesURL ) );
 64  
             }
 65  0
             catch ( MalformedURLException e )
 66  
             {
 67  0
                 throw new MojoExecutionException( e.getMessage(), e );
 68  0
             }
 69  
 
 70  0
             config.setActiveStyleProfileName( workspaceActiveCodeStyleProfileName );
 71  
 
 72  
         }
 73  
 
 74  0
         new EclipseWorkspaceWriter().init( this.getLog(), config ).write();
 75  0
     }
 76  
 
 77  
 }