使用Maven 3.3.1时,我的Maven构建失败,但使用Maven 3.2.2成功。
到目前为止,我已经运行了/path/to/3.3.1/mvn clean compile -X
并将输出与/path/to/3.2.2/mvn clean compile -X
生成的输出进行了比较。
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
...
差异:当Maven 3.2.2打印[DEBUG] Included: javax.inject:javax.inject:jar:1
时,Maven 3.3.1缺少它。
我不知道这是否有帮助,但这是我有效的构建插件:
<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>
我不明白:“填充类领域插件”到底有什么作用?为什么jar丢失了,即使它已被两个maven版本识别为依赖?
编辑:构建失败并出现此异常:
[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
答案 0 :(得分:3)
问题不在于maven-compiler-plugin的版本
当您使用 forceJavacCompilerUse 选项时,它基本上会在您的JDK中使用javax.tool API实现。
由于你使用的是 dagger-compiler ,它实际上依赖于 javax.inject ,所以它应该被拉动。
您可以尝试为dagger-compiler插件依赖项添加 [提供]范围,这样您就可以锁定所有传递依赖项。
还要确保添加了匕首 依赖于运行时依赖项。
请提供有关异常堆栈跟踪和pom的其他相关区域的更多详细信息,以帮助访问者缩小问题范围并快速指导您!