i want migrate 1 of our projects ant+ivy gradle. when compile sources using gradle error:
...\guava-gwt-14.0.1.jar(com/google/common/collect/abstractiterator.java):64: error: duplicate class: com.google.common.collect.abstractiterator public abstract class abstractiterator<t> extends unmodifiableiterator<t> { ^ ...\guava-gwt-14.0.1.jar(com/google/common/base/optional.java):223: error: cannot access abstractiterator return new abstractiterator<t>() { ^ bad source file: ...\guava-gwt-14.0.1.jar(com/google/common/base/abstractiterator.java) file not contain class com.google.common.base.abstractiterator please remove or make sure appears in correct subdirectory of sourcepath. note: input files use or override deprecated api. note: recompile -xlint:deprecation details. note: input files use unchecked or unsafe operations. note: recompile -xlint:unchecked details. 2 errors
i checked abstractiterator.java
in com.google.common.collect
, com.google.common.base
(as wrote in error). how solve problem?
[update]
this gradle build (very simple - it's beginning of migration ant gradle)
apply plugin: 'java' compilejava.options.encoding = 'iso-8859-1' repositories { mavencentral() maven { url 'http://gwtquery-plugins.googlecode.com/svn/mavenrepo' } ivy { url 'http://ivyrep/shared' url 'http://ivyrep/public' layout "pattern", { artifact "[organisation]/[module]/[revision]/[type]s/[artifact].[ext]" } } } // know conigurations should repaired (testcompile, runtime) beggining of migration ant gradle dependencies { compile 'net.sourceforge.cobertura:cobertura:1.9.4.1' compile 'com.google.gwt:gwt-servlet:2.5.0' compile 'com.google.gwt:gwt-user:2.5.0' compile 'com.google.gwt:gwt-dev:2.5.0' compile 'com.google.gwt.inject:gin:2.0.0' compile 'com.googlecode.gwtquery:gwtquery:1.3.2' compile 'com.googlecode.gwtquery.bundles:gquery-dnd-bundle:1.0.6' compile 'org.hamcrest:hamcrest-library:1.3' compile 'org.mockito:mockito-all:1.9.5' compile 'junit:junit:4.10' compile 'org.easytesting:fest-assert-core:2.0m10' compile 'xmlunit:xmlunit:1.3' compile 'org.reflections:reflections:0.9.9-rc1' }
i should add gwt project.
[update]
problem solved. i've excluded guava-gwt compile scope , started work. not best solution works.
apply plugin: 'java' configurations { guavagwt } dependencies { guavagwt 'com.google.guava:guava-gwt:14.0.1' // other dependencies } task compilegwt (dependson: classes) << { // [...] javaexec { main = 'com.google.gwt.dev.compiler' maxheapsize = '512m' classpath { [ sourcesets.main.java.srcdirs, sourcesets.main.output.resourcesdir, sourcesets.main.output.classesdir, sourcesets.main.compileclasspath, configurations.guavagwt, // use guava-gwt ] } args = [ modulename, '-war', builddir, '-loglevel', 'info', // '-draftcompile' // speeds compile 25% ] } // [...] } compilejava { configurations.compile.exclude module:'guava-gwt' // exclude guava-gwt // job }
i got same issue today, , fixed adding gradle build file:
tasks.withtype(javacompile) { options.compilerargs += ["-sourcepath", ""] }
thanks peter's answer in post: http://forums.gradle.org/gradle/topics/compilation_fails_when_i_use_guavas_optional_class_duplicate_class_com_google_common_collect_abstractiterator
Comments
Post a Comment