Java

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • OT - Maven woes

    14 answers - 4163 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    How the hell did anyone convince anyone else to use this crap?!
    With that off my chest - I *have to* use mvn2 on my current project,
    anyone have experience getting maven to actually do anything useful?
    I don't know maven well and I'm happy to concede that I may be a
    witless luser, and if someone can hit me with a cluebat, please do,
    but until that moment I have to say that my experience with mvn is
    completely negative.
    All I want to do is:
    1 - get build time (like Ant's <tstamp>) in a particular format
    2 - and write this value into the manifest of the created jar.
    This should not take me 1 week and still be no closer to getting a
    result. Regardless of mavens other qualities (dependency management),
    the fact that I cannot find the documentation that I need to solve
    this problem, the fact that parts of the maven website are 404, the
    fact that I cannot search the mailing list archives (no MARC, just
    some nabble.com thing), the fact that the FAQ is missing answers
    the list of documentation problems is endless with maven - I now think
    Ant's docs are fantastic.
    I'm truly at my wit's end regarding such a simple task, here is what I
    currently have in my pom.xml:
    <build>
    <filters>
    <filter>build.properties</filter>
    </filters>
    <resources>
    <resource>
    <!-- required for some reason to get
    filtering working
    <directory>src/main/resources</directory>
    <filtering>true</filtering>
    </resource>
    </resources>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
    <execution>
    <phase>process-classes</phase>
    <configuration>
    <tasks>
    <tstamp>
    <!-- 2006-08-19 15:32:04
    <format property="last.updated" pattern="yyyy-MM-dd hh:mm:ss"/>
    </tstamp>
    <echo file="build.properties" message="build.time=${last.updated}"/>
    <!--
    sanity check - yep ant works fine, thankfully
    <echo message="[build.properties] - updated with : ${last.updated}"/>
    </tasks>
    </configuration>
    <goals>
    <goal>run</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
    <archive>
    <manifestEntries>
    <!-- inserts the correct entry in the manifest, but
    <!-- so far no luck on getting the build time
    <Built-Time>XXX - ${build.time}</Built-Time>
    </manifestEntries>
    </archive>
    </configuration>
    <executions>
    <execution>
    <goals>
    <goal>jar</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
    Basically I want to set a property build.time, and reference it later.
    As it seems that you can only specify hard-coded properties in the
    pom (why oh why?!), I decided to get around this by getting ant to
    spit out the correct value into a props file, then use mavens
    filter/resources to pull in this new value and then reference it with
    ${build.time} in the appropriate place.
    course it doesn't work due to - what, I don't know, is it the goal,
    the phase that it executes in? Basically the docs don't tell me
    enough, and neither does the debug, and google-fu has failed me too.
    I know some of the maven devs lurk here (from time to time), if any of
    them could shed some light on this.
    Do I have to write a <tstampplugin (mojo?) for this?
    This has to be the second most frustrating piece of software I've
    encountered - right after
    Kev
    To unsubscribe, e-mail: dev-unsubscribe (AT) ant (DOT) apache.org
    For additional commands, e-mail: dev-help (AT) ant (DOT) apache.org
  • No.1 | | 1142 bytes | |

    15/09/06, Kevin Jackson <foamdino (AT) gmail (DOT) comwrote:
    How the hell did anyone convince anyone else to use this crap?!

    Well, since you asked so nicely :)

    I'm truly at my wit's end regarding such a simple task, here is what I
    currently have in my pom.xml:

    If you use ant tasks, you can only use them with other ant tasks. The
    ant properties are not fed back into the Maven build by the antrun
    plugin.

    So, you'll need to filter it into the file using your own <copy /task.

    I know some of the maven devs lurk here (from time to time), if any of
    them could shed some light on this.

    You'll likely get more help on users (AT) maven (DOT)

    Do I have to write a <tstampplugin (mojo?) for this?

    That's another option.

    This has to be the second most frustrating piece of software I've
    encountered - right after

    Well now, that comparison is just mean! :)
    - Brett

    To unsubscribe, e-mail: dev-unsubscribe (AT) ant (DOT) apache.org
    For additional commands, e-mail: dev-help (AT) ant (DOT) apache.org
  • No.2 | | 2437 bytes | |

    15/09/06, Kevin Jackson <foamdino (AT) gmail (DOT) comwrote:
    How the hell did anyone convince anyone else to use this crap?!

    Well, since you asked so nicely :)

    Thanks for taking the abuse in the (semi) light-hearted manner it was
    dished out in! Truly I didn't want to cause too much upset, but I
    wanted to express that there are some major documentation problems

    I'm truly at my wit's end regarding such a simple task, here is what I
    currently have in my pom.xml:

    If you use ant tasks, you can only use them with other ant tasks. The
    ant properties are not fed back into the Maven build by the antrun
    plugin.

    So, you'll need to filter it into the file using your own <copy /task.

    You see I've read pretty much every doc available on the web about
    maven properties and *none* mentioned that the ant properties are only
    available in the antrun plugin - that may be worth adding to the FAQ.

    And with the antrun plugin, ok I can get <tstampto generate the
    value I'm after, and I can use copy/replace to filter it into the
    file, but what phase/goal do I need to set so that ant will execute
    before the jar file is built? I thought process-classes as
    process-resources seems to occur before compilation.

    I know some of the maven devs lurk here (from time to time), if any of
    them could shed some light on this.

    You'll likely get more help on users (AT) maven (DOT)

    That was my next step, but I wanted to ask here for 2 reasons:

    a - I knew you lurked here and I thought I may get a faster response
    (and after a week of flailing about, I need this resolved quickly)
    b - the other ant devs have probably come across maven stuff in their
    day jobs and they can explain stuff to me in an 'ant' way

    Do I have to write a <tstampplugin (mojo?) for this?

    That's another option.

    Well if that's what it's going to take /rolls sleeves up/

    --
    This has to be the second most frustrating piece of software I've
    encountered - right after

    Well now, that comparison is just mean! :)

    , I retract that bit :). Thanks for responding to my flamebait.

    Kev

    To unsubscribe, e-mail: dev-unsubscribe (AT) ant (DOT) apache.org
    For additional commands, e-mail: dev-help (AT) ant (DOT) apache.org
  • No.3 | | 990 bytes | |

    15/09/06, Kevin Jackson <foamdino (AT) gmail (DOT) comwrote:
    And with the antrun plugin, ok I can get <tstampto generate the
    value I'm after, and I can use copy/replace to filter it into the
    file, but what phase/goal do I need to set so that ant will execute
    before the jar file is built? I thought process-classes as
    process-resources seems to occur before compilation.

    Anything before 'package' is fine, with process-resources being the
    most sensible. Just as long as you aren't overwriting it again with
    the resources plugin itself.

    Your best bet is probably to generate a filter.properties in the
    "generate-resources" phase that has the value, then use the filtering
    you had configured to copy the resource itself.

    Here's a working example:
    - Brett

    To unsubscribe, e-mail: dev-unsubscribe (AT) ant (DOT) apache.org
    For additional commands, e-mail: dev-help (AT) ant (DOT) apache.org
  • No.4 | | 1389 bytes | |

    Here's a working example:

    Hi, thanks for the cookbook example.

    My problem now is that if I use filtering, I get exceptions thrown
    during testing, these exceptions aren't thrown if I remove the
    filter/resources sections from my pom. Is this a known issue? Is
    there anything I have to do to get my tests to pass without throwing
    exceptions?

    some output:

    at (Launcher.java:375)
    java.util.zip.ZipException: oversubscribed literal/length tree
    at (InflaterInputStream.java:140)
    at (BufferedInputStream.java:218)
    at (BufferedInputStream.java:235)
    at java.io.FilterInputStream.read(FilterInputStream.j ava:66)
    at (PNGImageReader.
    java:1165)
    at (PNGImageReader
    java:1276)
    at (PNGImageReader.j
    ava:1362)
    at (PNGImageReader.java:1
    579)
    at javax.imageio.ImageI(ImageI:1400)
    at javax.imageio.ImageI(ImageI:1322)
    at (ImageFile.java:101)
    at <init>(ImageFile.java:63)
    at (ImageF
    ileTest.java:18)

    As I said, if I remove the resources/filters from the pom, the tests
    pass, so there's something fishy going on when maven uses filters.

    Thanks for your help so far (btw what time is it for you?)

    Kev

    To unsubscribe, e-mail: dev-unsubscribe (AT) ant (DOT) apache.org
    For additional commands, e-mail: dev-help (AT) ant (DOT) apache.org
  • No.5 | | 1841 bytes | |

    The example basically does "copy everything from src/main/resources
    with filters". I assume you have images in there too.

    You should setup a separate resource directory for filtering - maybe
    replace the one in the example with src/main/filtered-resources. ,
    you can add an includes or excludes to the one in the example.

    It's 4pm here (Sydney, Australia).
    - Brett

    15/09/06, Kevin Jackson <foamdino (AT) gmail (DOT) comwrote:
    Here's a working example:

    Hi, thanks for the cookbook example.

    My problem now is that if I use filtering, I get exceptions thrown
    during testing, these exceptions aren't thrown if I remove the
    filter/resources sections from my pom. Is this a known issue? Is
    there anything I have to do to get my tests to pass without throwing
    exceptions?

    some output:

    at (Launcher.java:375)
    java.util.zip.ZipException: oversubscribed literal/length tree
    at (InflaterInputStream.java:140)
    at (BufferedInputStream.java:218)
    at (BufferedInputStream.java:235)
    at java.io.FilterInputStream.read(FilterInputStream.j ava:66)
    at (PNGImageReader.
    java:1165)
    at (PNGImageReader
    .java:1276)
    at (PNGImageReader.j
    ava:1362)
    at (PNGImageReader.java:1
    579)
    at javax.imageio.ImageI(ImageI:1400)
    at javax.imageio.ImageI(ImageI:1322)
    at (ImageFile.java:101)
    at <init>(ImageFile.java:63)
    at (ImageF
    ileTest.java:18)

    As I said, if I remove the resources/filters from the pom, the tests
    pass, so there's something fishy going on when maven uses filters.

    Thanks for your help so far (btw what time is it for you?)

    Kev

    To unsubscribe, e-mail: dev-unsubscribe (AT) ant (DOT) apache.org
    For additional commands, e-mail: dev-help (AT) ant (DOT) apache.org
    --
  • No.6 | | 1673 bytes | |

    The example basically does "copy everything from src/main/resources
    with filters". I assume you have images in there too.

    No, I just checked, it's a common library that is re-used for
    different web-apps, but it doensn't contain any images, but then with
    the filtering switched on, all the images based tests break.

    You should setup a separate resource directory for filtering - maybe
    replace the one in the example with src/main/filtered-resources. ,
    you can add an includes or excludes to the one in the example.

    ok, I did as suggested and added a src/main/filter-resources dir and
    modified the pom, I'm now getting NullPointerException (s), something
    fishy is definately happening with filters/resources:

    Battery:

    Tests run: 7, Failures: 1, Errors: 0, Time elapsed: 0.016 sec

    class ()
    Time elapsed: 0 sec <<< FAILURE!

    [ stdout ]

    [ stderr ]

    [ stacktrace ]

    java.lang.NullPointerException
    at (IUtils.java:996)
    at (IUtils.java:217)
    at (File.java:325)
    at (ImageFileTest.java:18)
    at (ColorTest.java:61)
    at (Native Method)
    at ()
    at ()
    at (Method.java:585)
    at (AbstractBattery.java:124)
    at (AbstractBattery.java:70)
    at (AbstractBattery.java:49)
    at (JUnitBattery.java:220)
    at (Surefire.java:215)
    at (Surefire.java:163)
    at (Surefire.java:87)

    It's 4pm here (Sydney, Australia).

    , I'm not keeping you up at some ridiculous hour

    Kev

    To unsubscribe, e-mail: dev-unsubscribe (AT) ant (DOT) apache.org
    For additional commands, e-mail: dev-help (AT) ant (DOT) apache.org
  • No.7 | | 2066 bytes | |

    Did you run a clean after the change to make sure the bogus filtered
    resources got copied again properly?

    Sorry, but I'm not sure I can help much more as that's inside the
    custom test cases.
    - Brett

    15/09/06, Kevin Jackson <foamdino (AT) gmail (DOT) comwrote:
    The example basically does "copy everything from src/main/resources
    with filters". I assume you have images in there too.

    No, I just checked, it's a common library that is re-used for
    different web-apps, but it doensn't contain any images, but then with
    the filtering switched on, all the images based tests break.
    --
    You should setup a separate resource directory for filtering - maybe
    replace the one in the example with src/main/filtered-resources. ,
    you can add an includes or excludes to the one in the example.
    --
    ok, I did as suggested and added a src/main/filter-resources dir and
    modified the pom, I'm now getting NullPointerException (s), something
    fishy is definately happening with filters/resources:

    Battery:

    Tests run: 7, Failures: 1, Errors: 0, Time elapsed: 0.016 sec

    class ()
    Time elapsed: 0 sec <<< FAILURE!

    [ stdout ]
    >
    >
    >

    [ stderr ]
    >
    >
    >

    [ stacktrace ]

    java.lang.NullPointerException
    at (IUtils.java:996)
    at (IUtils.java:217)
    at (File.java:325)
    at (ImageFileTest.java:18)
    at (ColorTest.java:61)
    at (Native Method)
    at ()
    at ()
    at (Method.java:585)
    at (AbstractBattery.java:124)
    at (AbstractBattery.java:70)
    at (AbstractBattery.java:49)
    at (JUnitBattery.java:220)
    at (Surefire.java:215)
    at (Surefire.java:163)
    at (Surefire.java:87)

    It's 4pm here (Sydney, Australia).

    , I'm not keeping you up at some ridiculous hour

    Kev

    To unsubscribe, e-mail: dev-unsubscribe (AT) ant (DOT) apache.org
    For additional commands, e-mail: dev-help (AT) ant (DOT) apache.org
    --
  • No.8 | | 1106 bytes | |

    Did you run a clean after the change to make sure the bogus filtered
    resources got copied again properly?

    not sure what you mean by bogus, but I did this:

    mvn clean package

    Sorry, but I'm not sure I can help much more as that's inside the
    custom test cases.

    The thing is that the problem disappears completely when the filters
    are removed - the JUnit tests all pass when I remove the filters. So
    my guess is that something is happening in maven when the filters run
    which affects the interaction with the 'surefire' plugin in some way

    Just FYI, we are using commons IUtils in the tests.

    I'll try to track down the exact cause. If you're sure that the pom
    is right (based on the cookbook example), then the problem must be in
    the structure of the application, or something else that only affects
    the build when filtering is true

    Thanks so far
    Kev

    To unsubscribe, e-mail: dev-unsubscribe (AT) ant (DOT) apache.org
    For additional commands, e-mail: dev-help (AT) ant (DOT) apache.org
  • No.9 | | 633 bytes | |

    Sorry, but I'm not sure I can help much more as that's inside the
    custom test cases.

    Hi, sorry to bother you again,

    The problem is related to a single image in the src/test/resources
    directory. When I use filters, it seems that this file is no longer
    copied to the correct location for when surefire runs the unit tests.

    My guess is that I need to specify a <resourcesblock in the pom
    which includes graphics files (.png)

    Kev

    To unsubscribe, e-mail: dev-unsubscribe (AT) ant (DOT) apache.org
    For additional commands, e-mail: dev-help (AT) ant (DOT) apache.org
  • No.10 | | 902 bytes | |

    I was able to add test resources without changing the PM and they
    were correctly copied (unfiltered). Do you have a <testResources>
    element in the PM that might be interfering with it?

    15/09/06, Kevin Jackson <foamdino (AT) gmail (DOT) comwrote:
    Sorry, but I'm not sure I can help much more as that's inside the
    custom test cases.
    --
    Hi, sorry to bother you again,

    The problem is related to a single image in the src/test/resources
    directory. When I use filters, it seems that this file is no longer
    copied to the correct location for when surefire runs the unit tests.

    My guess is that I need to specify a <resourcesblock in the pom
    which includes graphics files (.png)

    Kev

    To unsubscribe, e-mail: dev-unsubscribe (AT) ant (DOT) apache.org
    For additional commands, e-mail: dev-help (AT) ant (DOT) apache.org
    --
  • No.11 | | 1343 bytes | |

    Hi Brett,

    Thanks for taking the time to trouble-shoot this - I *really*
    appreciate all the help so far.

    I've fixed the missing resource problem, but the Manifest file is
    still not being updated in the jar file.

    I have a Manifest.mf file in my src/main/resources dir, it is being
    updated with the build time correctly (and put in
    target/classes/META-INF. I now want this to be used in the jar
    plugin:

    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
    <archive>
    <manifestEntries>
    <Build-Time- ${build.time}</Build-Time>
    </manifestEntries>
    </archive>
    </configuration>
    <executions>
    <execution>
    <goals>
    <goal>jar</goal>
    </goals>
    </execution>
    </executions>
    </plugin>

    The jar plugin is simply creating a default manifest file and ignoring
    the resources file. What I really want is the src/main/resources
    Manifest.mf to be appended to the end of the auto-generated
    Manifest.mf

    Kev

    To unsubscribe, e-mail: dev-unsubscribe (AT) ant (DOT) apache.org
    For additional commands, e-mail: dev-help (AT) ant (DOT) apache.org
  • No.12 | | 1580 bytes | |

    Instead of the manifest entries (which you are filtering from your own
    manifest file), you can use the <manifestFileconfiguration to the
    JAR plugin (or do both).

    15/09/06, Kevin Jackson <foamdino (AT) gmail (DOT) comwrote:
    Hi Brett,

    Thanks for taking the time to trouble-shoot this - I *really*
    appreciate all the help so far.

    I've fixed the missing resource problem, but the Manifest file is
    still not being updated in the jar file.

    I have a Manifest.mf file in my src/main/resources dir, it is being
    updated with the build time correctly (and put in
    target/classes/META-INF. I now want this to be used in the jar
    plugin:

    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
    <archive>
    <manifestEntries>
    <Build-Time- ${build.time}</Build-Time>
    </manifestEntries>
    </archive>
    </configuration>
    <executions>
    <execution>
    <goals>
    <goal>jar</goal>
    </goals>
    </execution>
    </executions>
    </plugin>

    The jar plugin is simply creating a default manifest file and ignoring
    the resources file. What I really want is the src/main/resources
    Manifest.mf to be appended to the end of the auto-generated
    Manifest.mf

    Kev

    To unsubscribe, e-mail: dev-unsubscribe (AT) ant (DOT) apache.org
    For additional commands, e-mail: dev-help (AT) ant (DOT) apache.org
    --
  • No.13 | | 552 bytes | |

    Hi Brett,

    Just to let you know that I have managed to get the tstamp value into
    the manifest as required.

    I've left a note on the jira as the guide[1], you pointed me to is
    actually wrong[2]

    Finally although I may not like maven much, I have nothing but respect
    for the developers. Thanks for your expert help tracking this down.

    Kev

    [1] -
    [2] -

    To unsubscribe, e-mail: dev-unsubscribe (AT) ant (DOT) apache.org
    For additional commands, e-mail: dev-help (AT) ant (DOT) apache.org
  • No.14 | | 526 bytes | |

    Kevin Jackson wrote:
    Hi Brett,

    Just to let you know that I have managed to get the tstamp value into
    the manifest as required.

    I've left a note on the jira as the guide[1], you pointed me to is
    actually wrong[2]

    Kevin, you are free to provide patches :) I'm sure they'd welcome you as
    a committer before long too.
    -steve

    To unsubscribe, e-mail: dev-unsubscribe (AT) ant (DOT) apache.org
    For additional commands, e-mail: dev-help (AT) ant (DOT) apache.org

Re: OT - Maven woes


max 4000 letters.
Your nickname that display:
In order to stop the spam: 6 + 5 =
QUESTION ON "Java"

EMSDN.COM