if (roots == null || roots.length == 0) {
handleApplicationDeploymentFailure(Messages.JavaCloudFoundryArchiver_ERROR_NO_PACKAGE_FRAG_ROOTS);
}
JarPackageData jarPackageData = getJarPackageData(roots, mainType,
monitor);
boolean isBoot = isBootProject(javaProject);
// Search for existing MANIFEST.MF
IFile metaFile = getManifest(roots, javaProject);
// Only use existing manifest files for non-Spring boot, as Spring
// boot repackager will
// generate it own manifest file.
if (!isBoot && metaFile != null) {
// If it is not a boot project, use a standard library jar
// builder
jarPackageData.setJarBuilder(getDefaultLibJarBuilder());
jarPackageData.setManifestLocation(metaFile.getFullPath());
jarPackageData.setSaveManifest(false);
jarPackageData.setGenerateManifest(false);
// Check manifest accessibility through the jar package data
// API
// to verify the packaging won't fail
if (!jarPackageData.isManifestAccessible()) {
handleApplicationDeploymentFailure(NLS
.bind(Messages.JavaCloudFoundryArchiver_ERROR_MANIFEST_NOT_ACCESSIBLE,
metaFile.getLocation().toString()));
}
InputStream inputStream = null;
try {
inputStream = new FileInputStream(metaFile.getLocation()
.toFile());
Manifest manifest = new Manifest(inputStream);
Attributes att = manifest.getMainAttributes();
if (att.getValue("Main-Class") == null) { //$NON-NLS-1$
handleApplicationDeploymentFailure(Messages.JavaCloudFoundryArchiver_ERROR_NO_MAIN_CLASS_IN_MANIFEST);
}
} catch (FileNotFoundException e) {
handleApplicationDeploymentFailure(NLS
.bind(Messages.JavaCloudFoundryArchiver_ERROR_FAILED_READ_MANIFEST,
e.getLocalizedMessage()));
} catch (IOException e) {
handleApplicationDeploymentFailure(NLS
.bind(Messages.JavaCloudFoundryArchiver_ERROR_FAILED_READ_MANIFEST,
e.getLocalizedMessage()));
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException io) {
// Ignore
}
}
}
} else {
// Otherwise generate a manifest file. Note that manifest files
// are only generated in the temporary jar meant only for
// deployment.
// The associated Java project is no modified.
jarPackageData.setGenerateManifest(true);
// This ensures that folders in output folders appear at root
// level
// Example: src/main/resources, which is in the project's
// classpath, contains non-Java templates folder and
// has output folder target/classes. If not exporting output
// folder,
// templates will be packaged in the jar using this path:
// resources/templates
// This may cause problems with the application's dependencies
// if they are looking for just /templates at top level of the
// jar
// If exporting output folders, templates folder will be
// packaged at top level in the jar.
jarPackageData.setExportOutputFolders(true);
}
try {
packagedFile = packageApplication(jarPackageData, monitor);
} catch (CoreException e) {