[英]Why does Maven 3.3 not include 'javax.inject' but Maven 3.2 does?
My Maven build fails when using Maven 3.3.1 but is successful with Maven 3.2.2. 使用Maven 3.3.1时,我的Maven构建失败,但Maven 3.2.2成功。
So far I have run /path/to/3.3.1/mvn clean compile -X
and compared the output to the one produced by /path/to/3.2.2/mvn clean compile -X
. 到目前为止,我已经运行了
/path/to/3.3.1/mvn clean compile -X
,并将输出与/path/to/3.2.2/mvn clean compile -X
生成的输出进行了比较。
There was exactly one difference in the following block inside the maven-compiler-plugin / default-compile
phase: 在
maven-compiler-plugin / default-compile
阶段的下一个块中只有一个区别:
[DEBUG] Populating class realm plugin>org.apache.maven.plugins:maven-compiler-plugin:3.2
[DEBUG] Included: org.apache.maven.plugins:maven-compiler-plugin:jar:3.2
[DEBUG] Included: com.google.dagger:dagger-compiler:jar:2.0
[DEBUG] Included: com.google.dagger:dagger:jar:2.0
[DEBUG] Included: com.google.dagger:dagger-producers:jar:2.0-beta
[DEBUG] Included: com.google.guava:guava:jar:18.0
...
Difference: While Maven 3.2.2 printed [DEBUG] Included: javax.inject:javax.inject:jar:1
, it is missing for Maven 3.3.1. 区别: Maven 3.2.2打印
[DEBUG] Included: javax.inject:javax.inject:jar:1
,Maven 3.3.1缺少它。
I don't know if this helps, but this is my effective build plugin: 我不知道这是否有帮助,但这是我有效的构建插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version> <!-- 3.3 respectively -->
<dependencies>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
<configuration>
<source>1.8</source>
<target>1.8</target>
<!-- workaround for http://jira.codehaus.org/browse/MCOMPILER-202 -->
<forceJavacCompilerUse>true</forceJavacCompilerUse>
</configuration>
</plugin>
What I don't understand: What exactly does the "Populating class realm plugin" do? 我不明白:“填充类领域插件”到底有什么作用? Why is a jar missing, even though it has been identified as a dependency by both maven versions?
为什么一个jar丢失了,即使它已被两个maven版本识别为依赖?
Edit: Build fails with this exception: 编辑:构建失败,出现此异常:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project ui: Compilation failure -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project ui: Compilation failure
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:913)
at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
A minimal example project is available on GitHub . GitHub上提供了一个最小的示例项目。 The full output of the failing command is available here .
此处提供了失败命令的完整输出。
The problem is not with the version of maven-compiler-plugin. 问题不在于maven-compiler-plugin的版本。
When you use the option forceJavacCompilerUse it would basically use javax.tool API implementation within your JDK. 当你使用forceJavacCompilerUse选项时,它基本上会在你的JDK中使用javax.tool API实现。
Since you are using dagger-compiler , which is intern dependent on javax.inject , it should get pulled. 由于你使用的是dagger-compiler ,它是一个依赖于javax.inject的实习生,所以它应该被拉。
You can try adding [provided] scope for your dagger-compiler plugin dependency, this way you would be locking all the transitive dependencies. 您可以尝试为dagger-compiler插件依赖项添加[提供]范围 ,这样您就可以锁定所有传递依赖项。
Also make sure that you have added dagger dependency in your runtime dependencies. 还要确保在运行时依赖项中添加了dagger依赖项。
Please provide the some more details of exception-stack-trace and other related areas of your pom that would help visitors to narrow-down the problem and guide you quick! 请提供有关异常堆栈跟踪和pom的其他相关区域的更多详细信息,以帮助访问者缩小问题范围并快速指导您!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.