You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Stanislav Ochotnicky (JIRA)" <ji...@codehaus.org> on 2011/09/20 17:11:17 UTC
[jira] Created: (MNG-5177) Maven adds tests dependecies into
depgraph even when skipping tests
Maven adds tests dependecies into depgraph even when skipping tests
-------------------------------------------------------------------
Key: MNG-5177
URL: https://jira.codehaus.org/browse/MNG-5177
Project: Maven 2 & 3
Issue Type: Bug
Affects Versions: 3.0.3
Reporter: Stanislav Ochotnicky
Priority: Minor
Maven 3.x adds test dependencies into dependency graph even when we use -Dmaven.test.skip=true. This means unnecessary downloading of artifacts and failure of build if the repository with test dependencies is offline.
I was able to solve this by patching maven in following way:
1. add new DependencySelector implementation that looks at environment variables and omits test dependencies when maven.test.skip property is found
2. modify maven-compat as well so that old code paths work the same way.
Maybe a better way to do part 1 would be to modify ScopeDependencySelector, and if that's the preferred way I can rework the patch that way.
I had several issues with the implementation:
1. For some reason I wasn't able to get property definition from MavenSession so I used System.getProperty directly. Any idea what might be the reason?
2. Is there perhaps a better way to figure out that tests are being skipped instead of looking for "maven.test.skip" property?
3. I had to copy non-test artifacts of dependencies in DefaultArtifactResolver because original implementation didn't provide "remove" method. Not a big deal I guess, but worth a note.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] (MNG-5177) Maven adds tests dependecies into depgraph even
when skipping tests
Posted by "John Casey (JIRA)" <ji...@codehaus.org>.
[ https://jira.codehaus.org/browse/MNG-5177?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
John Casey closed MNG-5177.
---------------------------
Resolution: Won't Fix
Assignee: John Casey
This changes the behavior of core Maven for all plugins that may require test-scoped dependencies. It's a mistake to think only of those that compile or execute tests, or that respond to maven.test.skip. There are less invasive ways to achieve the stated goal with Maven as-is.
> Maven adds tests dependecies into depgraph even when skipping tests
> -------------------------------------------------------------------
>
> Key: MNG-5177
> URL: https://jira.codehaus.org/browse/MNG-5177
> Project: Maven 2 & 3
> Issue Type: Bug
> Affects Versions: 3.0.3
> Reporter: Stanislav Ochotnicky
> Assignee: John Casey
> Priority: Minor
> Attachments: 0001-Fix-text-scope-skipping-with-maven.test.skip.patch
>
>
> Maven 3.x adds test dependencies into dependency graph even when we use -Dmaven.test.skip=true. This means unnecessary downloading of artifacts and failure of build if the repository with test dependencies is offline.
> I was able to solve this by patching maven in following way:
> 1. add new DependencySelector implementation that looks at environment variables and omits test dependencies when maven.test.skip property is found
> 2. modify maven-compat as well so that old code paths work the same way.
> Maybe a better way to do part 1 would be to modify ScopeDependencySelector, and if that's the preferred way I can rework the patch that way.
> I had several issues with the implementation:
> 1. For some reason I wasn't able to get property definition from MavenSession so I used System.getProperty directly. Any idea what might be the reason?
> 2. Is there perhaps a better way to figure out that tests are being skipped instead of looking for "maven.test.skip" property?
> 3. I had to copy non-test artifacts of dependencies in DefaultArtifactResolver because original implementation didn't provide "remove" method. Not a big deal I guess, but worth a note.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] (MNG-5177) Maven adds tests dependecies into depgraph even
when skipping tests
Posted by "Stanislav Ochotnicky (JIRA)" <ji...@codehaus.org>.
[ https://jira.codehaus.org/browse/MNG-5177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=312192#comment-312192 ]
Stanislav Ochotnicky commented on MNG-5177:
-------------------------------------------
Very well, the test deps in special profile is a nice trick, but it only works for project which actively use it. There is no way for me as downstream consuming their builds to prevent this.
Let's say I have several hundreds of Maven projects. In some cases, when I build them I want to skip tests and ignore test dependencies. How can I do this without actually modifying all those pom.xml files? There is no obvious non-invasive way from my reading of docs/code.
re Nick: I didn't care much about maven.test.skip=false since this was supposed to be just POC/Hack. I couldn't figure out a proper way to fix this in first iteration so I was kind of hoping for suggestions. It looks like a good thing that I didn't try to polish this into oblivion when the basic premise looks unacceptable.
> Maven adds tests dependecies into depgraph even when skipping tests
> -------------------------------------------------------------------
>
> Key: MNG-5177
> URL: https://jira.codehaus.org/browse/MNG-5177
> Project: Maven 2 & 3
> Issue Type: Bug
> Affects Versions: 3.0.3
> Reporter: Stanislav Ochotnicky
> Assignee: John Casey
> Priority: Minor
> Attachments: 0001-Fix-text-scope-skipping-with-maven.test.skip.patch
>
>
> Maven 3.x adds test dependencies into dependency graph even when we use -Dmaven.test.skip=true. This means unnecessary downloading of artifacts and failure of build if the repository with test dependencies is offline.
> I was able to solve this by patching maven in following way:
> 1. add new DependencySelector implementation that looks at environment variables and omits test dependencies when maven.test.skip property is found
> 2. modify maven-compat as well so that old code paths work the same way.
> Maybe a better way to do part 1 would be to modify ScopeDependencySelector, and if that's the preferred way I can rework the patch that way.
> I had several issues with the implementation:
> 1. For some reason I wasn't able to get property definition from MavenSession so I used System.getProperty directly. Any idea what might be the reason?
> 2. Is there perhaps a better way to figure out that tests are being skipped instead of looking for "maven.test.skip" property?
> 3. I had to copy non-test artifacts of dependencies in DefaultArtifactResolver because original implementation didn't provide "remove" method. Not a big deal I guess, but worth a note.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] (MNG-5177) Maven adds tests dependecies into depgraph even
when skipping tests
Posted by "John Casey (JIRA)" <ji...@codehaus.org>.
[ https://jira.codehaus.org/browse/MNG-5177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=311981#comment-311981 ]
John Casey edited comment on MNG-5177 at 10/22/12 2:57 PM:
-----------------------------------------------------------
IMO this is a dangerous thing to add without warning. Any plugin can specify '@RequiresDependencResolution test' and get tripped up with this patch, it's not only those that respond to maven.test.skip. In fact, I can think of use cases off the top of my head (creating a standalone buildable archive of a project using the assembly plugin being one) where test scope is needed, but have nothing at all to do with compiling/executing tests directly.
If you want to avoid downloading test dependencies, you can move them into a profile that is activated when maven.test.skip == false. This works; I've used the technique.
was (Author: jdcasey):
IMO this is a dangerous thing to add without warning. Any plugin can specify '@RequiresDependencResolution test' and get tripped up with this patch, it's not only those that respond to maven.test.skip. In fact, I can think of use cases off the top of my head (creating a standalone buildable archive of a project using the assembly plugin being one) where test scope is needed, but have nothing at all to do with compiling/executing tests directly.
> Maven adds tests dependecies into depgraph even when skipping tests
> -------------------------------------------------------------------
>
> Key: MNG-5177
> URL: https://jira.codehaus.org/browse/MNG-5177
> Project: Maven 2 & 3
> Issue Type: Bug
> Affects Versions: 3.0.3
> Reporter: Stanislav Ochotnicky
> Priority: Minor
> Attachments: 0001-Fix-text-scope-skipping-with-maven.test.skip.patch
>
>
> Maven 3.x adds test dependencies into dependency graph even when we use -Dmaven.test.skip=true. This means unnecessary downloading of artifacts and failure of build if the repository with test dependencies is offline.
> I was able to solve this by patching maven in following way:
> 1. add new DependencySelector implementation that looks at environment variables and omits test dependencies when maven.test.skip property is found
> 2. modify maven-compat as well so that old code paths work the same way.
> Maybe a better way to do part 1 would be to modify ScopeDependencySelector, and if that's the preferred way I can rework the patch that way.
> I had several issues with the implementation:
> 1. For some reason I wasn't able to get property definition from MavenSession so I used System.getProperty directly. Any idea what might be the reason?
> 2. Is there perhaps a better way to figure out that tests are being skipped instead of looking for "maven.test.skip" property?
> 3. I had to copy non-test artifacts of dependencies in DefaultArtifactResolver because original implementation didn't provide "remove" method. Not a big deal I guess, but worth a note.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Updated: (MNG-5177) Maven adds tests dependecies into
depgraph even when skipping tests
Posted by "Stanislav Ochotnicky (JIRA)" <ji...@codehaus.org>.
[ https://jira.codehaus.org/browse/MNG-5177?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stanislav Ochotnicky updated MNG-5177:
--------------------------------------
Attachment: 0001-Fix-text-scope-skipping-with-maven.test.skip.patch
Maven patch/hack fixing the problem
> Maven adds tests dependecies into depgraph even when skipping tests
> -------------------------------------------------------------------
>
> Key: MNG-5177
> URL: https://jira.codehaus.org/browse/MNG-5177
> Project: Maven 2 & 3
> Issue Type: Bug
> Affects Versions: 3.0.3
> Reporter: Stanislav Ochotnicky
> Priority: Minor
> Attachments: 0001-Fix-text-scope-skipping-with-maven.test.skip.patch
>
>
> Maven 3.x adds test dependencies into dependency graph even when we use -Dmaven.test.skip=true. This means unnecessary downloading of artifacts and failure of build if the repository with test dependencies is offline.
> I was able to solve this by patching maven in following way:
> 1. add new DependencySelector implementation that looks at environment variables and omits test dependencies when maven.test.skip property is found
> 2. modify maven-compat as well so that old code paths work the same way.
> Maybe a better way to do part 1 would be to modify ScopeDependencySelector, and if that's the preferred way I can rework the patch that way.
> I had several issues with the implementation:
> 1. For some reason I wasn't able to get property definition from MavenSession so I used System.getProperty directly. Any idea what might be the reason?
> 2. Is there perhaps a better way to figure out that tests are being skipped instead of looking for "maven.test.skip" property?
> 3. I had to copy non-test artifacts of dependencies in DefaultArtifactResolver because original implementation didn't provide "remove" method. Not a big deal I guess, but worth a note.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] (MNG-5177) Maven adds tests dependecies into depgraph even
when skipping tests
Posted by "Nick Cross (JIRA)" <ji...@codehaus.org>.
[ https://jira.codehaus.org/browse/MNG-5177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=311986#comment-311986 ]
Nick Cross commented on MNG-5177:
---------------------------------
This also breaks the scenario when someone uses mvn -Dmaven.test.skip=false (where there is profile activated tests).
> Maven adds tests dependecies into depgraph even when skipping tests
> -------------------------------------------------------------------
>
> Key: MNG-5177
> URL: https://jira.codehaus.org/browse/MNG-5177
> Project: Maven 2 & 3
> Issue Type: Bug
> Affects Versions: 3.0.3
> Reporter: Stanislav Ochotnicky
> Assignee: John Casey
> Priority: Minor
> Attachments: 0001-Fix-text-scope-skipping-with-maven.test.skip.patch
>
>
> Maven 3.x adds test dependencies into dependency graph even when we use -Dmaven.test.skip=true. This means unnecessary downloading of artifacts and failure of build if the repository with test dependencies is offline.
> I was able to solve this by patching maven in following way:
> 1. add new DependencySelector implementation that looks at environment variables and omits test dependencies when maven.test.skip property is found
> 2. modify maven-compat as well so that old code paths work the same way.
> Maybe a better way to do part 1 would be to modify ScopeDependencySelector, and if that's the preferred way I can rework the patch that way.
> I had several issues with the implementation:
> 1. For some reason I wasn't able to get property definition from MavenSession so I used System.getProperty directly. Any idea what might be the reason?
> 2. Is there perhaps a better way to figure out that tests are being skipped instead of looking for "maven.test.skip" property?
> 3. I had to copy non-test artifacts of dependencies in DefaultArtifactResolver because original implementation didn't provide "remove" method. Not a big deal I guess, but worth a note.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] (MNG-5177) Maven adds tests dependecies into depgraph even
when skipping tests
Posted by "John Casey (JIRA)" <ji...@codehaus.org>.
[ https://jira.codehaus.org/browse/MNG-5177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=311981#comment-311981 ]
John Casey commented on MNG-5177:
---------------------------------
IMO this is a dangerous thing to add without warning. Any plugin can specify '@RequiresDependencResolution test' and get tripped up with this patch, it's not only those that respond to maven.test.skip. In fact, I can think of use cases off the top of my head (creating a standalone buildable archive of a project using the assembly plugin being one) where test scope is needed, but have nothing at all to do with compiling/executing tests directly.
> Maven adds tests dependecies into depgraph even when skipping tests
> -------------------------------------------------------------------
>
> Key: MNG-5177
> URL: https://jira.codehaus.org/browse/MNG-5177
> Project: Maven 2 & 3
> Issue Type: Bug
> Affects Versions: 3.0.3
> Reporter: Stanislav Ochotnicky
> Priority: Minor
> Attachments: 0001-Fix-text-scope-skipping-with-maven.test.skip.patch
>
>
> Maven 3.x adds test dependencies into dependency graph even when we use -Dmaven.test.skip=true. This means unnecessary downloading of artifacts and failure of build if the repository with test dependencies is offline.
> I was able to solve this by patching maven in following way:
> 1. add new DependencySelector implementation that looks at environment variables and omits test dependencies when maven.test.skip property is found
> 2. modify maven-compat as well so that old code paths work the same way.
> Maybe a better way to do part 1 would be to modify ScopeDependencySelector, and if that's the preferred way I can rework the patch that way.
> I had several issues with the implementation:
> 1. For some reason I wasn't able to get property definition from MavenSession so I used System.getProperty directly. Any idea what might be the reason?
> 2. Is there perhaps a better way to figure out that tests are being skipped instead of looking for "maven.test.skip" property?
> 3. I had to copy non-test artifacts of dependencies in DefaultArtifactResolver because original implementation didn't provide "remove" method. Not a big deal I guess, but worth a note.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira