/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package de.nplusc.izc.InstallPak.makedist;

import de.nplusc.izc.tools.IOtools.FileTK;
import de.nplusc.izc.tools.IOtools.ZipFileHandler;
import de.nplusc.izc.tools.IOtools.ZipUtils;
import de.nplusc.izc.tools.IOtools.iZformats.IZpackage;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;

/**
 *
 * @author LH
 */
public class MakeDist
{
    public static void makeDist(String relID,String inPath,String ExternalInputPath)
    {
        try
        {
            FileUtils.copyDirectory(new File(ExternalInputPath), new File(inPath+File.separator+"engine"));
        }
        catch (IOException ex)
        {
            ex.printStackTrace();
        }
        FileTK.kopierpaste(new File(inPath+"/ZZZ_sfxmod.jar"),new File(inPath+"/engine/ZZZ_sfxmod.jar"));
        FileTK.kopierpaste(new File(inPath+"/ZZZ_sfxmod.jar"),new File(inPath+"/demopackage/ZZZ_sfxmod.jar"));
        FileTK.kopierpaste(new File(inPath+"/ZZZ_sfxmod.jar"),new File(inPath+"/predist/ZZZ_sfxmod.jar"));
        IZpackage.wrapArchive(inPath+"/bundledata/iZsetup_inst.jar", inPath+"/engine");
        IZpackage.wrapArchive(inPath+"/bundledata/demopaq.jar", inPath+"/demopackage");
        ZipUtils zu = new ZipUtils(inPath+"/predist/izsetup.izbundle", inPath+File.separator+"bundledata");
        IZpackage.wrapArchive(inPath+"/dist/iZsetup_setup.jar", inPath+"/predist");
        new File(inPath+"/dist/"+relID+"/iZsetup_setup.jar").delete();
        FileTK.ensuredirExistence(new File(inPath+"/dist/"+relID+"/iZsetup_setup.jar"));
        FileTK.kopierpaste(new File(inPath+"/dist/iZsetup_setup.jar"), new File(inPath+"/dist/"+relID+"/iZsetup_setup.jar"));
        
        
        
    }
    public static void main(String[] args)
    {
        if(args.length==0)
        {
        makeDist("FFF","T:\\icns\\iZs\\decided","C:/.jenkins/jobs/iZsetup/workspace/dist");
        }
        else
        {
        makeDist(args[1],args[2],args[3]);
        makeDist(args[1],args[2]+"/64b",args[3]);
        }
    }
}
