bazel: backport java rework from main

This commit is contained in:
Corentin Le Molgat
2025-10-16 12:58:23 +02:00
parent b2e33c1b94
commit b294ff6de2
16 changed files with 358 additions and 201 deletions

View File

@@ -13,16 +13,20 @@
package com.google.ortools.algorithms;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.google.ortools.Loader;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Test the Knapsack solver java interface. */
@RunWith(JUnit4.class)
public final class KnapsackSolverTest {
@BeforeEach
@SuppressWarnings("EmptyMethods")
@Before
public void setUp() {
Loader.loadNativeLibraries();
}

View File

@@ -12,8 +12,9 @@
# limitations under the License.
load("@rules_cc//cc:cc_test.bzl", "cc_test")
load("@rules_java//java:java_test.bzl", "java_test")
load("@rules_java//java:java_binary.bzl", "java_binary")
load("@rules_python//python:py_test.bzl", "py_test")
load("//bazel:run_binary_test.bzl", "run_binary_test")
package(default_visibility = ["//visibility:public"])
@@ -54,13 +55,17 @@ py_test(
deps = ["//ortools/algorithms/python:knapsack_solver"],
)
java_test(
java_binary(
name = "Knapsack",
srcs = ["Knapsack.java"],
main_class = "com.google.ortools.algorithms.samples.Knapsack",
test_class = "com.google.ortools.algorithms.samples.Knapsack",
deps = [
"//ortools/algorithms/java:knapsacksolver",
"//ortools/java/com/google/ortools:Loader",
],
)
run_binary_test(
name = "KnapsackTest",
binary = ":Knapsack",
)