Maven Archetype

images gif/jpgs etc seem to get corrupted when copied by archetype

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Duplicate
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: Plugin
  • Labels:
    None
  • Environment:
    windows XP
  • Number of attachments :
    0

Description

I created a web archetype to include images in the src/main/webapp directory.

They seem to copy over correctly and there size is reatined, but oddly the images view as blank when displayed in browser or image viewer.
I double checked to make sure the images I was using were ok and manually copied them over and everything worked fine. I have the images in the resources section in archetype.xml. Could be an encoding issue?

Issue Links

Activity

Hide
Carlos Sanchez added a comment -

Seems that the Archetype code uses FileWriter instead of FileOutputStream

http://jroller.com/page/RickHigh?entry=maven_archetype_woes

Show
Carlos Sanchez added a comment - Seems that the Archetype code uses FileWriter instead of FileOutputStream http://jroller.com/page/RickHigh?entry=maven_archetype_woes
Hide
Chris Funk added a comment -

I think it is a bit more complicated than that.

I did the following primitive hack to the process template method and still have the same issue, it seems there might be something about copying images out of a jar resource. Don't know didn't spend too much time on it:

if (template.endsWith(".jpg") || template.endsWith(".gif")) {
try {
template = ARCHETYPE_RESOURCES + "/" + template;
InputStream is = getStream(template, Thread.currentThread()
.getContextClassLoader());
OutputStream os = new FileOutputStream(f);
int ch; // the buffer
while ((ch = is.read()) != -1) { os.write(ch); }
is.close();
os.close();

} catch (Exception e) { getLogger().error("Could not copy image " + e.getMessage()); }
return;
}

this had the exact same result

Show
Chris Funk added a comment - I think it is a bit more complicated than that. I did the following primitive hack to the process template method and still have the same issue, it seems there might be something about copying images out of a jar resource. Don't know didn't spend too much time on it: if (template.endsWith(".jpg") || template.endsWith(".gif")) { try { template = ARCHETYPE_RESOURCES + "/" + template; InputStream is = getStream(template, Thread.currentThread() .getContextClassLoader()); OutputStream os = new FileOutputStream(f); int ch; // the buffer while ((ch = is.read()) != -1) { os.write(ch); } is.close(); os.close(); } catch (Exception e) { getLogger().error("Could not copy image " + e.getMessage()); } return; } this had the exact same result

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: