是否有Maven的“仅编译器"?依赖工件的范围 [英] Is there a Maven "compiler-only" scope for dependency artifacts
问题描述
我意识到这更多是语义上的追求,而不是功能上的追求.
I realise this is more of a semantic quest rather than a functionality quest.
我有三种类型的编译范围依赖项:
I have three types of compile-scope dependencies:
-
仅编译范围,在运行时不使用. GWT客户端开发人员,MVP4G,RestyGWT,源保留注释处理器.我使用REST,因此不需要GWT服务器端.
Compile-only scope, not used at run-time. GWT client-side dev, MVP4G, RestyGWT, Source retention annotation processors. I use REST, so I don't need GWT server side.
提供-编译需要Hibernate jar,但由JBoss提供.
Provided - Hibernate jars required for compilation but provided by JBoss.
编译+运行时jars.
Compile + runtime jars.
对于情况2,我们可以使用提供的范围.情况3,我们将使用编译范围.
For case 2, we could use provided scope. Case 3, we would use compile scope.
但是对于情况1,即使JBoss根本不提供这些文件,我也使用提供的范围.在运行时也不需要它们.
However for case 1, I use provided scope, even though JBoss does not provide those files at all. Nor are they needed at run-time.
无论如何,您是否认为Maven应该为除了编译时才真正不需要伪像的范围提供提供"的同义词?也许,应该有一个仅编译"作用域吗?
Anyway, don't you think Maven should provide for a synonym for "provided" for a scope where the artefacts are not really needed except at compile time? Perhaps, should there be a "compile-only" scope?
推荐答案
如果jars不是真正的运行时"依赖项(仅用于构建),而不是最终工件,则可以通过多种方式将它们排除:
If the jars with are not true "runtime" dependencies (only for building) but not for the final artifact, you can exclude them various means:
- 排除在程序集描述符中
- 排除在jar(或战争,耳朵,任何东西)插件配置中
- Shade Plugin最小化罐子目标
- Exclusion in the assembly descriptor
- Exclusion in the jar (or war, ear, whatever) plugin configuration
- Shade Plugin minimize jar goal
我同意交付不必要的类很烦人(我已经在生产部署中看到过junit和testng jars-brrrr ...),但是从所有实际目的来看,这只是一个很小的问题.
I agree that shipping unnecessary classes is annoying (I've seen junit and testng jars in production deployments - brrrr...), but for all practical purposes it's a rather minor one.
如果您遇到依赖冲突(即提供库或框架的所有deps"版本),那就是另一回事了,但听起来并不像您在这里面临的那样.
If you have a dependency conflict (i.e shipping a "all deps" version of a library or framework), that's a different story, but doesn't sound like what you're facing here.
这篇关于是否有Maven的“仅编译器"?依赖工件的范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!