001package org.apache.maven.plugins.enforcer; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.apache.maven.execution.MavenSession; 023import org.apache.maven.plugin.AbstractMojo; 024import org.apache.maven.plugin.MojoExecution; 025import org.apache.maven.plugin.MojoExecutionException; 026import org.apache.maven.plugins.annotations.Mojo; 027import org.apache.maven.plugins.annotations.Parameter; 028import org.apache.maven.project.MavenProject; 029import org.codehaus.plexus.PlexusConstants; 030import org.codehaus.plexus.PlexusContainer; 031import org.codehaus.plexus.context.Context; 032import org.codehaus.plexus.context.ContextException; 033import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; 034 035/** 036 * This goal displays the current platform information. 037 * 038 * @author <a href="mailto:brianf@apache.org">Brian Fox</a> 039 */ 040@Mojo( name = "display-info", threadSafe = true ) 041public class DisplayInfoMojo 042 extends AbstractMojo 043 implements Contextualizable 044{ 045 046 /** 047 * MojoExecution needed by the ExpressionEvaluator 048 */ 049 @Parameter( defaultValue = "${mojoExecution}", readonly = true, required = true ) 050 protected MojoExecution mojoExecution; 051 052 /** 053 * The MavenSession 054 */ 055 @Parameter( defaultValue = "${session}", readonly = true, required = true ) 056 protected MavenSession session; 057 058 /** 059 * POM 060 */ 061 @Parameter( defaultValue = "${project}", readonly = true, required = true ) 062 protected MavenProject project; 063 064 // set by the contextualize method. Only way to get the 065 // plugin's container in 2.0.x 066 protected PlexusContainer container; 067 068 public void contextualize( Context context ) 069 throws ContextException 070 { 071 container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); 072 } 073 074 /** 075 * Entry point to the mojo 076 */ 077 public void execute() 078 throws MojoExecutionException 079 { 080 String mavenVersion = session.getSystemProperties().getProperty( "maven.version" ); 081 String javaVersion = System.getProperty( "java.version" ); 082 String javaVendor = System.getProperty( "java.vendor" ); 083 getLog().info( "Maven Version: " + mavenVersion ); 084 getLog().info( "JDK Version: " + javaVersion + " normalized as: " 085 + RequireJavaVersion.normalizeJDKVersion( javaVersion ) ); 086 getLog().info( "Java Vendor: " + javaVendor ); 087 RequireOS os = new RequireOS(); 088 os.displayOSInfo( getLog(), true ); 089 } 090 091}