[
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