Skip to content

Commit 946bb40

Browse files
committed
getting rid of code duplication
1 parent 181d173 commit 946bb40

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

maven-plugin/src/main/java/hudson/maven/Maven3Builder.java

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -458,11 +458,7 @@ private void recordMojoStarted(ExecutionEvent event) {
458458
initMojoStartTime( event.getProject() );
459459

460460
MavenProject mavenProject = event.getProject();
461-
XmlPlexusConfiguration xmlPlexusConfiguration = new XmlPlexusConfiguration( event.getMojoExecution().getConfiguration() );
462-
463-
MojoInfo mojoInfo =
464-
new MojoInfo( event.getMojoExecution(), null, xmlPlexusConfiguration,
465-
getExpressionEvaluator( event.getSession(), event.getMojoExecution() ) );
461+
MojoInfo mojoInfo = new MojoInfo(event);
466462

467463
List<MavenReporter> mavenReporters = getMavenReporters( mavenProject );
468464

@@ -495,13 +491,7 @@ public void mojoSucceeded( ExecutionEvent event ) {
495491

496492
private void recordMojoSucceeded(ExecutionEvent event) {
497493
MavenProject mavenProject = event.getProject();
498-
XmlPlexusConfiguration xmlPlexusConfiguration = new XmlPlexusConfiguration( event.getMojoExecution().getConfiguration() );
499-
500-
Mojo mojo = null;//getMojo( event.getMojoExecution(), event.getSession() );
501-
502-
MojoInfo mojoInfo =
503-
new MojoInfo( event.getMojoExecution(), mojo, xmlPlexusConfiguration,
504-
getExpressionEvaluator( event.getSession(), event.getMojoExecution() ) );
494+
MojoInfo mojoInfo = new MojoInfo(event);
505495

506496
recordExecutionTime(event,mojoInfo);
507497

@@ -557,13 +547,7 @@ private void debug(String msg) {
557547

558548
private void recordMojoFailed(ExecutionEvent event) {
559549
MavenProject mavenProject = event.getProject();
560-
XmlPlexusConfiguration xmlPlexusConfiguration = new XmlPlexusConfiguration( event.getMojoExecution().getConfiguration() );
561-
562-
Mojo mojo = null;//getMojo( event.getMojoExecution(), event.getSession() );
563-
564-
MojoInfo mojoInfo =
565-
new MojoInfo( event.getMojoExecution(), mojo, xmlPlexusConfiguration,
566-
getExpressionEvaluator( event.getSession(), event.getMojoExecution() ) );
550+
MojoInfo mojoInfo = new MojoInfo(event);
567551

568552
recordExecutionTime(event,mojoInfo);
569553

maven-plugin/src/main/java/hudson/maven/MojoInfo.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@
2323
*/
2424
package hudson.maven;
2525

26+
import org.apache.maven.execution.ExecutionEvent;
2627
import org.apache.maven.plugin.AbstractMojo;
2728
import org.apache.maven.plugin.MojoExecution;
2829
import org.apache.maven.plugin.Mojo;
2930
import org.apache.maven.plugin.MojoExecutionException;
3031
import org.apache.maven.plugin.MojoFailureException;
32+
import org.apache.maven.plugin.PluginParameterExpressionEvaluator;
3133
import org.apache.maven.plugin.descriptor.PluginDescriptor;
3234
import org.codehaus.classworlds.ClassRealm;
3335
import org.codehaus.plexus.configuration.PlexusConfiguration;
@@ -45,6 +47,7 @@
4547

4648
import hudson.util.InvocationInterceptor;
4749
import hudson.util.ReflectionUtils;
50+
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
4851

4952
/**
5053
* Information about Mojo to be executed. This object provides
@@ -111,6 +114,12 @@ public MojoInfo(MojoExecution mojoExecution, Mojo mojo, PlexusConfiguration conf
111114
this.pluginName = new PluginName(mojoExecution.getMojoDescriptor().getPluginDescriptor());
112115
}
113116

117+
public MojoInfo(ExecutionEvent event) {
118+
this(event.getMojoExecution(), null,
119+
new XmlPlexusConfiguration( event.getMojoExecution().getConfiguration() ),
120+
new PluginParameterExpressionEvaluator( event.getSession(), event.getMojoExecution() ));
121+
}
122+
114123
/**
115124
* Gets the goal name of the mojo to be executed,
116125
* such as "javadoc". This is local to the plugin name.

0 commit comments

Comments
 (0)