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