Skip to content

Commit 0b4048b

Browse files
authored
javac dump debug file should not be written in classes directory as it will be included in jar. change directory and make name configurable (#184)
Signed-off-by: Olivier Lamy <olamy@apache.org>
1 parent a1c57a5 commit 0b4048b

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerConfiguration.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ public class CompilerConfiguration
172172
*/
173173
private boolean forceJavacCompilerUse=false;
174174

175+
/**
176+
* force a different of the debug file containing the forked command run (such javac.sh)
177+
* @since 2.9.1
178+
*/
179+
private String debugFileName;
180+
175181
// ----------------------------------------------------------------------
176182
//
177183
// ----------------------------------------------------------------------
@@ -720,6 +726,16 @@ public void setCompilerReuseStrategy( CompilerReuseStrategy compilerReuseStrateg
720726
this.compilerReuseStrategy = compilerReuseStrategy;
721727
}
722728

729+
public String getDebugFileName()
730+
{
731+
return debugFileName;
732+
}
733+
734+
public void setDebugFileName(String debugFileName)
735+
{
736+
this.debugFileName = debugFileName;
737+
}
738+
723739
/**
724740
* Re-use strategy of the compiler (implement for java only).
725741
*/

plexus-compilers/plexus-compiler-j2objc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ J2ObjC Plexus compiler
2323
<dependency>
2424
<groupId>org.codehaus.plexus</groupId>
2525
<artifactId>plexus-compiler-j2objc</artifactId>
26-
<version>2.8.1-SNAPSHOT</version>
26+
<version>2.9.1-SNAPSHOT</version>
2727
</dependency>
2828
</dependencies>
2929
</plugin>

plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavacCompiler.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ protected CompilerResult compileOutOfProcess( CompilerConfiguration config, Stri
559559

560560
try
561561
{
562-
File argumentsFile = createFileWithArguments( args, config.getOutputLocation() );
562+
File argumentsFile = createFileWithArguments( args, config.getBuildDirectory().getAbsolutePath() );
563563
cli.addArguments(
564564
new String[]{ "@" + argumentsFile.getCanonicalPath().replace( File.separatorChar, '/' ) } );
565565

@@ -594,8 +594,10 @@ protected CompilerResult compileOutOfProcess( CompilerConfiguration config, Stri
594594

595595
if ( ( getLogger() != null ) && getLogger().isDebugEnabled() )
596596
{
597+
String debugFileName = StringUtils.isEmpty(config.getDebugFileName()) ? "javac" : config.getDebugFileName();
598+
597599
File commandLineFile =
598-
new File( config.getOutputLocation(), "javac." + ( Os.isFamily( Os.FAMILY_WINDOWS ) ? "bat" : "sh" ) );
600+
new File( config.getBuildDirectory(), StringUtils.trim(debugFileName) + "." + ( Os.isFamily( Os.FAMILY_WINDOWS ) ? "bat" : "sh" ) );
599601
try
600602
{
601603
FileUtils.fileWrite( commandLineFile.getAbsolutePath(), cli.toString().replaceAll( "'", "" ) );

0 commit comments

Comments
 (0)