Note that there are some explanatory texts on larger screens.

plurals
  1. POBuilding a test support artifact with dependencies
    primarykey
    data
    text
    <p>I've got a situation where my source has both tests and some test support code, along with the usual source code. I want to be able to publish both the source and the test support as separate artifacts (each with its own set of dependencies), but obviously not the test classes.</p> <p>My directory structure looks like this:</p> <pre><code>src/main/... src/test/... src/testsupport/... </code></pre> <p>I have some dependencies defined, as per usual:</p> <pre><code>dependencies { compile 'com.sun.jersey:jersey-core:1.17.1' ... more compile dependencies... testCompile 'com.google.code.gson:gson:2.1' ... more testCompile dependencies... } </code></pre> <p>I also need the test support sourceSet:</p> <pre><code>sourceSets { testSupport { java { srcDir 'src/testsupport/java' } resources { srcDir 'src/testsupport/resources' } compileClasspath += sourceSets.test.compileClasspath runtimeClasspath += sourceSets.test.runtimeClasspath } } </code></pre> <p>I have to add the test classpaths to the testSupport ones because the testsupport code has the same dependencies.</p> <p>Finally, to create my artifact, I have:</p> <pre><code>task createTestSupportArtifact (type: Jar) { classifier = 'testsupport' from sourceSets.testSupport.output } artifacts { archives file: createTestSupportArtifact.archivePath, builtBy: createTestSupportArtifact } </code></pre> <p>However, in my other repository that depends on these artifacts, it's not pulling in any dependencies for the testsupport artifact. I have a few theories as to why (it doesn't have it's own POM or it doesn't know the scope is test at runtime), but nothing concrete.</p> <p>Is there a better approach to this? Perhaps using <code>configurations</code> intelligently?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload