File outjar = openFile(outjarName);
ideManager.getProjectProperties().setOutJar(outjar.getAbsolutePath());
assertTrue("Build failed",doSynchronousBuild("config2.lst"));
- assertFalse("No build warnings",ideManager.getCompilationSourceLineTasks().isEmpty());
- List msgs = NullIdeManager.getIdeManager().getCompilationSourceLineTasks();
- assertTrue("Wrong message",((NullIdeTaskListManager.SourceLineTask)msgs.get(0)).message.getMessage().startsWith("manifest not copied: "));
+ assertTrue("Build warnings",ideManager.getCompilationSourceLineTasks().isEmpty());
compareJars(injar1,"src",outjar);
}
ideManager.getProjectProperties().setInJars(injars);
File outjar = openFile(outjarName);
ideManager.getProjectProperties().setOutJar(outjar.getAbsolutePath());
- assertFalse("Build should have failed",doSynchronousBuild("config2.lst"));
- assertFalse("No build errors",ideManager.getCompilationSourceLineTasks().isEmpty());
+ assertTrue("Build should have suceeded",doSynchronousBuild("config2.lst"));
+ assertFalse("Build warnings for duplicate resource expected",ideManager.getCompilationSourceLineTasks().isEmpty());
List msgs = NullIdeManager.getIdeManager().getCompilationSourceLineTasks();
- assertTrue("Wrong message",((NullIdeTaskListManager.SourceLineTask)msgs.get(1)).message.getMessage().startsWith("duplicate resource: "));
+ assertTrue("Wrong message",((NullIdeTaskListManager.SourceLineTask)msgs.get(0)).message.getMessage().startsWith("duplicate resource: "));
+ compareJars(injar1,"src",outjar);
}
public void testSrcToOutjar () {
injars.add(injar1);
ideManager.getProjectProperties().setInJars(injars);
assertTrue("Build failed",doSynchronousBuild("config2.lst"));
- assertFalse("No build warnings",ideManager.getCompilationSourceLineTasks().isEmpty());
- List msgs = NullIdeManager.getIdeManager().getCompilationSourceLineTasks();
- assertTrue("Wrong message",((NullIdeTaskListManager.SourceLineTask)msgs.get(0)).message.getMessage().startsWith("manifest not copied: "));
+ assertTrue("Build warnings",ideManager.getCompilationSourceLineTasks().isEmpty());
compareInjarsToBin(injar1,"src","bin");
}
for (int i = 0; i < toResources.length; i++) {
String fileName = FileUtil.normalizedPath(toResources[i],binBase);
boolean b = resources.remove(fileName);
- assertTrue("Extraneous resoures:" + fileName,b);
+ assertTrue("Extraneous resources: " + fileName,b);
}
- assertTrue("Missing resources:" + resources.toString(), resources.isEmpty());
+ assertTrue("Missing resources: " + resources.toString(), resources.isEmpty());
}
/*
String fileName = entry.getName();
if (!fileName.endsWith(".class")) {
- /* Ensure we didn't copy any JAR manifests */
- if (fileName.toLowerCase().startsWith("meta-inf")) {
+ /* Ensure we copied right JAR manifest */
+ if (fileName.equalsIgnoreCase("meta-inf/Manifest.mf")) {
byte[] outManifest = FileUtil.readAsByteArray(outjar);
- assertFalse("Manifest has been copied",Arrays.equals(inManifest,outManifest));
+ assertTrue("Wrong manifest has been copied",Arrays.equals(inManifest,outManifest));
}
boolean b = resources.remove(fileName);
}
outjar.close();
- assertTrue("Missing resources:" + resources.toString(), resources.isEmpty());
+ assertTrue("Missing resources: " + resources.toString(), resources.isEmpty());
}
catch (IOException ex) {
fail(ex.toString());
for (int i = 0; i < toResources.length; i++) {
String fileName = FileUtil.normalizedPath(toResources[i],binBase);
- /* Ensure we didn't copy any JAR manifests */
- if (fileName.toLowerCase().startsWith("meta-inf")) {
+ /* Ensure we copied the right JAR manifest */
+ if (fileName.equalsIgnoreCase("meta-inf/Manifest.mf")) {
byte[] outManifest = FileUtil.readAsByteArray(toResources[i]);
- assertFalse("Manifest has been copied",Arrays.equals(inManifest,outManifest));
+ assertTrue("Wrong manifest has been copied",Arrays.equals(inManifest,outManifest));
}
boolean b = resources.remove(fileName);
- assertTrue("Extraneous resoures:" + fileName,b);
+ assertTrue("Extraneous resources: " + fileName,b);
}
- assertTrue("Missing resources:" + resources.toString(), resources.isEmpty());
+ assertTrue("Missing resources: " + resources.toString(), resources.isEmpty());
}
catch (IOException ex) {
fail(ex.toString());
ZipEntry entry;
while (null != (entry = injar.getNextEntry())) {
String fileName = entry.getName();
- if (!fileName.endsWith(".class")) {
+ if (!entry.isDirectory() && !fileName.endsWith(".class")) {
/* JAR manifests shouldn't be copied */
- if (fileName.toLowerCase().startsWith("meta-inf")) {
+ if (fileName.equalsIgnoreCase("meta-inf/Manifest.mf")) {
manifest = FileUtil.readAsByteArray(injar);
}
- else {
- resources.add(fileName);
- }
+ resources.add(fileName);
}
injar.closeEntry();
}
this.addClassFile(classFile);
}
else if (!entry.isDirectory()) {
-// System.err.println("? addJarFile() filename='" + filename + "'");
-
- /* Don't copy JAR manifests */
- if (filename.toLowerCase().startsWith("meta-inf")) {
- world.showMessage(IMessage.WARNING, "manifest not copied: '" + filename +
- "' in JAR '" + inFile + "'", null, null);
- }
- else {
- addResource(filename,classFile);
- }
+
+ /* bug-44190 Copy meta-data */
+ addResource(filename,classFile);
}
inStream.closeEntry();
}
public void addResource (String name, UnwovenClassFile resourceFile) {
- Object previous = resources.put(name, resourceFile);
- if (null != previous) {
- world.showMessage(IMessage.ERROR, "duplicate resource: '" + name + "'",
+ /* bug-44190 Change error to warning and copy first resource */
+ if (!resources.containsKey(name)) {
+ resources.put(name, resourceFile);
+ }
+ else {
+ world.showMessage(IMessage.WARNING, "duplicate resource: '" + name + "'",
null, null);
}
}