title: Spring Cloud Contract compilation problems when using maven
body: <p>I recently added spring cloud contract to our spring project following the instructions on their tutorial site here (<a href="https://cloud.spring.io/spring-cloud-contract/#quick-start" rel="nofollow noreferrer">https://cloud.spring.io/spring-cloud-contract/#quick-start</a>).</p>
  
  <p>I managed to write contracts, generate stubs and everything works as expected, but I have a problem when working with a clean project after pulling it off our repository. When I let <code>mvn test</code> run I get compilation errors in the generated test-class because it seems like the project itself didn't build before so the base-class for the contract tests on the producer site doesn't seem to exist yet. </p>
  
  <p><code>
  [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project kongo-shoppingcart-service: Compilation failure: Compilation failure:
  [ERROR] [...]/src/kongo-service-shoppingcart/kongo-shoppingcart-service/target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java:[7,64] package edu.hm.ba.kongo.shop.shoppingcart.service.test.contracts does not exist
  [ERROR] [...]/src/kongo-service-shoppingcart/kongo-shoppingcart-service/target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java:[14,43] cannot find symbol
  [ERROR] symbol: class ContractTestBase
  </code></p>
  
  <p>My projects pom looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  </code></pre>
  
  <p>http://maven.apache.org/xsd/maven-4.0.0.xsd">
      4.0.0</p>
  
  <pre><code>&lt;parent&gt;
      &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
      &lt;artifactId&gt;spring-cloud-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;Brixton.M5&lt;/version&gt;
      &lt;relativePath/&gt;
  &lt;/parent&gt;
  
  &lt;groupId&gt;edu.hm.ba.kongo.shop&lt;/groupId&gt;
  &lt;artifactId&gt;kongo-shoppingcart-service&lt;/artifactId&gt;
  &lt;name&gt;kongo :: shoppingcart :: service&lt;/name&gt;
  &lt;version&gt;1.0&lt;/version&gt;
  
  &lt;properties&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;maven.compiler.source&gt;1.8&lt;/maven.compiler.source&gt;
      &lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;!-- Spring Boot --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-rest&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.plugin&lt;/groupId&gt;
          &lt;artifactId&gt;spring-plugin-core&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;!-- Spring Boot --&gt;
  
      &lt;!-- Spring Data --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
          &lt;artifactId&gt;spring-data-rest-hal-browser&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.hateoas&lt;/groupId&gt;
          &lt;artifactId&gt;spring-hateoas&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;!-- Spring Data --&gt;
  
      &lt;!-- Spring Cloud --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
          &lt;artifactId&gt;spring-cloud-starter-eureka&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
          &lt;artifactId&gt;spring-cloud-starter-config&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
          &lt;artifactId&gt;spring-cloud-starter-ribbon&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;!-- Spring Cloud --&gt;
  
      &lt;!-- json usw. --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.fasterxml.jackson.datatype&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-datatype-jsr310&lt;/artifactId&gt;
          &lt;version&gt;2.7.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.jayway.jsonpath&lt;/groupId&gt;
          &lt;artifactId&gt;json-path&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;!-- json usw. --&gt;
  
      &lt;!-- Datenbank --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.flywaydb&lt;/groupId&gt;
          &lt;artifactId&gt;flyway-core&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.h2database&lt;/groupId&gt;
          &lt;artifactId&gt;h2&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;mysql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-search-orm&lt;/artifactId&gt;
          &lt;version&gt;5.3.0.Final&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;!-- Datenbank --&gt;
  
      &lt;!-- Validation --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.validation&lt;/groupId&gt;
          &lt;artifactId&gt;validation-api&lt;/artifactId&gt;
          &lt;version&gt;1.0.0.GA&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
          &lt;version&gt;4.3.1.Final&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- Validation --&gt;
  
      &lt;!-- Other --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.google.guava&lt;/groupId&gt;
          &lt;artifactId&gt;guava&lt;/artifactId&gt;
          &lt;version&gt;18.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
          &lt;artifactId&gt;httpclient&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;!-- test --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.assertj&lt;/groupId&gt;
          &lt;artifactId&gt;assertj-core&lt;/artifactId&gt;
          &lt;version&gt;3.6.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
          &lt;artifactId&gt;spring-cloud-starter-contract-verifier&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- internal --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;de.muenchen&lt;/groupId&gt;
          &lt;artifactId&gt;Service-Lib&lt;/artifactId&gt;
          &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;de.muenchen&lt;/groupId&gt;
          &lt;artifactId&gt;Auditing&lt;/artifactId&gt;
          &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  
  &lt;dependencyManagement&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;spring-cloud-contract-dependencies&lt;/artifactId&gt;
              &lt;version&gt;1.0.3.RELEASE&lt;/version&gt;
              &lt;type&gt;pom&lt;/type&gt;
              &lt;scope&gt;import&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;artifactId&gt;spring-data-rest-webmvc&lt;/artifactId&gt;
              &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
              &lt;version&gt;2.5.0.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;artifactId&gt;spring-data-rest-core&lt;/artifactId&gt;
              &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
              &lt;version&gt;2.5.0.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/dependencyManagement&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;repackage&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;copy-resources&lt;/id&gt;
                      &lt;phase&gt;validate&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;copy-resources&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;outputDirectory&gt;${basedir}/target/&lt;/outputDirectory&gt;
                          &lt;resources&gt;
                              &lt;resource&gt;
                                  &lt;directory&gt;src/main/docker&lt;/directory&gt;
                                  &lt;filtering&gt;true&lt;/filtering&gt;
                              &lt;/resource&gt;
                          &lt;/resources&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;com.spotify&lt;/groupId&gt;
                      &lt;artifactId&gt;docker-maven-plugin&lt;/artifactId&gt;
                      &lt;version&gt;0.4.13&lt;/version&gt;
                      &lt;configuration&gt;
                          &lt;imageName&gt;${project.artifactId}&lt;/imageName&gt;
                          &lt;dockerDirectory&gt;target&lt;/dockerDirectory&gt;
                          &lt;resources&gt;
                              &lt;resource&gt;
                                  &lt;targetPath&gt;/&lt;/targetPath&gt;
                                  &lt;directory&gt;${project.build.directory}&lt;/directory&gt;
                                  &lt;include&gt;${project.build.finalName}.jar&lt;/include&gt;
                              &lt;/resource&gt;
                          &lt;/resources&gt;
                      &lt;/configuration&gt;
                      &lt;!-- Uncomment if you want to build a new image for every 'mvn package'
                      &lt;executions&gt;
                          &lt;execution&gt;
                              &lt;id&gt;build-image&lt;/id&gt;
                              &lt;phase&gt;package&lt;/phase&gt;
                              &lt;goals&gt;
                                  &lt;goal&gt;build&lt;/goal&gt;
                              &lt;/goals&gt;
                          &lt;/execution&gt;
                      &lt;/executions&gt;
                      --&gt;
                  &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;spring-cloud-contract-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;1.0.3.RELEASE&lt;/version&gt;
              &lt;!-- Don't forget about this value !! --&gt;
              &lt;extensions&gt;true&lt;/extensions&gt;
              &lt;configuration&gt;
                  &lt;baseClassForTests&gt;edu.hm.ba.kongo.shop.shoppingcart.service.test.contracts.ContractTestBase&lt;/baseClassForTests&gt;
                  &lt;contractsDirectory&gt;src/main/test/edu/hm/ba/kongo/shop/shoppingcart/service/test/contracts&lt;/contractsDirectory&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  
  &lt;repositories&gt;
      &lt;repository&gt;
          &lt;id&gt;spring-milestones&lt;/id&gt;
          &lt;name&gt;Spring Milestones&lt;/name&gt;
          &lt;url&gt;http://repo.spring.io/milestone&lt;/url&gt;
          &lt;snapshots&gt;
              &lt;enabled&gt;false&lt;/enabled&gt;
          &lt;/snapshots&gt;
      &lt;/repository&gt;
  &lt;/repositories&gt;
  </code></pre>
  
  <p></p>
  
  <p>But when I build the module by hand and run <code>mvn test</code> afterwords everything works as expected. Is there something wrong with the declaration of my POM?</p>