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.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.project.MavenProject;
28 import org.apache.maven.project.path.PathTranslator;
29 import org.codehaus.plexus.PlexusConstants;
30 import org.codehaus.plexus.PlexusContainer;
31 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
32 import org.codehaus.plexus.context.Context;
33 import org.codehaus.plexus.context.ContextException;
34 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
35
36
37
38
39
40
41
42
43
44 public class DisplayInfoMojo
45 extends AbstractMojo
46 implements Contextualizable
47 {
48
49
50
51
52
53
54 protected PathTranslator translator;
55
56
57
58
59
60
61
62 protected MavenSession session;
63
64
65
66
67
68
69
70
71 protected MavenProject project;
72
73
74
75 protected PlexusContainer container;
76
77 public void contextualize ( Context context )
78 throws ContextException
79 {
80 container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
81 }
82
83
84
85
86 public void execute ()
87 throws MojoExecutionException
88 {
89 try
90 {
91 EnforcerExpressionEvaluator evaluator = new EnforcerExpressionEvaluator( session, translator, project );
92 DefaultEnforcementRuleHelper helper = new DefaultEnforcementRuleHelper( session, evaluator, getLog(),
93 container );
94 RuntimeInformation rti = (RuntimeInformation) helper.getComponent( RuntimeInformation.class );
95 getLog().info( "Maven Version: " + rti.getApplicationVersion() );
96 getLog().info( "JDK Version: " + SystemUtils.JAVA_VERSION + " normalized as: "
97 + RequireJavaVersion.normalizeJDKVersion( SystemUtils.JAVA_VERSION_TRIMMED ) );
98 RequireOS os = new RequireOS();
99 os.displayOSInfo( getLog(), true );
100
101 }
102 catch ( ComponentLookupException e )
103 {
104 getLog().warn( "Unable to Lookup component: " + e.getLocalizedMessage() );
105 }
106
107 }
108
109 }