private void publishBundleModule()

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


	private void publishBundleModule(IModule[] module, IProgressMonitor monitor) throws CoreException {
		final IProject project = module[0].getProject();
        boolean installLocally = getServer().getAttribute(ISlingLaunchpadServer.PROP_INSTALL_LOCALLY, true);
		monitor.beginTask("deploying via local install", 5);

        try (OsgiClient osgiClient = Activator.getDefault().getOsgiClientFactory()
                .createOsgiClient(ServerUtil.getRepositoryInfo(getServer(), monitor))) {

            Version supportBundleVersion = osgiClient
                    .getBundleVersion(SUPPORT_INSTALL_BUNDLE_SYMBOLIC_NAME);
            monitor.worked(1);
            if (supportBundleVersion == null) {
                throw new CoreException(new Status(Status.ERROR, Activator.PLUGIN_ID,
                        "The support bundle was not found, please install it via the server properties page."));
            }

            IJavaProject javaProject = ProjectHelper.asJavaProject(project);

            IFolder outputFolder = (IFolder) project.getWorkspace().getRoot().findMember(javaProject.getOutputLocation());
            IPath outputLocation = outputFolder.getLocation();
            //ensure the MANIFEST.MF exists - if it doesn't then let the publish fail with a warn (instead of an error)
            IResource manifest = outputFolder.findMember("META-INF/MANIFEST.MF");
            if (manifest==null) {
                Activator.getDefault().getPluginLogger().warn("Project "+project+" does not have a META-INF/MANIFEST.MF (yet) - not publishing this time");
                monitor.done();
                setModulePublishState(module, IServer.PUBLISH_STATE_FULL);
                return;
            }
            
            monitor.worked(1);

            //TODO SLING-3767:
            //osgiClient must have a timeout!!!
            if (installLocally) {
                osgiClient.installBundle(outputLocation.toFile().toPath());
                monitor.worked(3);
            } else {

                JarBuilder builder = new JarBuilder(outputFolder);
                monitor.worked(1);
                try (InputStream bundleInput = builder.buildJar()) {
                	osgiClient.installBundle(bundleInput, builder.getBundleSymbolicName());
                }
                monitor.worked(2);
            }

            setModulePublishState(module, IServer.PUBLISH_STATE_NONE);

        } catch (IOException|URISyntaxException e1) {
            throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e1.getMessage(), e1));
        } catch (OsgiClientException e1) {
            throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed installing bundle : "
                    + e1.getMessage(), e1));
		} finally {
            monitor.done();
        }
	}