Last active
April 18, 2022 01:48
-
-
Save michail-nikolaev/3980346 to your computer and use it in GitHub Desktop.
Gradle - dependency to test classes of another module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use test classes from spring-common as dependency to tests of current module | |
testCompile files(this.project(':spring-common').sourceSets.test.output) | |
// use testCompile dependencies from spring-common as dependency to tests of current module | |
testCompile files(this.project(':spring-common').sourceSets.test.runtimeClasspath) | |
def isClassesDependency(module) { | |
(module instanceof org.gradle.plugins.ide.idea.model.ModuleLibrary) && module.classes.iterator()[0].url.toString().contains(rootProject.name) | |
} | |
idea { | |
module { | |
scopes.PROVIDED.plus += configurations.provided | |
iml.whenMerged { module -> | |
module.dependencies.removeAll(module.dependencies.grep{isClassesDependency(it)}) | |
module.dependencies*.exported = true | |
} | |
} | |
} | |
// and somewhere to include test classes | |
testRuntime project(":spring-common") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment