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
41 @Mojo( name = "display-info", threadSafe = true )
42 public class DisplayInfoMojo
43 extends AbstractMojo
44 implements Contextualizable
45 {
46
47
48
49
50 @Parameter( defaultValue = "${mojoExecution}", readonly = true, required = true )
51 protected MojoExecution mojoExecution;
52
53
54
55
56 @Parameter( defaultValue = "${session}", readonly = true, required = true )
57 protected MavenSession session;
58
59
60
61
62 @Parameter( defaultValue = "${project}", readonly = true, required = true )
63 protected MavenProject project;
64
65
66
67 protected PlexusContainer container;
68
69 public void contextualize( Context context )
70 throws ContextException
71 {
72 container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
73 }
74
75
76
77
78 public void execute()
79 throws MojoExecutionException
80 {
81 String mavenVersion = session.getSystemProperties().getProperty( "maven.version" );
82 String javaVersion = System.getProperty( "java.version" );
83 getLog().info( "Maven Version: " + mavenVersion );
84 getLog().info( "JDK Version: " + javaVersion + " normalized as: "
85 + RequireJavaVersion.normalizeJDKVersion( javaVersion ) );
86 RequireOS os = new RequireOS();
87 os.displayOSInfo( getLog(), true );
88 }
89
90 }