title: Spring Cloud Contract Gradle - How to access constants defined in main source set in contract DSL?
body: <p>The question is how to access constants defined in <code>main</code> source set in contract DSL.</p>
  <p>I have a simple class that holds constants - it is part of <code>main</code> SourceSet :</p>
  <pre><code>package io.mkrzywanski.pn.user.app.infra;
  
  import lombok.AccessLevel;
  import lombok.NoArgsConstructor;
  
  @NoArgsConstructor(access = AccessLevel.PRIVATE)
  public final class UserServiceConstants {
      public static final String USER_SERVICE = &quot;user-service&quot;;
  
      public static final class Paths {
          public static final String VERSION = &quot;v1&quot;;
          public static final String USERS = VERSION + &quot;/users&quot;;
      }
  }
  
  </code></pre>
  <p>I would like to access constants defined in this class in my contract class :</p>
  <pre><code>import io.mkrzywanski.pn.user.app.infra.UserServiceConstants
  import org.springframework.cloud.contract.spec.Contract
  
  Contract.make {
      request {
          method(GET())
          url(&quot;/v1/users/1&quot;)
      }
      response {
          headers {
              header 'Content-Type': 'application/json'
          }
          status(404)
          body([
                  timestamp: &quot;${nonEmpty()}&quot;,
                  message  : &quot;User with id ${fromRequest().path(2)} not found&quot;,
                  status   : 404,
                  serviceName: &quot;${UserServiceConstants.USER_SERVICE}&quot;,
                  path: &quot;${UserServiceConstants.Paths.USERS}&quot;
          ])
      }
  }
  </code></pre>
  <p>However when <code>generateContractTests</code> task is invoked in gradle I receive compilation error:</p>
  <pre><code>@ line 3, column 1.
     import io.mkrzywanski.pn.user.app.infra.UserServiceConstants.
  userDetailsNotFound.groovy: 3: unable to resolve class io.mkrzywanski.pn.user.app.infra.UserServiceConstants
  </code></pre>
  <p>I know that it is possible to have a separate jar with classes which could be added to the test scope but I kinda do not understand why the former does not work.</p>