Maven Dependency Plugin
  1. Maven Dependency Plugin
  2. MDEP-128

Support ability to specify multiple "includeScope" parameters

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-alpha-4
    • Fix Version/s: 2.8
    • Component/s: copy-dependencies
    • Labels:
      None
    • Number of attachments :
      0

      Description

      You can only configure the plugin with either one includeScope or one excludeScope. When executing the plugin to copy dependencies with the following configuration:

      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-dependency-plugin</artifactId>
         <executions>
            <execution>
               <id>copy-dependencies</id>
               <phase>validate</phase>
               <goals>
                  <goal>copy-dependencies</goal>
               </goals>
            </execution>
         </executions>
         <configuration>
            <outputDirectory>/src/main/webapp/WEB-INF/lib</outputDirectory> 
            <overWriteReleases>false</overWriteReleases> 
            <overWriteIfNewer>true</overWriteIfNewer> 
            <overWriteSnapshots>true</overWriteSnapshots>
            <excludeScope>provided</excludeScope>
         </configuration>
      </plugin>

      It does exclude the provided scope, but it includes the test scope [easymock, dbunit, and junit appear in the output directory]. I tried to correct this problem by replacing the excludeScope parameter with two includeScope parameters, one for compile one for runtime, but only the first parameter was actually used.

      I also tried to exclude test but got an error, something like, "Can't exclude tests as that would exclude everything!".

      The goal is to be able to recreate the default copy functionality that is accomplished when executing a "mvn package" command, but be able to specify a maven-dependency-plugin configuration. When specifying this configuration, it overrides the default settings throughout the entire build life-cycle (as it should). But it is impossible to configure the plugin in the exact same was as the default settings.

      This is needed to support copying dependencies into the WEB-INF/lib folder within Eclipse workspaces, to support embedded application-server deployment.

        Activity

        Hide
        brianfox brianfox added a comment -

        You shouldn't ever need to include or exclude two scopes at the same time because they are comprised of each other. The default is to include test scope, which includes everything. If you don't want any test dependencies or provided dependencies, then include runtime and exclude provided.

        The scopes being interpreted are the scopes as maven sees them, not as specified in the pom. So the "test" scope includes everything, runtime includes compile but not provided etc.

        Show
        brianfox brianfox added a comment - You shouldn't ever need to include or exclude two scopes at the same time because they are comprised of each other. The default is to include test scope, which includes everything. If you don't want any test dependencies or provided dependencies, then include runtime and exclude provided. The scopes being interpreted are the scopes as maven sees them, not as specified in the pom. So the "test" scope includes everything, runtime includes compile but not provided etc.
        Hide
        Matthew Lieder added a comment -

        While that makes sense, it is still counter-intuitive and I believe it would help a lot of people if what you just said could be documented somewhere (ideally with some notes added to the includeScope/excludeScope attributes on the goal).

        Show
        Matthew Lieder added a comment - While that makes sense, it is still counter-intuitive and I believe it would help a lot of people if what you just said could be documented somewhere (ideally with some notes added to the includeScope/excludeScope attributes on the goal).
        Hide
        Ivan added a comment -

        I hope this issue is still watched, so I have voted for it.

        Currently I need to include "compile" and exclude both "provided" and "system" dependencies and I cannot do it rather than excluding system dependencies with <excludeArtifactIds> and similar tags. This is not a good idea if I have dozens of them.

        Btw, seems like "provided" and "system" scopes are independent (one doesn't comprise another).

        Show
        Ivan added a comment - I hope this issue is still watched, so I have voted for it. Currently I need to include "compile" and exclude both "provided" and "system" dependencies and I cannot do it rather than excluding system dependencies with <excludeArtifactIds> and similar tags. This is not a good idea if I have dozens of them. Btw, seems like "provided" and "system" scopes are independent (one doesn't comprise another).
        Hide
        Tamer Dakhlallah added a comment -

        From my experience, if you don't want any test or provided dependencies, then just include runtime scope dependencies. You don't need to "exclude" anything (contrary to what Brian says) because runtime scope doesn't give you any provided dependencies to begin with.

        In summary:
        Runtime scope gives you runtime and compile dependencies.
        Compile scope gives you compile, provided, and system dependencies.
        Test (default) scope gives you all dependencies.
        Provided scope just gives you provided dependencies.
        System scope just gives you system dependencies.

        I agree with Matthew in that this needs to be documented somewhere..

        Show
        Tamer Dakhlallah added a comment - From my experience, if you don't want any test or provided dependencies, then just include runtime scope dependencies. You don't need to "exclude" anything (contrary to what Brian says) because runtime scope doesn't give you any provided dependencies to begin with. In summary: Runtime scope gives you runtime and compile dependencies. Compile scope gives you compile, provided, and system dependencies. Test (default) scope gives you all dependencies. Provided scope just gives you provided dependencies. System scope just gives you system dependencies. I agree with Matthew in that this needs to be documented somewhere..
        Hide
        Rafal Figas added a comment -

        Wooow, this is REALLY counterintuitive. I found this, while I was trying to exclude test dependencies, exactly the same way as Bryan Stopp did. I think it would be VERY helpful if written at goal documentation in here:
        http://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html

        Show
        Rafal Figas added a comment - Wooow, this is REALLY counterintuitive. I found this, while I was trying to exclude test dependencies, exactly the same way as Bryan Stopp did. I think it would be VERY helpful if written at goal documentation in here: http://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html
        Hide
        Ian Springer added a comment -

        +1 on improving the docs. At the very least the descriptions of the includeScope and excludeScope properties should be improved on http://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html.

        Show
        Ian Springer added a comment - +1 on improving the docs. At the very least the descriptions of the includeScope and excludeScope properties should be improved on http://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html .
        Hide
        Herve Boutemy added a comment -

        doc improved in r1481514

        Show
        Herve Boutemy added a comment - doc improved in r1481514

          People

          • Assignee:
            Herve Boutemy
            Reporter:
            Bryan Stopp
          • Votes:
            11 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: