Coverage Report - org.apache.maven.plugins.enforcer.DisplayInfoMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
DisplayInfoMojo
0%
0/14
N/A
1.5
 
 1  
 package org.apache.maven.plugins.enforcer;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *  http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.apache.commons.lang.SystemUtils;
 23  
 import org.apache.maven.execution.MavenSession;
 24  
 import org.apache.maven.execution.RuntimeInformation;
 25  
 import org.apache.maven.plugin.AbstractMojo;
 26  
 import org.apache.maven.plugin.MojoExecutionException;
 27  
 import org.apache.maven.project.MavenProject;
 28  
 import org.apache.maven.project.path.PathTranslator;
 29  
 import org.codehaus.plexus.PlexusConstants;
 30  
 import org.codehaus.plexus.PlexusContainer;
 31  
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 32  
 import org.codehaus.plexus.context.Context;
 33  
 import org.codehaus.plexus.context.ContextException;
 34  
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
 35  
 
 36  
 /**
 37  
  * This goal displays the current platform information.
 38  
  *
 39  
  * @goal display-info
 40  
  * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
 41  
  * @version $Id: DisplayInfoMojo.java 1127643 2011-05-25 19:24:38Z krosenvold $
 42  
  * @threadSafe
 43  
  */
 44  0
 public class DisplayInfoMojo
 45  
     extends AbstractMojo
 46  
     implements Contextualizable
 47  
 {
 48  
 
 49  
     /**
 50  
      * Path Translator needed by the ExpressionEvaluator
 51  
      *
 52  
      * @component role="org.apache.maven.project.path.PathTranslator"
 53  
      */
 54  
     protected PathTranslator translator;
 55  
 
 56  
     /**
 57  
      * The MavenSession
 58  
      *
 59  
      * @parameter default-value="${session}"
 60  
      * @readonly
 61  
      */
 62  
     protected MavenSession session;
 63  
 
 64  
     /**
 65  
      * POM
 66  
      *
 67  
      * @parameter default-value="${project}"
 68  
      * @readonly
 69  
      * @required
 70  
      */
 71  
     protected MavenProject project;
 72  
 
 73  
     // set by the contextualize method. Only way to get the
 74  
     // plugin's container in 2.0.x
 75  
     protected PlexusContainer container;
 76  
 
 77  
     public void contextualize ( Context context )
 78  
         throws ContextException
 79  
     {
 80  0
         container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
 81  0
     }
 82  
 
 83  
     /**
 84  
      * Entry point to the mojo
 85  
      */
 86  
     public void execute ()
 87  
         throws MojoExecutionException
 88  
     {
 89  
         try
 90  
         {
 91  0
             EnforcerExpressionEvaluator evaluator = new EnforcerExpressionEvaluator( session, translator, project );
 92  0
             DefaultEnforcementRuleHelper helper = new DefaultEnforcementRuleHelper( session, evaluator, getLog(),
 93  
                                                                                     container );
 94  0
             RuntimeInformation rti = (RuntimeInformation) helper.getComponent( RuntimeInformation.class );
 95  0
             getLog().info( "Maven Version: " + rti.getApplicationVersion() );
 96  0
             getLog().info( "JDK Version: " + SystemUtils.JAVA_VERSION + " normalized as: "
 97  
                                + RequireJavaVersion.normalizeJDKVersion( SystemUtils.JAVA_VERSION_TRIMMED ) );
 98  0
             RequireOS os = new RequireOS();
 99  0
             os.displayOSInfo( getLog(), true );
 100  
 
 101  
         }
 102  0
         catch ( ComponentLookupException e )
 103  
         {
 104  0
             getLog().warn( "Unable to Lookup component: " + e.getLocalizedMessage() );
 105  0
         }
 106  
 
 107  0
     }
 108  
 
 109  
 }