Search in sources :

Example 1 with EventHelper

use of com.twinsoft.convertigo.engine.util.EventHelper in project convertigo by convertigo.

the class Ionic3Builder method init.

@Override
protected synchronized void init() throws EngineException {
    if (initDone) {
        return;
    }
    ApplicationComponent application = (ApplicationComponent) project.getMobileApplication().getApplicationComponent();
    String tplName = application.getTplProjectName();
    if (!project.getName().equals(tplName)) {
        try {
            Engine.theApp.referencedProjectManager.getReferenceFromProject(project, tplName);
            Engine.theApp.referencedProjectManager.importProjectFrom(project, tplName);
        } catch (Exception e) {
            throw new EngineException("Failed to import referenced template: " + tplName + " :" + e.getMessage(), e);
        }
    }
    ionicTplDir = application.getIonicTplDir();
    if (!ionicTplDir.exists()) {
        throw new EngineException("Missing template project '" + application.getTplProjectName() + "'\nThe template folder should be in: " + ionicTplDir.getPath());
    }
    if (Engine.isStudioMode()) {
        File devicePref = new File(Engine.USER_WORKSPACE_PATH, "studio/device-" + project.getName() + ".json");
        if (devicePref.exists()) {
            try {
                JSONObject device = new JSONObject(FileUtils.readFileToString(devicePref, "UTF-8"));
                buildMode = MobileBuilderBuildMode.get(device.getString("buildMode"));
            } catch (Exception e) {
            }
        }
    }
    if (isIonicTemplateBased()) {
        if (eventHelper == null) {
            eventHelper = new EventHelper();
        }
        setNeedPkgUpdate(false);
        // Clean directories
        cleanDirectories();
        // Copy template directory to working directory
        copyTemplateFiles();
        // Copy template assets to build directory
        copyAssetsToBuildDir();
        // Modify configuration files
        updateConfigurationFiles();
        // Tpl version
        updateTplVersion();
        // PWA
        configurePwaApp(application);
        // Write source files (based on bean components)
        updateSourceFiles();
        // Studio mode : start worker for build process
        if (Engine.isStudioMode() || Engine.isCliMode()) {
            if (pushedFiles == null) {
                pushedFiles = new HashMap<String, CharSequence>();
            }
            if (queue == null) {
                queue = new LinkedBlockingQueue<Map<String, CharSequence>>();
            }
            if (worker == null) {
                worker = new MbWorker(queue);
                if (Engine.isStudioMode()) {
                    worker.start();
                } else {
                    worker.process();
                }
            }
        }
        initDone = true;
        Engine.logEngine.debug("(MobileBuilder) Initialized builder for ionic project '" + project.getName() + "'");
    }
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) IApplicationComponent(com.twinsoft.convertigo.beans.core.IApplicationComponent) ApplicationComponent(com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) EngineException(com.twinsoft.convertigo.engine.EngineException) EventHelper(com.twinsoft.convertigo.engine.util.EventHelper) File(java.io.File) HashMap(java.util.HashMap) Map(java.util.Map) IOException(java.io.IOException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 2 with EventHelper

use of com.twinsoft.convertigo.engine.util.EventHelper in project convertigo by convertigo.

the class NgxBuilder method init.

@Override
protected synchronized void init() throws EngineException {
    if (initDone) {
        return;
    }
    ApplicationComponent application = (ApplicationComponent) project.getMobileApplication().getApplicationComponent();
    String tplName = application.getTplProjectName();
    if (!project.getName().equals(tplName)) {
        try {
            Engine.theApp.referencedProjectManager.getReferenceFromProject(project, tplName);
            Engine.theApp.referencedProjectManager.importProjectFrom(project, tplName);
        } catch (Exception e) {
            throw new EngineException("Failed to import referenced template: " + tplName + " :" + e.getMessage(), e);
        }
    }
    ionicTplDir = application.getIonicTplDir();
    if (!ionicTplDir.exists()) {
        throw new EngineException("Missing template project '" + application.getTplProjectName() + "'\nThe template folder should be in: " + ionicTplDir.getPath());
    }
    if (isIonicTemplateBased()) {
        if (eventHelper == null) {
            eventHelper = new EventHelper();
        }
        setNeedPkgUpdate(false);
        // Clean directories
        cleanDirectories();
        // Copy template directory to working directory
        copyTemplateFiles();
        // Copy template assets to build directory
        copyAssetsToBuildDir();
        // Modify configuration files
        updateConfigurationFiles();
        // Tpl version
        updateTplVersion();
        // Modify env.json
        initEnvFile();
        // PWA
        configurePwaApp(application);
        // Write source files (based on bean components)
        updateSourceFiles();
        // Studio mode : start worker for build process
        if (Engine.isStudioMode() || Engine.isCliMode()) {
            if (pushedFiles == null) {
                pushedFiles = new HashMap<String, CharSequence>();
            }
            if (queue == null) {
                queue = new LinkedBlockingQueue<Map<String, CharSequence>>();
            }
            if (worker == null) {
                worker = new MbWorker(queue);
                if (Engine.isStudioMode()) {
                    worker.start();
                } else {
                    worker.process();
                }
            }
            if (watcherService == null) {
                updateConsumer();
                updateConsumers();
                if (Engine.isStudioMode()) {
                    try {
                        watcherService = new DirectoryWatcherService(project, true);
                        watcherService.start();
                    } catch (Exception e) {
                        Engine.logEngine.warn(e.getMessage());
                    }
                }
            }
        }
        initDone = true;
        Engine.logEngine.debug("(MobileBuilder) Initialized builder for ionic project '" + project.getName() + "'");
    }
}
Also used : ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) IApplicationComponent(com.twinsoft.convertigo.beans.core.IApplicationComponent) EngineException(com.twinsoft.convertigo.engine.EngineException) EventHelper(com.twinsoft.convertigo.engine.util.EventHelper) HashMap(java.util.HashMap) Map(java.util.Map) IOException(java.io.IOException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Aggregations

IApplicationComponent (com.twinsoft.convertigo.beans.core.IApplicationComponent)2 EngineException (com.twinsoft.convertigo.engine.EngineException)2 EventHelper (com.twinsoft.convertigo.engine.util.EventHelper)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ApplicationComponent (com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent)1 ApplicationComponent (com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent)1 File (java.io.File)1 JSONObject (org.codehaus.jettison.json.JSONObject)1