Skip to content
This repository was archived by the owner on Dec 3, 2025. It is now read-only.
This repository was archived by the owner on Dec 3, 2025. It is now read-only.

sourceSets example complete with extendsFrom for configuration and compileClasspath inheritance #1402

@hmarggraff

Description

@hmarggraff

I have not found a way to translate the groovy definition of a source Set for integration tests into the Kotlin DSL.

What I want:

  1. Place integration tests in a separate source directory src/itest/kotlin
  2. Make the classes from main sourceSet visible there via compileClasspath/runtimeClasspath
  3. Add a specific dependency for the integration tests
  4. Create a task that runs the integration tests

The groovy example is taken from here: https://www.petrikainulainen.net/programming/gradle/getting-started-with-gradle-integration-testing/

Groovy:
sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration-test/java')
}
resources.srcDir file('src/integration-test/resources')
}
}
configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}
dependencies {
compile 'log4j:log4j:1.2.17'
testCompile 'junit:junit:4.11'
integrationTestCompile 'org.assertj:assertj-core:3.0.0'
}
task integrationTest(type: Test) {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
outputs.upToDateWhen { false }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions