mirror of
https://github.com/apache/maven.git
synced 2025-02-23 02:15:50 +00:00
PR: MNG-976
Submitted by: Lester Ecarma Reviewed by: Brett Porter add meminitial and maxmem settings to the forking compiler git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@327878 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bc1d56f5d4
commit
05add6c489
@ -11,20 +11,25 @@
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
<inceptionYear>2001</inceptionYear>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
<version>1.0.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-compiler-api</artifactId>
|
||||
<version>1.5.1</version>
|
||||
<version>1.6-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-compiler-manager</artifactId>
|
||||
<version>1.5.1</version>
|
||||
<version>1.6-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-compiler-javac</artifactId>
|
||||
<version>1.5.1</version>
|
||||
<version>1.6-SNAPSHOT</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -33,4 +38,4 @@
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
</project>
|
||||
|
@ -28,6 +28,7 @@
|
||||
import org.codehaus.plexus.compiler.util.scan.mapping.SingleTargetSourceMapping;
|
||||
import org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping;
|
||||
import org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@ -144,6 +145,20 @@ public abstract class AbstractCompilerMojo
|
||||
*/
|
||||
private boolean fork;
|
||||
|
||||
/**
|
||||
* Initial size, in megabytes, of the memory allocation pool, ex. "64", "64m".
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private String meminitial;
|
||||
|
||||
/**
|
||||
* maximum size, in megabytes, of the memory allocation pool, ex. "128", "128m".
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private String maxmem;
|
||||
|
||||
/**
|
||||
* The executable of the compiler to use.
|
||||
*
|
||||
@ -296,6 +311,37 @@ public void execute()
|
||||
|
||||
compilerConfiguration.setFork( fork );
|
||||
|
||||
if( fork )
|
||||
{
|
||||
if ( !StringUtils.isEmpty( meminitial ) )
|
||||
{
|
||||
String value = getMemoryValue( meminitial );
|
||||
|
||||
if ( value != null )
|
||||
{
|
||||
compilerConfiguration.setMeminitial( value );
|
||||
}
|
||||
else
|
||||
{
|
||||
getLog().info( "Invalid value for meminitial '" + meminitial + "'. Ignoring this option." );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !StringUtils.isEmpty( maxmem ) )
|
||||
{
|
||||
String value = getMemoryValue( maxmem );
|
||||
|
||||
if ( value != null )
|
||||
{
|
||||
compilerConfiguration.setMaxmem( value );
|
||||
}
|
||||
else
|
||||
{
|
||||
getLog().info( "Invalid value for maxmem '" + maxmem + "'. Ignoring this option." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
compilerConfiguration.setExecutable( executable );
|
||||
|
||||
compilerConfiguration.setWorkingDirectory( basedir );
|
||||
@ -439,6 +485,38 @@ public void execute()
|
||||
}
|
||||
}
|
||||
|
||||
private String getMemoryValue( String setting )
|
||||
{
|
||||
String value = null;
|
||||
|
||||
// Allow '128' or '128m'
|
||||
if ( isDigits( setting ) )
|
||||
{
|
||||
value = setting + "m";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ( isDigits( setting.substring( 0, setting.length() - 1 ) ) ) &&
|
||||
( setting.toLowerCase().endsWith( "m" ) ) )
|
||||
{
|
||||
value = setting;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private boolean isDigits( String string )
|
||||
{
|
||||
for ( int i = 0; i < string.length(); i++ )
|
||||
{
|
||||
if ( !Character.isDigit( string.charAt( i ) ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Set computeStaleSources( CompilerConfiguration compilerConfiguration, Compiler compiler,
|
||||
SourceInclusionScanner scanner )
|
||||
throws MojoExecutionException, CompilerException
|
||||
|
Loading…
x
Reference in New Issue
Block a user