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 * @version $Id$ 040 */ 041@Mojo( name = "display-info", threadSafe = true ) 042public class DisplayInfoMojo 043 extends AbstractMojo 044 implements Contextualizable 045{ 046 047 /** 048 * MojoExecution needed by the ExpressionEvaluator 049 */ 050 @Parameter( defaultValue = "${mojoExecution}", readonly = true, required = true ) 051 protected MojoExecution mojoExecution; 052 053 /** 054 * The MavenSession 055 */ 056 @Parameter( defaultValue = "${session}", readonly = true, required = true ) 057 protected MavenSession session; 058 059 /** 060 * POM 061 */ 062 @Parameter( defaultValue = "${project}", readonly = true, required = true ) 063 protected MavenProject project; 064 065 // set by the contextualize method. Only way to get the 066 // plugin's container in 2.0.x 067 protected PlexusContainer container; 068 069 public void contextualize( Context context ) 070 throws ContextException 071 { 072 container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); 073 } 074 075 /** 076 * Entry point to the mojo 077 */ 078 public void execute() 079 throws MojoExecutionException 080 { 081 String mavenVersion = session.getSystemProperties().getProperty( "maven.version" ); 082 String javaVersion = System.getProperty( "java.version" ); 083 getLog().info( "Maven Version: " + mavenVersion ); 084 getLog().info( "JDK Version: " + javaVersion + " normalized as: " 085 + RequireJavaVersion.normalizeJDKVersion( javaVersion ) ); 086 RequireOS os = new RequireOS(); 087 os.displayOSInfo( getLog(), true ); 088 } 089 090}