maven.plugin.classpath和maven.runtime.classpath有什么区别 [英] What is the difference between maven.plugin.classpath and maven.runtime.classpath
问题描述
Maven可以识别4个类路径:
Maven recognizes 4 classpaths:
-
maven.compile.classpath: 编译源代码时需要在类路径上的类和jar.所以基本上对于maven-compiler-plugin
maven.compile.classpath: Classes and jars which need to be on classpath when compiling your source codes. So basically for maven-compiler-plugin
maven.test.classpath:运行单元测试或集成测试时需要放在类路径上的类和jars
maven.test.classpath: Classes and jars which need to be on classpath when running unit tests or integration tests
maven.runtime.classpath: 我知道maven.runtime.classpath包含jar和maven本身需要运行的类.
maven.runtime.classpath: I understood that maven.runtime.classpath contains jars and classes maven itself needs to run.
maven.plugin.classpath: 我知道当插件运行自己的JVM时,该类路径将传递给maven插件
maven.plugin.classpath: I understood that this classpath is pass to maven plugin when the plugin runs it's own JVM
问题:
- 我是对的吗?
- 插件是否是编译类路径的超集?
- 测试编译类路径的超集吗?
- 当插件运行时,它是自己的JVM-什么是 类路径传递给它?
- 是否有任何文档?
- Am I right?
- Is plugin superset of compile classpath?
- Is test superset of compile classpath?
- When plugin runs it's own JVM - what is the classpath passed to it?
- Is there any documentation on this?
推荐答案
实际上,您错了,但是我找不到任何明确说明此问题的文档.
Actually, you have it wrong, but I couldn't find any documentation stating this explicitly.
这4个属性由 maven-antrun-plugin
定义,并且不是Maven本身的一部分.来自引用Maven类路径:
您还可以使用以下类路径引用:
You can also use these classpath references:
-
maven.compile.classpath
-
maven.runtime.classpath
-
maven.test.classpath
-
maven.plugin.classpath
maven.compile.classpath
maven.runtime.classpath
maven.test.classpath
maven.plugin.classpath
此插件创建这4个属性,以便Ant任务可以引用它们.如果您查看
This plugin creates those 4 properties so that Ant tasks can refer to them. You'll find where those properties are created if you take a look at the source code, copied here for reference
Path p = new Path( antProject );
p.setPath( StringUtils.join( mavenProject.getCompileClasspathElements().iterator(), File.pathSeparator ) );
/* maven.dependency.classpath it's deprecated as it's equal to maven.compile.classpath */
antProject.addReference( "maven.dependency.classpath", p );
antProject.addReference( "maven.compile.classpath", p );
p = new Path( antProject );
p.setPath( StringUtils.join( mavenProject.getRuntimeClasspathElements().iterator(), File.pathSeparator ) );
antProject.addReference( "maven.runtime.classpath", p );
p = new Path( antProject );
p.setPath( StringUtils.join( mavenProject.getTestClasspathElements().iterator(), File.pathSeparator) );
antProject.addReference( "maven.test.classpath", p );
/* set maven.plugin.classpath with plugin dependencies */
antProject.addReference( "maven.plugin.classpath", getPathFromArtifacts( pluginArtifacts, antProject ) );
通过分析此代码,可以得出以下结论:
By analyzing this code, it is possible to conclude that:
-
maven.compile.classpath
对应于范围compile
的类路径元素. -
maven.runtime.classpath
对应于范围runtime
的类路径元素. -
maven.test.classpath
对应于范围为test
的类路径元素. -
maven.plugin.classpath
对应于maven-antrun-plugin
本身的依赖性.
maven.compile.classpath
corresponds to elements of the classpath that are of scopecompile
.maven.runtime.classpath
corresponds to elements of the classpath that are of scoperuntime
.maven.test.classpath
corresponds to elements of the classpath that are of scopetest
.maven.plugin.classpath
corresponds to the dependencies of themaven-antrun-plugin
itself.
这篇关于maven.plugin.classpath和maven.runtime.classpath有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!