Manifest.Attribute mainClass = new Manifest.Attribute();
mainClass.setName("Main-Class");
mainClass.setValue(task.getMainClass());
ManifestTask manifest = (ManifestTask) task.createSubtask(ManifestTask.class);
manifest.setFile(manifestFile);
try {
manifest.addConfiguredAttribute(mainClass);
} catch (ManifestException e) {
throw new BuildException("Manifest error", e);
}
manifest.execute();
}