在使用 Gradle、JUNG 和 Error Prone 时如何修复此 Xlint:path 错误?
How do I fix this Xlint:path error when using Gradle, JUNG and Error Prone?
我很难让 JUNG 和 Error Prone 在我基于 Gradle 的 Java 项目中很好地协同工作,我想知道是否有人以前遇到过这样的问题并且可以帮助我找到解决方案。
我已经在 JUNG and Error Prone 的 GitHub 问题跟踪器上发布了这个问题,但似乎没有人知道它的原因,这就是我将其发布在这里的原因。
When I try to run gradle run
with the following build.gradle
plugins {
id 'application'
id 'java'
id 'net.ltgt.errorprone' version '0.0.8'
}
group 'org.jbduncan'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
mainClassName = 'org.jbduncan.helloworld.HelloWorld'
repositories {
jcenter()
}
dependencies {
compile 'net.sf.jung:jung-graph-impl:2.1.1'
errorprone 'com.google.errorprone:error_prone_core:2.0.11'
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.compilerArgs = [
'-Xlint:all',
'-Werror'
]
}
and this class
package org.jbduncan.helloworld;
public final class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
it emits the following message.
:compileJava
warning: [path] bad path element "C:\Users\Jonathan\.gradle\caches\modules-2\files-2.1\net.sf.jung\jung-graph-impl.1.193acb2ab4c00a3939cb99a8751e5d38a4299dc\jung-api-2.1.1.jar": no such file or directory
warning: [path] bad path element "C:\Users\Jonathan\.gradle\caches\modules-2\files-2.1\net.sf.jung\jung-graph-impl.1.193acb2ab4c00a3939cb99a8751e5d38a4299dc\guava-19.0.jar": no such file or directory
warning: [path] bad path element "C:\Users\Jonathan\.gradle\caches\modules-2\files-2.1\net.sf.jung\jung-api.1.1\e47ee4efdfacce12f0af620747d9d0e44bf2eaa4\guava-19.0.jar": no such file or directory
error: warnings found and -Werror specified
1 error
3 warnings
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed with exit code 1; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.488 secs
When I investigate the contents of my Gradle cache, I can see that, indeed, the jar files mentioned above simply don't exist.
When I look into C:\Users\Jonathan\.gradle\caches\modules-2\files-2.1\net.sf.jung\jung-graph-impl.1.193acb2ab4c00a3939cb99a8751e5d38a4299dc\jung-graph-impl-2.1.1.jar
, the META-INF/MANIFEST.MF
contains this text.
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven 3.0.5
Built-By: jrtom
Build-Jdk: 1.8.0-google-v7
Class-Path: jung-api-2.1.1.jar guava-19.0.jar
I get the same problem with JUNG versions 2.1 and 2.0, and no other library with dependencies I've tried seems to have this problem.
However the problem goes away when I exclude from build.gradle
the lines id 'net.ltgt.errorprone' version '0.0.8'
and errorprone 'com.google.errorprone:error_prone_core:2.0.11'
, so it's not clear to me if this is a problem with JUNG or if it's gradle-errorprone-plugin or Error Prone related.
我认为值得注意的是,由于我在 JUNG 问题跟踪器上发布了上述问题,我将项目的 Error Prone 版本从 2.0.11 升级到 2.0.13,但不幸的是,这并没有解决我的问题。
问题已解决 this bug fix to JUNG。
我很难让 JUNG 和 Error Prone 在我基于 Gradle 的 Java 项目中很好地协同工作,我想知道是否有人以前遇到过这样的问题并且可以帮助我找到解决方案。
我已经在 JUNG and Error Prone 的 GitHub 问题跟踪器上发布了这个问题,但似乎没有人知道它的原因,这就是我将其发布在这里的原因。
When I try to run
gradle run
with the followingbuild.gradle
plugins { id 'application' id 'java' id 'net.ltgt.errorprone' version '0.0.8' } group 'org.jbduncan' version '1.0-SNAPSHOT' sourceCompatibility = 1.8 mainClassName = 'org.jbduncan.helloworld.HelloWorld' repositories { jcenter() } dependencies { compile 'net.sf.jung:jung-graph-impl:2.1.1' errorprone 'com.google.errorprone:error_prone_core:2.0.11' } tasks.withType(JavaCompile) { options.encoding = 'UTF-8' options.compilerArgs = [ '-Xlint:all', '-Werror' ] }
and this class
package org.jbduncan.helloworld; public final class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world!"); } }
it emits the following message.
:compileJava warning: [path] bad path element "C:\Users\Jonathan\.gradle\caches\modules-2\files-2.1\net.sf.jung\jung-graph-impl.1.193acb2ab4c00a3939cb99a8751e5d38a4299dc\jung-api-2.1.1.jar": no such file or directory warning: [path] bad path element "C:\Users\Jonathan\.gradle\caches\modules-2\files-2.1\net.sf.jung\jung-graph-impl.1.193acb2ab4c00a3939cb99a8751e5d38a4299dc\guava-19.0.jar": no such file or directory warning: [path] bad path element "C:\Users\Jonathan\.gradle\caches\modules-2\files-2.1\net.sf.jung\jung-api.1.1\e47ee4efdfacce12f0af620747d9d0e44bf2eaa4\guava-19.0.jar": no such file or directory error: warnings found and -Werror specified 1 error 3 warnings :compileJava FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':compileJava'. > Compilation failed with exit code 1; see the compiler error output for details. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 5.488 secs
When I investigate the contents of my Gradle cache, I can see that, indeed, the jar files mentioned above simply don't exist.
When I look into
C:\Users\Jonathan\.gradle\caches\modules-2\files-2.1\net.sf.jung\jung-graph-impl.1.193acb2ab4c00a3939cb99a8751e5d38a4299dc\jung-graph-impl-2.1.1.jar
, theMETA-INF/MANIFEST.MF
contains this text.Manifest-Version: 1.0 Archiver-Version: Plexus Archiver Created-By: Apache Maven 3.0.5 Built-By: jrtom Build-Jdk: 1.8.0-google-v7 Class-Path: jung-api-2.1.1.jar guava-19.0.jar
I get the same problem with JUNG versions 2.1 and 2.0, and no other library with dependencies I've tried seems to have this problem.
However the problem goes away when I exclude from
build.gradle
the linesid 'net.ltgt.errorprone' version '0.0.8'
anderrorprone 'com.google.errorprone:error_prone_core:2.0.11'
, so it's not clear to me if this is a problem with JUNG or if it's gradle-errorprone-plugin or Error Prone related.
我认为值得注意的是,由于我在 JUNG 问题跟踪器上发布了上述问题,我将项目的 Error Prone 版本从 2.0.11 升级到 2.0.13,但不幸的是,这并没有解决我的问题。
问题已解决 this bug fix to JUNG。