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(EmbeddedArtifactLocator.SUPPORT_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");
Activator.getDefault().issueConsoleLog("InstallBundle", outputFolder.getLocation().toOSString(), "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.installLocalBundle(outputLocation.toOSString());
monitor.worked(3);
} else {
JarBuilder builder = new JarBuilder();
InputStream bundle = builder.buildJar(outputFolder);
monitor.worked(1);
osgiClient.installLocalBundle(bundle, outputFolder.getLocation().toOSString());
monitor.worked(2);
}
setModulePublishState(module, IServer.PUBLISH_STATE_NONE);