Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-7578

Building Linux image on Windows impossible (patch incuded)

    XMLWordPrintableJSON

Details

    • Patch

    Description

      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() appends ".exe" to the toolName (causing `javac.exe` is not found):

          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;
         }
      

      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) 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:

          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;
         }
      

      This would solve the problem.

      Attachments

        Issue Links

          Activity

            People

              mthmulders Maarten Mulders
              Labun Eugen Labun
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: