add bazel java POC; works with algorithms and graph

This commit is contained in:
Laurent Perron
2022-12-29 19:56:02 +01:00
parent 01032d0fec
commit 2746b48c5c
19 changed files with 442 additions and 2 deletions

View File

@@ -11,7 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
load(":code_samples.bzl", "code_sample_cc_py")
load(":code_samples.bzl", "code_sample_cc_py", "code_sample_java")
code_sample_cc_py(name = "assignment_linear_sum_assignment")
@@ -22,3 +22,13 @@ code_sample_cc_py(name = "balance_min_flow")
code_sample_cc_py(name = "simple_max_flow_program")
code_sample_cc_py(name = "simple_min_cost_flow_program")
code_sample_java(name = "AssignmentLinearSumAssignment")
code_sample_java(name = "AssignmentMinFlow")
code_sample_java(name = "BalanceMinFlow")
code_sample_java(name = "SimpleMaxFlowProgram")
code_sample_java(name = "SimpleMinCostFlowProgram")

View File

@@ -21,6 +21,7 @@ import com.google.ortools.graph.MaxFlow;
/** Minimal MaxFlow program. */
public final class SimpleMaxFlowProgram {
public static void main(String[] args) throws Exception {
System.loadLibrary("jniortools");
Loader.loadNativeLibraries();
// [START solver]
// Instantiate a SimpleMaxFlow solver.

View File

@@ -85,3 +85,19 @@ def code_sample_py(name):
def code_sample_cc_py(name):
code_sample_cc(name = name)
code_sample_py(name = name)
def code_sample_java(name):
native.java_binary(
name = name + "_java",
srcs = [name + ".java"],
main_class = "com.google.ortools.graph.samples." + name,
data = [
"//ortools/java/com/google/ortools:libjniortools.so",
"//ortools/java/com/google/ortools:libjniortools.dylib",
"//ortools/java/com/google/ortools:jniortools.dll",
],
deps = [
"//ortools/graph/java:graph",
"//ortools/java/com/google/ortools:Loader"
],
)