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.plugins.annotations.Component;
 28  
 import org.apache.maven.plugins.annotations.Mojo;
 29  
 import org.apache.maven.project.MavenProject;
 30  
 import org.apache.maven.project.path.PathTranslator;
 31  
 import org.codehaus.plexus.PlexusConstants;
 32  
 import org.codehaus.plexus.PlexusContainer;
 33  
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 34  
 import org.codehaus.plexus.context.Context;
 35  
 import org.codehaus.plexus.context.ContextException;
 36  
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
 37  
 
 38  
 /**
 39  
  * This goal displays the current platform information.
 40  
  *
 41  
  * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
 42  
  * @version $Id: DisplayInfoMojo.java 1411846 2012-11-20 20:29:54Z hboutemy $
 43  
  */
 44  
 @Mojo( name = "display-info", threadSafe = true )
 45  0
 public class DisplayInfoMojo
 46  
     extends AbstractMojo
 47  
     implements Contextualizable
 48  
 {
 49  
 
 50  
     /**
 51  
      * Path Translator needed by the ExpressionEvaluator
 52  
      */
 53  
     @Component( role = PathTranslator.class )
 54  
     protected PathTranslator translator;
 55  
 
 56  
     /**
 57  
      * The MavenSession
 58  
      */
 59  
     @Component
 60  
     protected MavenSession session;
 61  
 
 62  
     /**
 63  
      * POM
 64  
      */
 65  
     @Component
 66  
     protected MavenProject project;
 67  
 
 68  
     // set by the contextualize method. Only way to get the
 69  
     // plugin's container in 2.0.x
 70  
     protected PlexusContainer container;
 71  
 
 72  
     public void contextualize ( Context context )
 73  
         throws ContextException
 74  
     {
 75  0
         container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
 76  0
     }
 77  
 
 78  
     /**
 79  
      * Entry point to the mojo
 80  
      */
 81  
     public void execute ()
 82  
         throws MojoExecutionException
 83  
     {
 84  
         try
 85  
         {
 86  0
             EnforcerExpressionEvaluator evaluator = new EnforcerExpressionEvaluator( session, translator, project );
 87  0
             DefaultEnforcementRuleHelper helper = new DefaultEnforcementRuleHelper( session, evaluator, getLog(),
 88  
                                                                                     container );
 89  0
             RuntimeInformation rti = (RuntimeInformation) helper.getComponent( RuntimeInformation.class );
 90  0
             getLog().info( "Maven Version: " + rti.getApplicationVersion() );
 91  0
             getLog().info( "JDK Version: " + SystemUtils.JAVA_VERSION + " normalized as: "
 92  
                                + RequireJavaVersion.normalizeJDKVersion( SystemUtils.JAVA_VERSION_TRIMMED ) );
 93  0
             RequireOS os = new RequireOS();
 94  0
             os.displayOSInfo( getLog(), true );
 95  
         }
 96  0
         catch ( ComponentLookupException e )
 97  
         {
 98  0
             getLog().warn( "Unable to Lookup component: " + e.getLocalizedMessage() );
 99  0
         }
 100  0
     }
 101  
 
 102  
 }