spring-cloud / spring-cloud-contract

Support for Consumer Driven Contracts in Spring
https://cloud.spring.io/spring-cloud-contract
Apache License 2.0
717 stars 439 forks source link

Contract tests not generated in producer failing with compile error #2101

Open diana-deliu opened 6 months ago

diana-deliu commented 6 months ago

Hello!

The issue I use spring cloud contract tests for a while now and they were working as expected. I've recently had to change my laptop (old one - Windows, this one Windows as well) and now the spring cloud contract tests are not generated anymore. We use Gradle as build tool.

What we've tried so far

Please keep in mind that the provided configuration works for almost all of my peers and it's been working for me as well for the last couple of years. We use:

The actual error

java.lang.IllegalStateException: Exceptions occurred while trying to compile the file [==========
import org.springframework.cloud.contract.spec.Contract;
                                              ^^^^^^^^^
ERROR:package org.springframework.cloud.contract.spec does not exist
==========
, ==========
import org.springframework.cloud.contract.spec.internal.QueryParameters;
                                                       ^^^^^^^^^^^^^^^^
ERROR:package org.springframework.cloud.contract.spec.internal does not exist
==========
, ==========
import org.springframework.cloud.contract.spec.internal.RegexPatterns;
                                                       ^^^^^^^^^^^^^^
ERROR:package org.springframework.cloud.contract.spec.internal does not exist
==========
, ==========
import org.springframework.cloud.contract.spec.internal.Request;
                                                       ^^^^^^^^
ERROR:package org.springframework.cloud.contract.spec.internal does not exist
==========
, ==========
import org.springframework.cloud.contract.spec.internal.Response;
                                                       ^^^^^^^^^
ERROR:package org.springframework.cloud.contract.spec.internal does not exist
==========
, ==========
import org.springframework.cloud.contract.verifier.util.ContractVerifierUtil;
                                                       ^^^^^^^^^^^^^^^^^^^^^
ERROR:package org.springframework.cloud.contract.verifier.util does not exist
==========
, ==========
import static org.assertj.core.util.Lists.newArrayList;
                                   ^^^^^^
ERROR:package org.assertj.core.util does not exist
==========
, ==========
import static org.assertj.core.util.Lists.newArrayList;

We've run out of ideas, so any help is much appreciated. Thanks in advance!

hackus commented 6 months ago

If it may help:

It works if downgrading to gradle-6.8-all and using id "org.springframework.cloud.contract" version "2.2.4.RELEASE"

marcingrzejszczak commented 4 months ago

@shanman190 any ideas what can cause this? Gradle + windows ?

shanman190 commented 4 months ago

@marcingrzejszczak, I don't think that it's a Windows + Gradle sort of problem.

Here's the steps that I'd go through:

  1. Where are the tests located? src/test/resources/contracts/? src/contractTest/resources/contracts/?

  2. Verify the dependencies by their configuration (test=testCompileClasspath, contractTest=contractTestCompileClasspath) with gradlew dependencyInsight --configuration <configuration> --dependency spring-cloud-contract-spec-java since it's failing to compile and the Contract class comes from that jar (repeat for other classes locations).

  3. If Gradle is showing the jars are resolving from a dependency standpoint, I'd go into the Gradle user home and verify it's contents of those jars by looking specifically for the classes that are failing to resolve inside of them.