I have a maven based GWT project that includes Guava. I am having problems trying Maven (and failing) to compile sources found in guava-gwt*.jar :
could not parse error message: symbol: static setCountImpl location: class /home/mark/.m2/repository/com/google/guava/guava-gwt/11.0.1/guava-gwt-11.0.1.jar(com/google/common/collect/AbstractMultiset.java):100: error: cannot find symbol return setCountImpl(this, element, count); ^
I cannot understand why Maven believes that it should compile sources in guava-gwt . This is what my project looks like:
βββ pom.xml βββ src βββ main β βββ java βββ test βββ java βββ SomeTestFile.java
SomeTestFile.java
import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; import org.junit.Test; public class SomeTestFile { @Test public void testMethod() { Multimap<Integer, String> someMap = ArrayListMultimap.create(); someMap.put(5, "five"); System.out.println(someMap); } }
pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>guava-problem</groupId> <artifactId>guava-problem</artifactId> <version>1.0</version> <dependencies> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>11.0.1</version> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava-gwt</artifactId> <version>11.0.1</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> </project>
I have already tried the following:
- Removing
guava dependencies (leaving only guava-gwt ) - Scoping
guava-gwt to provided
I'm not sure what else to try. guava-gwt includes sources because GWT compiles it into equivalent Javascript. But I do not want Maven to try to compile these sources.
Edit
Just a note ... the test files themselves do not need guava-gwt over guava , because they are compiled and executed as Java code (they do not go through the GWT compilation stage). I don't need guava-gwt specifically for these tests, but it should be available for my actual GWT client code.
Maven full exit
mark@mark-peters:~/devel/guava-problem$ mvn -V clean test-compile Apache Maven 2.2.1 (rdebian-1) Java version: 1.7.0 Java home: /usr/lib/jvm/jdk1.7.0/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux" version: "2.6.32-38-generic" arch: "amd64" Family: "unix" [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building Unnamed - guava-problem:guava-problem:jar:1.0 [INFO] task-segment: [clean, test-compile] [INFO] ------------------------------------------------------------------------ [INFO] [clean:clean {execution: default-clean}] [INFO] Deleting file set: /home/mark/devel/guava-problem/target (included: [**], excluded: []) [INFO] [resources:resources {execution: default-resources}] [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, ie build is platform dependent! [INFO] skip non existing resourceDirectory /home/mark/devel/guava-problem/src/main/resources [INFO] [compiler:compile {execution: default-compile}] [INFO] Nothing to compile - all classes are up to date [INFO] [resources:testResources {execution: default-testResources}] [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, ie build is platform dependent! [INFO] skip non existing resourceDirectory /home/mark/devel/guava-problem/src/test/resources [INFO] [compiler:testCompile {execution: default-testCompile}] [INFO] Compiling 1 source file to /home/mark/devel/guava-problem/target/test-classes [INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Compilation failure /home/mark/.m2/repository/com/google/guava/guava-gwt/11.0.1/guava-gwt-11.0.1.jar(com/google/common/collect/AbstractMultiset.java):[19,0] error: cannot find symbol could not parse error message: symbol: static setCountImpl location: class /home/mark/.m2/repository/com/google/guava/guava-gwt/11.0.1/guava-gwt-11.0.1.jar(com/google/common/collect/AbstractMultiset.java):100: error: cannot find symbol return setCountImpl(this, element, count); ^ could not parse error message: symbol: method setCountImpl(AbstractMultiset<E>,E,int) location: class AbstractMultiset<E> where E is a type-variable: E extends Object declared in class AbstractMultiset /home/mark/.m2/repository/com/google/guava/guava-gwt/11.0.1/guava-gwt-11.0.1.jar(com/google/common/collect/AbstractMultiset.java):105: error: cannot find symbol return setCountImpl(this, element, oldCount, newCount); ^ [INFO] ------------------------------------------------------------------------ [INFO] For more information, run Maven with the -e switch [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2 seconds [INFO] Finished at: Tue Feb 21 12:49:42 EST 2012 [INFO] Final Memory: 18M/212M [INFO] ------------------------------------------------------------------------
Change (again)
Having established that the source of the problem has nothing to do with Guava, but rather in the Maven version (see my answer ), I updated the title and question to be more useful for future users.