If you open your garbled images in a hex editor, you will probably
notice a few tokens were replaced by Maven filtering. You should run
strings on the corrupted file just to see what's in it. ;-)

Assume the random bits in a JPG just happened to align with a Maven
token like ${buildDirectory}, it would be replaced by
c:\projects\maven\projA or whatever, thus corrupting the image.

Moving these types of resources to a non-filtered directory is the
best approach.

Wayne

On 5/4/06, Edelson, Justin <[EMAIL PROTECTED]> wrote:
> Also just as a side note...I tried making the jar from scratch using
just
> the jar command and everything is fine. (But it'd still be really nice
to
> use mvn to do it instead...)

I assum you're running jar on the contents of src/main/resources, which
isn't what maven is doing. Take a look at target/classes. Your images
are probably garbled there as well.

It appears to me that the garbeling happens when the resources plugin is
executed and the directory is being filtered. While the resources plugin
could be modified to detect if a file was of a particular type and
choose to filter or not filter based on the type, this doesn't scale
well (and could have some serious performance impact on projects with a
lot of resources). Although it's slightly more onerous for the pom
writer, the best solution (and the one that works now) would be to use a
separate resources directory for resources that shouldn't be filtered.

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
      <resource>
        <directory>src/main/images</directory>
        <filtering>false</filtering> <!-- not actually necessary as
false is the default -->
      </resource>
    </resources>
  </build>

If you absolutely needed to put all the resources in the same directory,
you could also accomplish this with includes/excludes:

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
        <excludes>
                <exclude>**/*.jpg</exclude>
                <exclude>**/*.gif</exclude>
                <exclude>**/*.png</exclude>
        </excludes>
      </resource>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>false</filtering>
        <includes>
                <include>**/*.jpg</include>
                <include>**/*.gif</include>
                <include>**/*.png</include>
        </includes>
      </resource>
    </resources>
  </build>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to