Cactus
  1. Cactus
  2. CACTUS-132

Allow cactus plugin to include some resources

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.7
    • Component/s: Maven Integration
    • Labels:
      None

      Description

      In a project I produce a jar artifact. I have a webapp in my src/test/webapp directory. I need to include some resources in the war for the cactus test as junit does.

      As Vincent answers me :
      > Is there a way to include build resources and test resources in the
      > webapp during a cactus test ?

      ... I guess the Cactus
      plugin could copy some resources. However, the resources that Cactus would
      copy (during the cactifywar step) would need to be defined as properties
      (and not in the POM as there's not way currently to extend the POM and I
      think we shouldn't reuse the junit resources which are for pure JUnit
      tests).

      1. CACTUS-132-felipeal.patch
        11 kB
        Felipe Leme
      2. CACTUS-132-felipeal.patch2
        12 kB
        Felipe Leme
      3. CACTUS-132-nchalumeau.patch
        8 kB
        Nicolas Chalumeau
      4. changes.xml.diff
        1 kB
        Nicolas Chalumeau
      5. plugin.jelly.diff
        0.9 kB
        Nicolas Chalumeau
      6. plugin.properties.diff
        0.6 kB
        Nicolas Chalumeau
      7. project.xml.diff
        0.8 kB
        Nicolas Chalumeau
      8. properties.xml.diff
        0.8 kB
        Nicolas Chalumeau
      9. test06.zip
        7 kB
        Nicolas Chalumeau
      10. webjar.zip
        6 kB
        Nicolas Chalumeau

        Activity

        Hide
        Nicolas Chalumeau added a comment -

        Add a patch.

        Show
        Nicolas Chalumeau added a comment - Add a patch.
        Hide
        Vincent Massol added a comment -

        Cool. Thanks Nicolas. Could you please also add the associated changes for properties.xml, changes.xml and plugin.properties? (and also mabye for project.xml to add you as a contributor )?

        Show
        Vincent Massol added a comment - Cool. Thanks Nicolas. Could you please also add the associated changes for properties.xml, changes.xml and plugin.properties? (and also mabye for project.xml to add you as a contributor )?
        Hide
        Nicolas Chalumeau added a comment -

        Here is a sample application that use strutstestcase. This example shows how to test a jar who contains struts action and need some file in the webapp classpath.

        I will attach other files toonight

        Show
        Nicolas Chalumeau added a comment - Here is a sample application that use strutstestcase. This example shows how to test a jar who contains struts action and need some file in the webapp classpath. I will attach other files toonight
        Hide
        Nicolas Chalumeau added a comment -

        done.
        The changes.xml patch fix a </action> without opening tag <action>

        Show
        Nicolas Chalumeau added a comment - done. The changes.xml patch fix a </action> without opening tag <action>
        Hide
        Felipe Leme added a comment -

        I will apply the changes.

        Show
        Felipe Leme added a comment - I will apply the changes.
        Hide
        Felipe Leme added a comment -

        Here is a condensed patch with all the changes, plus a test case and additional check if the directory exists.
        I haven't commit it though, for a reason: once this new properties gets through, users will expect a mechanismo to include/exclude files, probably using wildcards (like * and **). So, I change the property to cactus.resources.dirs, in a way that would allow us to add new properties in the future (like cactus.resources.includes and cactus.resources.excludes). Note that this is not as straightfoward as having this info in the POM, as we cannot have individual includes/excludes for each directory.

        Anyway, I will commit (or not) the changes once I get some feedback on this comment.

        – Felipe

        PS: another improvement that could be made would be not relying on maven.build.dest and including the resources directly from inside the <cactifywar> tag. But I'm not sure if that would work (besides I haven't the spare cycles to check it right now

        Show
        Felipe Leme added a comment - Here is a condensed patch with all the changes, plus a test case and additional check if the directory exists. I haven't commit it though, for a reason: once this new properties gets through, users will expect a mechanismo to include/exclude files, probably using wildcards (like * and **). So, I change the property to cactus.resources.dirs, in a way that would allow us to add new properties in the future (like cactus.resources.includes and cactus.resources.excludes). Note that this is not as straightfoward as having this info in the POM, as we cannot have individual includes/excludes for each directory. Anyway, I will commit (or not) the changes once I get some feedback on this comment. – Felipe PS: another improvement that could be made would be not relying on maven.build.dest and including the resources directly from inside the <cactifywar> tag. But I'm not sure if that would work (besides I haven't the spare cycles to check it right now
        Hide
        Felipe Leme added a comment -

        Polished some documentation and updated with CVS (because of CACTUS-132 fix).

        Show
        Felipe Leme added a comment - Polished some documentation and updated with CVS (because of CACTUS-132 fix).
        Hide
        Nicolas Chalumeau added a comment -

        Add the global patch.
        The following properties are add :

        1. (optional). List of resources label to include in the war classpath
          cactus.resources.dirs=
        1. (optional). Label directory to include in the war classpath
          #cactus.resources.X.dir=src/main/resources
        1. (optional). Regular expression for the label X that file have to match to be include in the war classpath. by default */
          #cactus.resources.X.includes=*.xml,*.dtd
        1. (optional). Regular expression for the label X that file have to match to be exclude in the war classpath. by default none
          #cactus.resources.X.excludes=

        The includes/excludes regexp work and allow "recursive" includes by default.

        test follow

        Show
        Nicolas Chalumeau added a comment - Add the global patch. The following properties are add : (optional). List of resources label to include in the war classpath cactus.resources.dirs= (optional). Label directory to include in the war classpath #cactus.resources.X.dir=src/main/resources (optional). Regular expression for the label X that file have to match to be include in the war classpath. by default * / #cactus.resources.X.includes=* .xml, *.dtd (optional). Regular expression for the label X that file have to match to be exclude in the war classpath. by default none #cactus.resources.X.excludes= The includes/excludes regexp work and allow "recursive" includes by default. test follow
        Hide
        Nicolas Chalumeau added a comment -

        I can't include this in the global patch so this is the zip of the test case.

        I find something strange :

        • when i am in the test06 dir and i launch cactus:test, the test are okay
        • but when i am in maven dir and launch plugin:test, the test fail

        In fact i see this before. The reactor seem to use for relative path it use as base path maven. ie :
        When the copy of resource it looks for .../integration/maven/target/classes/test.properties and not for .../integration/maven/src/plugin-test/test06/target/classes/test.properties for the target dir

        That's why plugin:test fail. Can't the pluginTest use the maven:maven tag could solve it ?

        Nicolas,

        Show
        Nicolas Chalumeau added a comment - I can't include this in the global patch so this is the zip of the test case. I find something strange : when i am in the test06 dir and i launch cactus:test, the test are okay but when i am in maven dir and launch plugin:test, the test fail In fact i see this before. The reactor seem to use for relative path it use as base path maven. ie : When the copy of resource it looks for .../integration/maven/target/classes/test.properties and not for .../integration/maven/src/plugin-test/test06/target/classes/test.properties for the target dir That's why plugin:test fail. Can't the pluginTest use the maven:maven tag could solve it ? Nicolas,
        Hide
        Felipe Leme added a comment -

        Applied patch with minor documentation changes.

        Show
        Felipe Leme added a comment - Applied patch with minor documentation changes.

          People

          • Assignee:
            Felipe Leme
            Reporter:
            Nicolas Chalumeau
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development