@@ -516,8 +516,6 @@ public class Jar extends Zip {
private Manifest createManifest()
private Manifest createManifest()
throws BuildException {
throws BuildException {
try {
try {
Manifest finalManifest = Manifest.getDefaultManifest();
if (manifest == null) {
if (manifest == null) {
if (manifestFile != null) {
if (manifestFile != null) {
// if we haven't got the manifest yet, attempt to
// if we haven't got the manifest yet, attempt to
@@ -526,6 +524,25 @@ public class Jar extends Zip {
}
}
}
}
// fileset manifest must come even before the default
// manifest if mergewithoutmain is selected and there is
// no explicit manifest specified - otherwise the Main
// section of the fileset manifest is still merged to the
// final manifest.
boolean mergeFileSetFirst = !mergeManifestsMain
&& filesetManifest != null
&& configuredManifest == null && manifest == null;
Manifest finalManifest;
if (mergeFileSetFirst) {
finalManifest = new Manifest();
finalManifest.merge(filesetManifest, false, mergeClassPaths);
finalManifest.merge(Manifest.getDefaultManifest(),
true, mergeClassPaths);
} else {
finalManifest = Manifest.getDefaultManifest();
}
/*
/*
* Precedence: manifestFile wins over inline manifest,
* Precedence: manifestFile wins over inline manifest,
* over manifests read from the filesets over the original
* over manifests read from the filesets over the original
@@ -537,7 +554,9 @@ public class Jar extends Zip {
if (isInUpdateMode()) {
if (isInUpdateMode()) {
finalManifest.merge(originalManifest, false, mergeClassPaths);
finalManifest.merge(originalManifest, false, mergeClassPaths);
}
}
finalManifest.merge(filesetManifest, false, mergeClassPaths);
if (!mergeFileSetFirst) {
finalManifest.merge(filesetManifest, false, mergeClassPaths);
}
finalManifest.merge(configuredManifest, !mergeManifestsMain,
finalManifest.merge(configuredManifest, !mergeManifestsMain,
mergeClassPaths);
mergeClassPaths);
finalManifest.merge(manifest, !mergeManifestsMain,
finalManifest.merge(manifest, !mergeManifestsMain,