1 package org.apache.maven.plugins.enforcer;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.execution.MavenSession;
23 import org.apache.maven.plugin.AbstractMojo;
24 import org.apache.maven.plugin.MojoExecution;
25 import org.apache.maven.plugin.MojoExecutionException;
26 import org.apache.maven.plugins.annotations.Mojo;
27 import org.apache.maven.plugins.annotations.Parameter;
28 import org.apache.maven.project.MavenProject;
29 import org.codehaus.plexus.PlexusConstants;
30 import org.codehaus.plexus.PlexusContainer;
31 import org.codehaus.plexus.context.Context;
32 import org.codehaus.plexus.context.ContextException;
33 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
34
35
36
37
38
39
40 @Mojo( name = "display-info", threadSafe = true )
41 public class DisplayInfoMojo
42 extends AbstractMojo
43 implements Contextualizable
44 {
45
46
47
48
49 @Parameter( defaultValue = "${mojoExecution}", readonly = true, required = true )
50 protected MojoExecution mojoExecution;
51
52
53
54
55 @Parameter( defaultValue = "${session}", readonly = true, required = true )
56 protected MavenSession session;
57
58
59
60
61 @Parameter( defaultValue = "${project}", readonly = true, required = true )
62 protected MavenProject project;
63
64
65
66 protected PlexusContainer container;
67
68 public void contextualize( Context context )
69 throws ContextException
70 {
71 container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
72 }
73
74
75
76
77 public void execute()
78 throws MojoExecutionException
79 {
80 String mavenVersion = session.getSystemProperties().getProperty( "maven.version" );
81 String javaVersion = System.getProperty( "java.version" );
82 getLog().info( "Maven Version: " + mavenVersion );
83 getLog().info( "JDK Version: " + javaVersion + " normalized as: "
84 + RequireJavaVersion.normalizeJDKVersion( javaVersion ) );
85 RequireOS os = new RequireOS();
86 os.displayOSInfo( getLog(), true );
87 }
88
89 }