void copyLauncher()

in nbm-maven-plugin/src/main/java/org/apache/netbeans/nbm/BuildMacMojo.java [252:283]


    void copyLauncher( File macOSDir ) throws IOException, MojoExecutionException
    {
        Path launcherPath = macOSDir.toPath(  ).resolve( brandingToken );

        if ( macLauncherFile != null )
        {
            FileUtils.copyFile( macLauncherFile, launcherPath.toFile(  ) );
        }
        else
        {
            URL harnessResourse = getClass(  ).getClassLoader(  ).getResource( "harness" );
            JarURLConnection jarConnection = ( JarURLConnection ) harnessResourse.openConnection(  );
            JarFile jarFile = jarConnection.getJarFile(  );

            JarEntry entry = jarFile.getJarEntry( "harness/launchers/app-macOS" );

            if ( entry == null )
            {
                throw new MojoExecutionException( "macOS launcher not found in harness"
                                                 + " or via macLauncherFile parameter" );

            }

            try ( InputStream entryInputStream = jarFile.getInputStream( entry ) )
            {
                Files.copy( entryInputStream, launcherPath, StandardCopyOption.REPLACE_EXISTING );
            }

        }

        launcherPath.toFile(  ).setExecutable( true );
    }