Details
Description
At fist, you must use non-us windows xp ( I have reproduced this on Windows XP Professional CZECH mutation ).
Create simple maven project with one class ( for example test.App ).
Write following code:
public class App { public static void main(String[] args) throws IOException { String s = args[0]; FileWriter w = new FileWriter(new File("c:\\output.txt"), true); // get env variable String appData = System.getenv("APPDATA"); // write env variable to file and write if directory where that variable points to exists w.write(s + " : " + appData + " : " + new File(appData).exists() + "\n"); w.close(); }
Then run this app with exec:exec and directly by following commands:
mvn install
mvn exec:exec -Dexec.executable=java -Dexec.args="-classpath %classpath test.App maven"
java -cp target\mavenExecEncodingBug-1.0-SNAPSHOT.jar test.App jar
We are expecting result like:
maven : C:\Documents and Settings\admin\Data aplikací : true
jar : C:\Documents and Settings\admin\Data aplikací : true
But it is:
maven : C:\Documents and Settings\admin\Data aplikacˇ : false
jar : C:\Documents and Settings\admin\Data aplikací : true
This is a big problem for me, because my applications looks into different folders when running from IDE and in production.
See also https://netbeans.org/bugzilla/show_bug.cgi?id=172265 for more reference.
Issue Links
| This issue depends upon: | ||||
| PLXUTILS-124 | CommandLine enviroment variables are broken ( bad encoding ) |
|
|
|
I have taked a look into source of exec plugin and it seems that problem is on other place.
I have added into ExecMojo:execute() following code:
Commandline commandLine = new Commandline();
commandLine.setExecutable( getExecutablePath() );
// TEST
try {
for ( String xxx : commandLine.getEnvironmentVariables() ) { System.out.println("TEST:"+ xxx); }
}
catch (CommandLineException ex) { ex.printStackTrace(); }
... and encoding of "APPDATA" was corrupted there too.
Could anybody confirm it is CommandLine class bug?