Skip to content

implementation scope for junit4 #10283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ subprojects {

dependencies {
testImplementation 'ch.qos.logback:logback-classic:1.3.14'
if (project != project(':testcontainers')) {
// in order to compile classes which extend GenericContainer, etc
compileOnly libs.junit4
testImplementation libs.junit4
}
}

checkstyle {
Expand Down
3 changes: 2 additions & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ configurations.all {
}

dependencies {
api 'junit:junit:4.13.2'
// originally was api scope, but that's problematic for projects using junit 5
implementation libs.junit4
api 'org.slf4j:slf4j-api:1.7.36'
compileOnly 'org.jetbrains:annotations:24.1.0'
testCompileOnly 'org.jetbrains:annotations:24.1.0'
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[libraries]
junit4 = { group = "junit", name = "junit", version = "4.13.2" }
3 changes: 3 additions & 0 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ publishing {
def apiDeps= project.configurations.api.resolvedConfiguration.firstLevelModuleDependencies
def providedDeps = project.configurations.provided.resolvedConfiguration.firstLevelModuleDependencies
def newApiDeps = apiDeps - providedDeps
def shaded = project.configurations.shaded.resolvedConfiguration.firstLevelModuleDependencies
def runtimeDeps = project.configurations.runtimeClasspath.resolvedConfiguration.firstLevelModuleDependencies - apiDeps - providedDeps - shaded

def addDependencies = { Set<ResolvedDependency> resolvedDependencies, scope ->
for (dependency in resolvedDependencies) {
Expand Down Expand Up @@ -90,6 +92,7 @@ publishing {
}
addDependencies(newApiDeps, 'compile')
addDependencies(providedDeps, 'provided')
addDependencies(runtimeDeps, 'runtime')
}
}
}
Expand Down