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

Support ability to specify multiple "includeScope" parameters

    Details

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

      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

        Bryan Stopp created issue -
        Hide
        Brian E. Fox 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
        Brian E. Fox 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
        Bit Buzzer 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
        Bit Buzzer 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
        Rafał 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
        Rafał 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 P. 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 P. 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 .
        Hervé Boutemy made changes -
        Field Original Value New Value
        Assignee Brian Fox [ brianfox ]
        Hervé Boutemy made changes -
        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.
        You can only configure the plugin with either one includeScope or one excludeScope. When executing the plugin to copy dependencies with the following configuration:

        {code:xml}<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>{code}

        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.
        Component/s copy-dependencies [ 12673 ]
        Hide
        Hervé Boutemy added a comment -

        doc improved in r1481514

        Show
        Hervé Boutemy added a comment - doc improved in r1481514
        Hervé Boutemy made changes -
        Resolution Fixed [ 1 ]
        Fix Version/s 2.8 [ 19150 ]
        Assignee Herve Boutemy [ hboutemy ]
        Status Open [ 1 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 09:23:40 UTC 2015 [ 1428225820705 ]
        Mark Thomas made changes -
        Workflow jira [ 12718914 ] Default workflow, editable Closed status [ 12761275 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 22:54:20 UTC 2015 [ 1428274460860 ]
        Mark Thomas made changes -
        Workflow jira [ 12956679 ] Default workflow, editable Closed status [ 12993983 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Closed Closed
        1958d 21h 48m 1 Hervé Boutemy 12/May/13 06:38

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development