[ 
https://issues.apache.org/jira/browse/MNG-7578?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17622864#comment-17622864
 ] 

Michael Osipov commented on MNG-7578:
-------------------------------------

Makes sense, this also applies to other executalbes. I wonder why we need 
{{.exe}} at all to execute. It is implied on Windows anyway.

> Building Linux image on Windows impossible (patch incuded)
> ----------------------------------------------------------
>
>                 Key: MNG-7578
>                 URL: https://issues.apache.org/jira/browse/MNG-7578
>             Project: Maven
>          Issue Type: Bug
>          Components: Core, Toolchains
>    Affects Versions: 3.8.6
>            Reporter: Eugen Labun
>            Priority: Major
>
> If you try to find `javac` in a Linux JDK using `Toolchain.findTool()` 
> method, this will fail when the build is running on Windows, since the 
> implementation 
> [JavaToolchainImpl#findTool()|https://github.com/apache/maven/blob/maven-3.8.6/maven-core/src/main/java/org/apache/maven/toolchain/java/JavaToolchainImpl.java#L74-L86]
>  appends ".exe" to the toolName (causing `javac.exe` is not found):
> {code:java}
>     private static File findTool( String toolName, File installFolder )
>     {
>         File bin = new File( installFolder, "bin" ); //NOI18N
>         if ( bin.exists() )
>         {
>             File tool = new File( bin, toolName + ( Os.isFamily( "windows" ) 
> ? ".exe" : "" ) ); // NOI18N
>             if ( tool.exists() )
>             {
>                 return tool;
>             }
>         }
>         return null;
>    }
> {code}
> The current workaround is to manually add a fake `javac.exe` file to the JDK 
> `bin` directory. See [tool chain issue (building linux image on windows 
> machine)|https://github.com/moditect/moditect/issues/107] in moditect project.
> The `findTool` method could yet easily be changed to search for exact 
> `toolName` as requested, with a fallback to `toolName.exe` for backward 
> compatibility:
> {code:java}
>     private static File findTool( String toolName, File installFolder )
>     {
>         File bin = new File( installFolder, "bin" );
>         if ( bin.exists() )
>         {
>             File tool = new File( bin, toolName );
>             if ( tool.exists() )
>             {
>                 return tool;
>             }
>             File toolExe = new File( bin, toolName + ".exe" );
>             if ( toolExe.exists() )
>             {
>                 return toolExe;
>             }
>         }
>         return null;
>    }
> {code}
> This would solve the problem.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to