do not warn "Expected no module/library non-runtime dependencies for resource-only module for" if we have test sources

GitOrigin-RevId: 594fd09a6e1cced735280018653f813a7f407ca5
This commit is contained in:
Vladimir Krivosheev
2025-05-05 07:58:29 +02:00
committed by intellij-monorepo-bot
parent 0d895183f7
commit e44a609c9d
5 changed files with 92 additions and 6 deletions

View File

@@ -0,0 +1,21 @@
### auto-generated section `build intellij.libraries.hamcrest.more.matchers` start
load("@rules_java//java:defs.bzl", "java_library")
load("@rules_jvm//:jvm.bzl", "jvm_resources")
jvm_resources(
name = "hamcrest-more-matchers_resources",
files = glob(["resources/**/*"]),
strip_prefix = "resources"
)
java_library(
name = "hamcrest-more-matchers",
visibility = ["//visibility:public"],
exports = ["@lib//:libraries-hamcrest-more-matchers-github-seregamorph-hamcrest-more-matchers"],
runtime_deps = [
":hamcrest-more-matchers_resources",
"//libraries/hamcrest",
"@lib//:libraries-hamcrest-more-matchers-github-seregamorph-hamcrest-more-matchers",
]
)
### auto-generated section `build intellij.libraries.hamcrest.more.matchers` end

View File

@@ -0,0 +1,21 @@
### auto-generated section `build intellij.libraries.junit5.params` start
load("@rules_java//java:defs.bzl", "java_library")
load("@rules_jvm//:jvm.bzl", "jvm_resources")
jvm_resources(
name = "junit5-params_resources",
files = glob(["resources/**/*"]),
strip_prefix = "resources"
)
java_library(
name = "junit5-params",
visibility = ["//visibility:public"],
exports = ["@lib//:junit5Params"],
runtime_deps = [
":junit5-params_resources",
"@lib//:junit5Params",
"//libraries/junit5",
]
)
### auto-generated section `build intellij.libraries.junit5.params` end

View File

@@ -0,0 +1,22 @@
### auto-generated section `build intellij.libraries.junit5.pioneer` start
load("@rules_java//java:defs.bzl", "java_library")
load("@rules_jvm//:jvm.bzl", "jvm_resources")
jvm_resources(
name = "junit5-pioneer_resources",
files = glob(["resources/**/*"]),
strip_prefix = "resources"
)
java_library(
name = "junit5-pioneer",
visibility = ["//visibility:public"],
exports = ["@lib//:junit5Pioneer"],
runtime_deps = [
":junit5-pioneer_resources",
"@lib//:junit5Pioneer",
"//libraries/junit5-launcher",
"//libraries/junit5-params",
]
)
### auto-generated section `build intellij.libraries.junit5.pioneer` end

View File

@@ -0,0 +1,20 @@
### auto-generated section `build intellij.libraries.testcontainers` start
load("@rules_java//java:defs.bzl", "java_library")
load("@rules_jvm//:jvm.bzl", "jvm_resources")
jvm_resources(
name = "testcontainers_resources",
files = glob(["resources/**/*"]),
strip_prefix = "resources"
)
java_library(
name = "testcontainers",
visibility = ["//visibility:public"],
exports = ["@lib//:testcontainers"],
runtime_deps = [
":testcontainers_resources",
"//libraries/junit4",
]
)
### auto-generated section `build intellij.libraries.testcontainers` end

View File

@@ -1,4 +1,6 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. // Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
@file:Suppress("ReplacePutWithAssignment")
package org.jetbrains.intellij.build.bazel package org.jetbrains.intellij.build.bazel
import com.intellij.openapi.util.NlsSafe import com.intellij.openapi.util.NlsSafe
@@ -30,8 +32,8 @@ internal class ModuleList(
@JvmField val ultimate: List<ModuleDescriptor>, @JvmField val ultimate: List<ModuleDescriptor>,
val skippedModules: List<String>, val skippedModules: List<String>,
) { ) {
val deps = IdentityHashMap<ModuleDescriptor, ModuleDeps>() @JvmField val deps = IdentityHashMap<ModuleDescriptor, ModuleDeps>()
val testDeps = IdentityHashMap<ModuleDescriptor, ModuleDeps>() @JvmField val testDeps = IdentityHashMap<ModuleDescriptor, ModuleDeps>()
} }
@Suppress("ReplaceGetOrSet") @Suppress("ReplaceGetOrSet")
@@ -520,10 +522,10 @@ internal class BazelBuildFileGenerator(
module: ModuleDescriptor, module: ModuleDescriptor,
forTests: Boolean, forTests: Boolean,
): GenerateResourcesResult { ): GenerateResourcesResult {
if (module.sources.isEmpty() && !(module.module.dependenciesList.dependencies.none { if (module.sources.isEmpty() && module.testSources.isEmpty() && !(module.module.dependenciesList.dependencies.none { element ->
when (it) { // -- require when (element) {
is JpsModuleDependency, is JpsLibraryDependency -> { is JpsModuleDependency, is JpsLibraryDependency -> {
val scope = javaExtensionService.getDependencyExtension(it)?.scope val scope = javaExtensionService.getDependencyExtension(element)?.scope
scope != JpsJavaDependencyScope.TEST && scope != JpsJavaDependencyScope.RUNTIME scope != JpsJavaDependencyScope.TEST && scope != JpsJavaDependencyScope.RUNTIME
} }
else -> false else -> false
@@ -659,7 +661,7 @@ private fun extraResourceTarget(
.mapNotNull { sourceRoot -> .mapNotNull { sourceRoot ->
val sourceRootDir = sourceRoot.path val sourceRootDir = sourceRoot.path
val metaInf = sourceRootDir.resolve("META-INF") val metaInf = sourceRootDir.resolve("META-INF")
if (!Files.exists(metaInf)) { if (Files.notExists(metaInf)) {
return@mapNotNull null return@mapNotNull null
} }