1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Handle dependency exclusion for tests too.

This commit is contained in:
Cedric Beust 2017-02-10 10:03:24 -08:00
parent 262e1e3a26
commit e03b4527ad
2 changed files with 14 additions and 10 deletions

View file

@ -204,15 +204,6 @@ class CompilerUtils @Inject constructor(val files: KFiles, val dependencyManager
} }
} }
/**
* Naïve implementation: just exclude all dependencies that start with one of the excluded dependencies.
* Should probably make exclusion more generic (full on string) or allow exclusion to be specified
* formally by groupId or artifactId.
*/
private fun isDependencyExcluded(id: IClasspathDependency, excluded: List<IClasspathDependency>)
= excluded.any { id.id.startsWith(it.id) }
fun sourceCompilerFlags(project: Project?, context: KobaltContext, info: CompilerActionInfo) : List<String> { fun sourceCompilerFlags(project: Project?, context: KobaltContext, info: CompilerActionInfo) : List<String> {
val adapters = context.pluginInfo.compilerFlagContributors.map { val adapters = context.pluginInfo.compilerFlagContributors.map {
val closure = { project: Project, context: KobaltContext, currentFlags: List<String>, val closure = { project: Project, context: KobaltContext, currentFlags: List<String>,
@ -234,4 +225,15 @@ class CompilerUtils @Inject constructor(val files: KFiles, val dependencyManager
} }
return result return result
} }
companion object {
/**
* Naïve implementation: just exclude all dependencies that start with one of the excluded dependencies.
* Should probably make exclusion more generic (full on string) or allow exclusion to be specified
* formally by groupId or artifactId.
*/
fun isDependencyExcluded(dep: IClasspathDependency, excluded: List<IClasspathDependency>)
= excluded.any { excluded -> dep.id.startsWith(excluded.id) }
}
} }

View file

@ -91,7 +91,9 @@ open class JvmCompilerPlugin @Inject constructor(
scopes = listOf(Scope.TEST)) scopes = listOf(Scope.TEST))
val compileDependencies = dependencyManager.calculateDependencies(project, context, val compileDependencies = dependencyManager.calculateDependencies(project, context,
scopes = listOf(Scope.COMPILE)) scopes = listOf(Scope.COMPILE))
val allDependencies = (compileDependencies + testDependencies).toHashSet() val allDependencies = (compileDependencies + testDependencies)
.toHashSet()
.filter { ! CompilerUtils.isDependencyExcluded(it, project.excludedDependencies) }
return testContributor.run(project, context, configName, allDependencies.toList()) return testContributor.run(project, context, configName, allDependencies.toList())
} else { } else {
context.logger.log(project.name, 2, context.logger.log(project.name, 2,