5

When I run mvn clean compile on my project I get a build success.

But when I run mvn install straight afterwards, I get a Build Failure because of a compilation error.

The error I get is:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project auto-tests: Compilation failure: Compilation failure:

I have this in my pom.xml:

<plugin>
    <inherited>true</inherited>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
        <encoding>UTF-8</encoding>
        <source>1.6</source>
        <target>1.6</target>
    </configuration>
</plugin>

and

<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
</dependency>

The failure is because it cannot find the classes which sit in another module. The dependency for these classes is added in my pom file and intellij never complains about it.

Am I missing something here?

Soma
  • 861
  • 2
  • 17
  • 32
user3194793
  • 51
  • 2
  • 4
  • What is the actual compile error? – matt forsythe Jan 14 '14 at 16:38
  • the error that is getting returned is: package com.xx.xxx.xxxservice does not exist – user3194793 Jan 14 '14 at 16:41
  • the funny thing is, is that in intelliJ everything builds fine and I never get any of these packages complaining as i have a dependency in my pom.xml it only throws this error when I try to run the tests from the command line. – user3194793 Jan 14 '14 at 16:43
  • The likely reason for that is that IntelliJ probably combines all of the dependencies into one big classpath that it uses to build everything. Maven command line builds have separate compile, test-compile, and run classpaths. What is the pom's `` entry for com.xx.xxx.xxxservice? – matt forsythe Jan 14 '14 at 17:04

2 Answers2

3

It's "testCompile" mojo that fails, which is called inside the "test-compile" phase, a phase between "compile" and "install".

So basically your test sources cannot compile.

Tome
  • 3,234
  • 3
  • 33
  • 36
1

It looks like you probably have a compile error in one of your tests (which don't get compiled in the normal compile phase). It's hard to tell exactly where without a full pom and source code.

matt forsythe
  • 3,863
  • 1
  • 19
  • 29