protected void publishModule()

in eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java [204:264]


    protected void publishModule(int kind, int deltaKind, IModule[] module, IProgressMonitor monitor)
            throws CoreException {

        Logger logger = Activator.getDefault().getPluginLogger();
        
        if (commandFactory == null) {
            commandFactory = Activator.getDefault().getCommandFactory();
        }

        logger.trace(traceOperation(kind, deltaKind, module));

        if (getServer().getServerState() == IServer.STATE_STOPPED) {
            logger.trace("Ignoring request to publish module when the server is stopped");
            setModulePublishState(module, IServer.PUBLISH_STATE_NONE);
            return;
        }

        if ((kind == IServer.PUBLISH_AUTO || kind == IServer.PUBLISH_INCREMENTAL)
                && deltaKind == ServerBehaviourDelegate.NO_CHANGE) {
            logger.trace("Ignoring request to publish the module when no resources have changed; most likely another module has changed");
            setModulePublishState(module, IServer.PUBLISH_STATE_NONE);
            return;
        }
        
        if (kind == IServer.PUBLISH_FULL && deltaKind == ServerBehaviourDelegate.REMOVED) {
            logger.trace("Ignoring request to unpublish all of the module resources");
            setModulePublishState(module, IServer.PUBLISH_STATE_NONE);
            return;
        }
        
        try {
            if (ProjectHelper.isBundleProject(module[0].getProject())) {
                String serverMode = getServer().getMode();
                if (!serverMode.equals(ILaunchManager.DEBUG_MODE) || kind==IServer.PUBLISH_CLEAN) {
                    // in debug mode, we rely on the hotcode replacement feature of eclipse/jvm
                    // otherwise, for run and profile modes we explicitly publish the bundle module
                    
                    // TODO: make this configurable as part of the server config
                    
                    // SLING-3655 : when doing PUBLISH_CLEAN, the bundle deployment mechanism should 
                    // still be triggered
                    publishBundleModule(module, monitor);
                }
            } else if (ProjectHelper.isContentProject(module[0].getProject())) {
    
                try {
                    publishContentModule(kind, deltaKind, module, monitor);
                } catch (SerializationException e) {
                    throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Serialization error for "
                            + traceOperation(kind, deltaKind, module).toString(), e));
                } catch (IOException e) {
                    throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "IO error for "
                            + traceOperation(kind, deltaKind, module).toString(), e));
                }
            }
        } catch (CoreException e) {
            // in case of errors always require full redeployment of the whole module
            setModulePublishState(module, IServer.PUBLISH_STATE_FULL);
            throw e;
        }
    }