diff --git a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java index cf6b86ce..6f275041 100644 --- a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java +++ b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java @@ -48,6 +48,7 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ResolutionErrorHandler; import org.apache.maven.artifact.versioning.VersionRange; +import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecution; @@ -1496,7 +1497,7 @@ private Set getCompileSources( Compiler compiler, CompilerConfiguration co catch ( InclusionScanException e ) { throw new MojoExecutionException( - "Error scanning source root: \'" + sourceRoot + "\' for stale files to recompile.", e ); + "Error scanning source root: '" + sourceRoot + "' for stale files to recompile.", e ); } } @@ -1536,42 +1537,14 @@ private boolean isSourceChanged( CompilerConfiguration compilerConfiguration, Co */ protected int getRequestThreadCount() { - try - { - Method getRequestMethod = session.getClass().getMethod( "getRequest" ); - Object mavenExecutionRequest = getRequestMethod.invoke( this.session ); - Method getThreadCountMethod = mavenExecutionRequest.getClass().getMethod( "getThreadCount" ); - String threadCount = (String) getThreadCountMethod.invoke( mavenExecutionRequest ); - return Integer.parseInt( threadCount ); - } - catch ( Exception e ) - { - getLog().debug( "unable to get threadCount for the current build: " + e.getMessage() ); - } - return 1; + return session.getRequest().getDegreeOfConcurrency(); } protected Date getBuildStartTime() { - Date buildStartTime = null; - try - { - Method getRequestMethod = session.getClass().getMethod( "getRequest" ); - Object mavenExecutionRequest = getRequestMethod.invoke( session ); - Method getStartTimeMethod = mavenExecutionRequest.getClass().getMethod( "getStartTime" ); - buildStartTime = (Date) getStartTimeMethod.invoke( mavenExecutionRequest ); - } - catch ( Exception e ) - { - getLog().debug( "unable to get start time for the current build: " + e.getMessage() ); - } - - if ( buildStartTime == null ) - { - return new Date(); - } - - return buildStartTime; + MavenExecutionRequest request = session.getRequest(); + Date buildStartTime = request == null ? new Date() : request.getStartTime(); + return buildStartTime == null ? new Date() : buildStartTime; } diff --git a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java index 9d9469f6..43683040 100644 --- a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java +++ b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java @@ -306,7 +306,7 @@ protected void preparePaths( Set sourceFiles ) if ( release != null ) { - if ( Integer.valueOf( release ) < 9 ) + if ( Integer.parseInt( release ) < 9 ) { pathElements = Collections.emptyMap(); modulepathElements = Collections.emptyList(); @@ -314,7 +314,7 @@ protected void preparePaths( Set sourceFiles ) return; } } - else if ( Double.valueOf( getTarget() ) < Double.valueOf( MODULE_INFO_TARGET ) ) + else if ( Double.parseDouble( getTarget() ) < Double.parseDouble( MODULE_INFO_TARGET ) ) { pathElements = Collections.emptyMap(); modulepathElements = Collections.emptyList(); @@ -440,7 +440,7 @@ protected SourceInclusionScanner getSourceInclusionScanner( String inputFileEndi if ( testIncludes.isEmpty() && testExcludes.isEmpty() ) { testIncludes = Collections.singleton( defaultIncludePattern ); - scanner = new SimpleSourceInclusionScanner( testIncludes, Collections.emptySet() ); + scanner = new SimpleSourceInclusionScanner( testIncludes, Collections.emptySet() ); } else {