Cant resolve type error when performing a maven build
I am getting the following error when trying to do a ma开发者_Python百科ven command line build:
[ERROR] /trunk/application/web/src/test/java/com/morrislgn/ec/dms/controller/MyControllerTest.java:96:0::0 BuilderType cannot be resolved to a type Caused by: org.codehaus.mojo.aspectj.CompilationFailedException: Compiler errors : error at import static com.morrislgn.ec.dms.common.domain.BuilderType.*;
However, when I run this test class from within Eclipse these tests run as expected. I have looked at the dependancies and added the common project as a dependancy, to the class path etc without any joy.
Does anyone have any other ideas as to what might be causing this problem?
Thanks in advance,
Morris
I think you need to some kind of dependencies to the aspectj plugin configuration. The kind you need depends on where the missing BuilderType class is supposed to be coming from. If you can explain that someone may be able to be more specific. See the plugin docs, especially here and here (assuming you're compiling a test - see the compile goal otherwise. I'm not an aspectj user - if anyone reads this who is, please weigh in!
Please post the relevant parts of your pom, and explain where BuilderType should come from.
Ok, found a solution.
the builderClass mentioned above was under src\test\main in a common project I had. As such, it wasnt built included with the common jar.
I have a web project which depended on the common jar, in turn used the BuilderType in its test. In Eclipse all of this could be resolved as it seemed able to knit everything together.
Building from the command line using maven was different however as this relied on the jar files and not the java files.
To work around this a test classes jar file was added to the build instructions in the POM for the common project:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>jar_it</id>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
And then a dependency was added to the web project so it could use this jar.
<dependency>
<groupId>group.id</groupId>
<artifactId>common</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
Job done. :)
精彩评论