Jetty
  1. Jetty
  2. JETTY-1491

jetty-maven-plugin ignores <useTestClasspath> and/or <userTestScope> since 7.5.2.v20111006 and 8.0.3.v20111011

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 7.5.2, 7.5.3, 7.5.4, 7.6.0, 7.6.1, 8.0.3, 8.0.4, 8.1.0
    • Fix Version/s: 7.6.2, 8.1.2
    • Component/s: Maven
    • Labels:
      None
    • Environment:
    • Testcase included:
      yes
    • Number of attachments :
      1

      Description

      The 7.5.2 and 8.0.3 releases of the jetty-maven-plugin have broken the useTestClasspath and/or useTestScope options.

      The attached sample project illustrates the issue through a couple of JUnit test cases which use httpclient to connect to a jetty instance started through the maven plugin (using Class.forName to resolve classes from different scopes).

      I believe the problem is due to using the combination of the following in JettyRunMojo.java:

      JettyRunMojo.java:57
      /* 
       * @requiresDependencyResolution compile+runtime
       */
      

      and

      JettyRunMojo.java:437
      for ( Iterator<Artifact> iter = projectArtifacts.iterator(); iter.hasNext(); )
      {
          // snip
          if (((!Artifact.SCOPE_PROVIDED.equals(artifact.getScope())) && (!Artifact.SCOPE_TEST.equals( artifact.getScope())))
                         ||
                     (useTestClasspath && Artifact.SCOPE_TEST.equals( artifact.getScope())))
                 {
                 }
      }
      

      It appears that the for loop is assuming all artifacts will be available, and attempting to filter out the test dependencies if useTestScope is specified. However, since the @requireDependencyResolution doesn't include +test, these aren't available.

      I haven't had a chance to verify this (hence no patch to offer just yet) - but I'll try and get something sorted out to confirm this in the next few days (unless someone on the other end can verify ahead of time).

        Activity

        Jan Bartel made changes -
        Field Original Value New Value
        Assignee Jan Bartel [ janb ]
        Hide
        Jan Bartel added a comment -

        Martin,

        Which version of maven are you using? I tried your test case and it seems to work for me with no errors produced, so I suspect it is a difference of maven version. My version is 3.0.3.

        That said, it may be better if I change the dependencyResolution to "test" instead ... I'll have a read and fiddle with that and get back to you.

        Jan

        Show
        Jan Bartel added a comment - Martin, Which version of maven are you using? I tried your test case and it seems to work for me with no errors produced, so I suspect it is a difference of maven version. My version is 3.0.3. That said, it may be better if I change the dependencyResolution to "test" instead ... I'll have a read and fiddle with that and get back to you. Jan
        Hide
        Martin Lau added a comment -

        Originally, this was tested with 3.0.4.

        I've just repeated with 3.0.3 (OS X's standard install) and it shows the same problem with:

                <jetty-maven-plugin.version>7.5.2.v20111006</jetty-maven-plugin.version>
        

        Might be worth noting that the pom.xml that was added to this issue had the version set to be a working version of the jetty plugin (probably a bit of bad form from my end). If you look at the end of the pom.xml, there are a bunch of properties listing good and bad versions.

        Martin

        Show
        Martin Lau added a comment - Originally, this was tested with 3.0.4. I've just repeated with 3.0.3 (OS X's standard install) and it shows the same problem with: <jetty-maven-plugin.version>7.5.2.v20111006</jetty-maven-plugin.version> Might be worth noting that the pom.xml that was added to this issue had the version set to be a working version of the jetty plugin (probably a bit of bad form from my end). If you look at the end of the pom.xml, there are a bunch of properties listing good and bad versions. Martin
        Hide
        Jan Bartel added a comment -

        I've modified the @requiresDependencyResolution to be "test" for the jetty:run and jetty:start mojos. I can see the test scope dependencies being placed on the webapp's classpath with both your test and also just running at the command line.

        thanks
        Jan

        Show
        Jan Bartel added a comment - I've modified the @requiresDependencyResolution to be "test" for the jetty:run and jetty:start mojos. I can see the test scope dependencies being placed on the webapp's classpath with both your test and also just running at the command line. thanks Jan
        Jan Bartel made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 7.6.2 [ 18352 ]
        Fix Version/s 8.1.2 [ 18351 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Jan Bartel
            Reporter:
            Martin Lau
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: