You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Maarten Mulders (Jira)" <ji...@apache.org> on 2022/10/29 09:30:00 UTC

[jira] [Assigned] (MNG-7578) Building Linux image on Windows impossible (patch incuded)

     [ https://issues.apache.org/jira/browse/MNG-7578?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Maarten Mulders reassigned MNG-7578:
------------------------------------

    Assignee: Maarten Mulders

> 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
>            Assignee: Maarten Mulders
>            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)