title: Gradle How to include runtimeOnly dependencies in JavaExec classpath?
body: <p>Gradle How to include runtimeOnly dependencies in JavaExec classpath?
  For example, </p>
  
  <p>subproject foo:</p>
  
  <pre><code>dependencies {
      runtimeOnly files('libs/hello.jar')
  }
  </code></pre>
  
  <p>subproject bar:</p>
  
  <pre><code>dependencies {
      compile project(':foo')
  }
  
  task execHello(type: JavaExec, dependsOn: 'compileJava') {      
       classpath = configurations.runtime         
       main 'myPackage.Hello'
  }
  </code></pre>
  
  <p>the main class myPackage.Hello is defined in the libs/hello.jar that is a runtimeOnly dependency for project foo. </p>
  
  <p>configurations.runtime does not contain the runtimeOnly dependency hello.jar. If I changed the runtimeOnly dependency as api dependency in project foo, it will work.</p>
  
  <pre><code>classpath = configurations.runtime + configuration.runtimeOnly
  </code></pre>
  
  <p>Error: runtimeOnly can not be explicitly resolved. How to add the hello.jar in the JavaExec classpath?</p>