cmake(java): Add Maven Package (#202)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# This file is just an orchestration
|
||||
cmake_minimum_required(VERSION 3.8.2)
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
# Apple: Don't modify install_name when touching RPATH.
|
||||
|
||||
207
cmake/java.cmake
207
cmake/java.cmake
@@ -3,7 +3,7 @@ if(NOT BUILD_JAVA)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET ortools::ortools)
|
||||
message(FATAL_ERROR "Java: missing ortools TARGET")
|
||||
message(FATAL_ERROR "Java: missing ortools::ortools TARGET")
|
||||
endif()
|
||||
|
||||
# Will need swig
|
||||
@@ -19,47 +19,39 @@ if(UNIX AND NOT APPLE)
|
||||
list(APPEND CMAKE_SWIG_FLAGS "-DSWIGWORDSIZE64")
|
||||
endif()
|
||||
|
||||
# Generate Protobuf java sources
|
||||
set(PROTO_JAVAS)
|
||||
file(GLOB_RECURSE proto_java_files RELATIVE ${PROJECT_SOURCE_DIR}
|
||||
"ortools/constraint_solver/*.proto"
|
||||
"ortools/linear_solver/*.proto"
|
||||
"ortools/sat/*.proto"
|
||||
"ortools/util/*.proto"
|
||||
)
|
||||
list(REMOVE_ITEM proto_java_files "ortools/constraint_solver/demon_profiler.proto")
|
||||
foreach(PROTO_FILE ${proto_java_files})
|
||||
#message(STATUS "protoc proto(java): ${PROTO_FILE}")
|
||||
get_filename_component(PROTO_DIR ${PROTO_FILE} DIRECTORY)
|
||||
get_filename_component(PROTO_NAME ${PROTO_FILE} NAME_WE)
|
||||
set(PROTO_JAVA ${PROJECT_BINARY_DIR}/java/com/google/${PROTO_DIR}/${PROTO_NAME}.java)
|
||||
#message(STATUS "protoc java: ${PROTO_JAVA}")
|
||||
add_custom_command(
|
||||
OUTPUT ${PROTO_JAVA}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/java/com/google/${PROTO_DIR}
|
||||
COMMAND protobuf::protoc
|
||||
"--proto_path=${PROJECT_SOURCE_DIR}"
|
||||
"--java_out=${PROJECT_BINARY_DIR}/java/com/google/${PROTO_DIR}"
|
||||
${PROTO_FILE}
|
||||
DEPENDS ${PROTO_FILE} protobuf::protoc
|
||||
COMMENT "Generate Java protocol buffer for ${PROTO_FILE}"
|
||||
VERBATIM)
|
||||
list(APPEND PROTO_JAVAS ${PROTO_JAVA})
|
||||
endforeach()
|
||||
add_custom_target(Java${PROJECT_NAME}_proto DEPENDS ${PROTO_JAVAS} ortools::ortools)
|
||||
|
||||
# Setup Java
|
||||
find_package(Java 1.8 REQUIRED COMPONENTS Development)
|
||||
# Find Java
|
||||
find_package(Java 1.8 COMPONENTS Development REQUIRED)
|
||||
find_package(JNI REQUIRED)
|
||||
|
||||
# Find maven
|
||||
find_program(MAVEN_EXECUTABLE mvn)
|
||||
# On windows mvn spawn a process while mvn.cmd is a blocking command
|
||||
if(UNIX)
|
||||
find_program(MAVEN_EXECUTABLE mvn)
|
||||
else()
|
||||
find_program(MAVEN_EXECUTABLE mvn.cmd)
|
||||
endif()
|
||||
if(NOT MAVEN_EXECUTABLE)
|
||||
message(FATAL_ERROR "Check for maven Program: not found")
|
||||
else()
|
||||
message(STATUS "Found Maven: ${MAVEN_EXECUTABLE}")
|
||||
endif()
|
||||
|
||||
# Needed by java/CMakeLists.txt
|
||||
set(JAVA_PACKAGE com.google.ortools)
|
||||
set(JAVA_PACKAGE_PATH src/main/java/com/google/ortools)
|
||||
set(JAVA_RESOURCES_PATH src/main/resources)
|
||||
if(APPLE)
|
||||
set(NATIVE_IDENTIFIER darwin)
|
||||
elseif(UNIX)
|
||||
set(NATIVE_IDENTIFIER linux-x86-64)
|
||||
elseif(WIN32)
|
||||
set(NATIVE_IDENTIFIER win32-x86-64)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported system !")
|
||||
endif()
|
||||
set(JAVA_NATIVE_PROJECT ortools-${NATIVE_IDENTIFIER})
|
||||
set(JAVA_PROJECT ortools-java)
|
||||
|
||||
# CMake will remove all '-D' prefix (i.e. -DUSE_FOO become USE_FOO)
|
||||
#get_target_property(FLAGS ortools::ortools COMPILE_DEFINITIONS)
|
||||
set(FLAGS -DUSE_BOP -DUSE_GLOP -DABSL_MUST_USE_RESULT)
|
||||
@@ -71,6 +63,38 @@ if(USE_COINOR)
|
||||
endif()
|
||||
list(APPEND CMAKE_SWIG_FLAGS ${FLAGS} "-I${PROJECT_SOURCE_DIR}")
|
||||
|
||||
# Generate Protobuf java sources
|
||||
set(PROTO_JAVAS)
|
||||
file(GLOB_RECURSE proto_java_files RELATIVE ${PROJECT_SOURCE_DIR}
|
||||
"ortools/constraint_solver/*.proto"
|
||||
"ortools/linear_solver/*.proto"
|
||||
"ortools/sat/*.proto"
|
||||
"ortools/util/*.proto"
|
||||
)
|
||||
list(REMOVE_ITEM proto_java_files "ortools/constraint_solver/demon_profiler.proto")
|
||||
list(REMOVE_ITEM proto_java_files "ortools/constraint_solver/assignment.proto")
|
||||
foreach(PROTO_FILE ${proto_java_files})
|
||||
#message(STATUS "protoc proto(java): ${PROTO_FILE}")
|
||||
get_filename_component(PROTO_DIR ${PROTO_FILE} DIRECTORY)
|
||||
string(REGEX REPLACE "_" "" PROTO_DIR ${PROTO_DIR})
|
||||
get_filename_component(PROTO_NAME ${PROTO_FILE} NAME_WE)
|
||||
set(PROTO_OUT ${PROJECT_BINARY_DIR}/java/${JAVA_PROJECT}/src/main/java/com/google/${PROTO_DIR})
|
||||
set(PROTO_JAVA ${PROTO_OUT}/${PROTO_NAME}.java)
|
||||
#message(STATUS "protoc java: ${PROTO_JAVA}")
|
||||
add_custom_command(
|
||||
OUTPUT ${PROTO_JAVA}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${PROTO_OUT}
|
||||
COMMAND protobuf::protoc
|
||||
"--proto_path=${PROJECT_SOURCE_DIR}"
|
||||
"--java_out=${PROJECT_BINARY_DIR}/java/${JAVA_PROJECT}/src/main/java"
|
||||
${PROTO_FILE}
|
||||
DEPENDS ${PROTO_FILE} protobuf::protoc
|
||||
COMMENT "Generate Java protocol buffer for ${PROTO_FILE}"
|
||||
VERBATIM)
|
||||
list(APPEND PROTO_JAVAS ${PROTO_JAVA})
|
||||
endforeach()
|
||||
add_custom_target(Java${PROJECT_NAME}_proto DEPENDS ${PROTO_JAVAS} ortools::ortools)
|
||||
|
||||
# Create the native library
|
||||
add_library(jniortools SHARED "")
|
||||
set_target_properties(jniortools PROPERTIES
|
||||
@@ -78,47 +102,114 @@ set_target_properties(jniortools PROPERTIES
|
||||
# note: macOS is APPLE and also UNIX !
|
||||
if(APPLE)
|
||||
set_target_properties(jniortools PROPERTIES INSTALL_RPATH "@loader_path")
|
||||
# Xcode fails to build if library doesn't contains at least one source file.
|
||||
if(XCODE)
|
||||
file(GENERATE
|
||||
OUTPUT ${PROJECT_BINARY_DIR}/jniortools/version.cpp
|
||||
CONTENT "namespace {char* version = \"${PROJECT_VERSION}\";}")
|
||||
target_sources(jniortools PRIVATE ${PROJECT_BINARY_DIR}/jniortools/version.cpp)
|
||||
endif()
|
||||
elseif(UNIX)
|
||||
set_target_properties(jniortools PROPERTIES INSTALL_RPATH "$ORIGIN")
|
||||
endif()
|
||||
|
||||
# Swig wrap all libraries
|
||||
set(OR_TOOLS_JAVA com.google.ortools)
|
||||
foreach(SUBPROJECT IN ITEMS algorithms graph linear_solver constraint_solver sat util)
|
||||
add_subdirectory(ortools/${SUBPROJECT}/java)
|
||||
target_link_libraries(jniortools PRIVATE java_${SUBPROJECT})
|
||||
target_link_libraries(jniortools PRIVATE jni${SUBPROJECT})
|
||||
endforeach()
|
||||
|
||||
####################
|
||||
## Java package ##
|
||||
####################
|
||||
file(GENERATE OUTPUT java/$<CONFIG>/replace.cmake
|
||||
CONTENT
|
||||
"FILE(READ ${PROJECT_SOURCE_DIR}/ortools/java/pom.xml.in input)
|
||||
STRING(REPLACE \"@PROJECT_VERSION@\" \"${PROJECT_VERSION}\" input \"\${input}\")
|
||||
STRING(REPLACE \"@ortools@\" \"$<TARGET_FILE:${PROJECT_NAME}>\" input \"\${input}\")
|
||||
STRING(REPLACE \"@native@\" \"$<TARGET_FILE:jniortools>\" input \"\${input}\")
|
||||
FILE(WRITE pom.xml \"\${input}\")"
|
||||
)
|
||||
#################################
|
||||
## Java Native Maven Package ##
|
||||
#################################
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/ortools/java/pom-native.xml.in
|
||||
${PROJECT_BINARY_DIR}/java/pom-native.xml.in
|
||||
@ONLY)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT java/pom.xml
|
||||
COMMAND ${CMAKE_COMMAND} -P ./$<CONFIG>/replace.cmake
|
||||
WORKING_DIRECTORY java
|
||||
)
|
||||
OUTPUT java/${JAVA_NATIVE_PROJECT}/pom.xml
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/java/pom-native.xml.in
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${JAVA_NATIVE_PROJECT}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ./pom-native.xml.in ${JAVA_NATIVE_PROJECT}/pom.xml
|
||||
BYPRODUCTS
|
||||
java/${JAVA_NATIVE_PROJECT}
|
||||
WORKING_DIRECTORY java)
|
||||
|
||||
add_custom_target(java_native_package
|
||||
DEPENDS
|
||||
java/${JAVA_NATIVE_PROJECT}/pom.xml
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory src
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${JAVA_RESOURCES_PATH}/${NATIVE_IDENTIFIER}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
$<TARGET_FILE:jniortools>
|
||||
$<$<NOT:$<PLATFORM_ID:Windows>>:$<TARGET_SONAME_FILE:${PROJECT_NAME}>>
|
||||
${JAVA_RESOURCES_PATH}/${NATIVE_IDENTIFIER}/
|
||||
COMMAND ${MAVEN_EXECUTABLE} compile
|
||||
COMMAND ${MAVEN_EXECUTABLE} package
|
||||
COMMAND ${MAVEN_EXECUTABLE} install
|
||||
WORKING_DIRECTORY java/${JAVA_NATIVE_PROJECT})
|
||||
|
||||
##########################
|
||||
## Java Maven Package ##
|
||||
##########################
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/ortools/java/pom-local.xml.in
|
||||
${PROJECT_BINARY_DIR}/java/pom-local.xml.in
|
||||
@ONLY)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT java/${JAVA_PROJECT}/pom.xml
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/java/pom-local.xml.in
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${JAVA_PROJECT}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ./pom-local.xml.in ${JAVA_PROJECT}/pom.xml
|
||||
BYPRODUCTS
|
||||
java/${JAVA_PROJECT}
|
||||
WORKING_DIRECTORY java)
|
||||
|
||||
# Main Target
|
||||
add_custom_target(java_package ALL
|
||||
DEPENDS
|
||||
ortools::ortools
|
||||
Java${PROJECT_NAME}_proto
|
||||
jniortools
|
||||
java/pom.xml
|
||||
java/${JAVA_PROJECT}/pom.xml
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/ortools/java/com src/main/java/com
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ortools/java/Loader.java ${JAVA_PACKAGE_PATH}/
|
||||
COMMAND ${MAVEN_EXECUTABLE} compile
|
||||
COMMAND ${MAVEN_EXECUTABLE} package
|
||||
WORKING_DIRECTORY java
|
||||
)
|
||||
COMMAND ${MAVEN_EXECUTABLE} install
|
||||
WORKING_DIRECTORY java/${JAVA_PROJECT})
|
||||
add_dependencies(java_package java_native_package Java${PROJECT_NAME}_proto)
|
||||
|
||||
# Test
|
||||
#################
|
||||
## Java Test ##
|
||||
#################
|
||||
set(JAVA_TEST_PROJECT ortools-test)
|
||||
if(BUILD_TESTING)
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/ortools/java/pom-test.xml.in
|
||||
${PROJECT_BINARY_DIR}/java/pom-test.xml.in
|
||||
@ONLY)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT java/${JAVA_TEST_PROJECT}/pom.xml
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${JAVA_TEST_PROJECT}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ./pom-test.xml.in ${JAVA_TEST_PROJECT}/pom.xml
|
||||
BYPRODUCTS
|
||||
java/${JAVA_TEST_PROJECT}
|
||||
WORKING_DIRECTORY java)
|
||||
|
||||
add_custom_target(java_test_package ALL
|
||||
DEPENDS
|
||||
java/${JAVA_TEST_PROJECT}/pom.xml
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory src
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${JAVA_PACKAGE_PATH}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ortools/java/Test.java ${JAVA_PACKAGE_PATH}/
|
||||
COMMAND ${MAVEN_EXECUTABLE} compile
|
||||
COMMAND ${MAVEN_EXECUTABLE} package
|
||||
WORKING_DIRECTORY java/${JAVA_TEST_PROJECT})
|
||||
add_dependencies(java_test_package java_package)
|
||||
|
||||
add_test(
|
||||
NAME JavaTest
|
||||
COMMAND ${MAVEN_EXECUTABLE} exec:java -Dexec.mainClass=com.google.ortools.Test
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/java/${JAVA_TEST_PROJECT})
|
||||
#add_subdirectory(examples/java)
|
||||
endif()
|
||||
|
||||
@@ -3,15 +3,16 @@ set_property(SOURCE knapsack_solver.i PROPERTY SWIG_MODULE_NAME main)
|
||||
set_property(SOURCE knapsack_solver.i PROPERTY COMPILE_DEFINITIONS
|
||||
${OR_TOOLS_COMPILE_DEFINITIONS} ABSL_MUST_USE_RESULT)
|
||||
set_property(SOURCE knapsack_solver.i PROPERTY COMPILE_OPTIONS
|
||||
-package ${OR_TOOLS_JAVA}.algorithms)
|
||||
swig_add_library(java_algorithms
|
||||
-package ${JAVA_PACKAGE}.algorithms)
|
||||
swig_add_library(jnialgorithms
|
||||
TYPE OBJECT
|
||||
LANGUAGE java
|
||||
OUTPUT_DIR ${PROJECT_BINARY_DIR}/java/com/google/${PROJECT_NAME}/algorithms
|
||||
OUTPUT_DIR
|
||||
${PROJECT_BINARY_DIR}/java/${JAVA_PROJECT}/${JAVA_PACKAGE_PATH}/algorithms
|
||||
SOURCES knapsack_solver.i)
|
||||
|
||||
target_include_directories(java_algorithms PRIVATE ${JNI_INCLUDE_DIRS})
|
||||
set_target_properties(java_algorithms PROPERTIES
|
||||
target_include_directories(jnialgorithms PRIVATE ${JNI_INCLUDE_DIRS})
|
||||
set_target_properties(jnialgorithms PROPERTIES
|
||||
SWIG_USE_TARGET_INCLUDE_DIRECTORIES ON
|
||||
POSITION_INDEPENDENT_CODE ON)
|
||||
target_link_libraries(java_algorithms PRIVATE ortools::ortools)
|
||||
target_link_libraries(jnialgorithms PRIVATE ortools::ortools)
|
||||
|
||||
@@ -807,8 +807,8 @@ class Solver {
|
||||
///
|
||||
/// - the most common use case is modeling: the given constraint is really
|
||||
/// part of the problem that the user is trying to solve. In this use case,
|
||||
/// AddConstraint is called outside of search (i.e., with <tt>state() ==
|
||||
/// OUTSIDE_SEARCH</tt>). Most users should only use AddConstraint in this
|
||||
/// AddConstraint is called outside of search (i.e., with @code state() ==
|
||||
/// OUTSIDE_SEARCH @endcode). Most users should only use AddConstraint in this
|
||||
/// way. In this case, the constraint will belong to the model forever: it
|
||||
/// cannot not be removed by backtracking.
|
||||
///
|
||||
@@ -3099,8 +3099,8 @@ inline int64 Zero() { return 0; }
|
||||
inline int64 One() { return 1; }
|
||||
|
||||
/// A BaseObject is the root of all reversibly allocated objects.
|
||||
/// A DebugString method and the associated << operator are implemented
|
||||
/// as a convenience.
|
||||
/// A DebugString method and the associated @code operator<< @endcode
|
||||
/// are implemented as a convenience.
|
||||
class BaseObject {
|
||||
public:
|
||||
BaseObject() {}
|
||||
|
||||
@@ -3,15 +3,16 @@ set_property(SOURCE routing.i PROPERTY SWIG_MODULE_NAME main)
|
||||
set_property(SOURCE routing.i PROPERTY COMPILE_DEFINITIONS
|
||||
${OR_TOOLS_COMPILE_DEFINITIONS} ABSL_MUST_USE_RESULT)
|
||||
set_property(SOURCE routing.i PROPERTY COMPILE_OPTIONS
|
||||
-package ${OR_TOOLS_JAVA}.constraintsolver)
|
||||
swig_add_library(java_constraint_solver
|
||||
-package ${JAVA_PACKAGE}.constraintsolver)
|
||||
swig_add_library(jniconstraint_solver
|
||||
TYPE OBJECT
|
||||
LANGUAGE java
|
||||
OUTPUT_DIR ${PROJECT_BINARY_DIR}/java/com/google/${PROJECT_NAME}/constraintsolver
|
||||
OUTPUT_DIR
|
||||
${PROJECT_BINARY_DIR}/java/${JAVA_PROJECT}/${JAVA_PACKAGE_PATH}/constraintsolver
|
||||
SOURCES routing.i)
|
||||
|
||||
target_include_directories(java_constraint_solver PRIVATE ${JNI_INCLUDE_DIRS})
|
||||
set_target_properties(java_constraint_solver PROPERTIES
|
||||
target_include_directories(jniconstraint_solver PRIVATE ${JNI_INCLUDE_DIRS})
|
||||
set_target_properties(jniconstraint_solver PROPERTIES
|
||||
SWIG_USE_TARGET_INCLUDE_DIRECTORIES ON
|
||||
POSITION_INDEPENDENT_CODE ON)
|
||||
target_link_libraries(java_constraint_solver PRIVATE ortools::ortools)
|
||||
target_link_libraries(jniconstraint_solver PRIVATE ortools::ortools)
|
||||
|
||||
@@ -74,7 +74,7 @@ class RoutingIndexManager {
|
||||
return index_to_node_[index];
|
||||
}
|
||||
// TODO(user): Remove when removal of NodeIndex from RoutingModel is
|
||||
/// complete.
|
||||
// complete.
|
||||
int num_unique_depots() const { return num_unique_depots_; }
|
||||
std::vector<NodeIndex> GetIndexToNodeMap() const { return index_to_node_; }
|
||||
gtl::ITIVector<NodeIndex, int64> GetNodeToIndexMap() const {
|
||||
|
||||
@@ -3,15 +3,16 @@ set_property(SOURCE graph.i PROPERTY SWIG_MODULE_NAME main)
|
||||
set_property(SOURCE graph.i PROPERTY COMPILE_DEFINITIONS
|
||||
${OR_TOOLS_COMPILE_DEFINITIONS} ABSL_MUST_USE_RESULT)
|
||||
set_property(SOURCE graph.i PROPERTY COMPILE_OPTIONS
|
||||
-package ${OR_TOOLS_JAVA}.graph)
|
||||
swig_add_library(java_graph
|
||||
-package ${JAVA_PACKAGE}.graph)
|
||||
swig_add_library(jnigraph
|
||||
TYPE OBJECT
|
||||
LANGUAGE java
|
||||
OUTPUT_DIR ${PROJECT_BINARY_DIR}/java/com/google/${PROJECT_NAME}/graph
|
||||
OUTPUT_DIR
|
||||
${PROJECT_BINARY_DIR}/java/${JAVA_PROJECT}/${JAVA_PACKAGE_PATH}/graph
|
||||
SOURCES graph.i)
|
||||
|
||||
target_include_directories(java_graph PRIVATE ${JNI_INCLUDE_DIRS})
|
||||
set_target_properties(java_graph PROPERTIES
|
||||
target_include_directories(jnigraph PRIVATE ${JNI_INCLUDE_DIRS})
|
||||
set_target_properties(jnigraph PROPERTIES
|
||||
SWIG_USE_TARGET_INCLUDE_DIRECTORIES ON
|
||||
POSITION_INDEPENDENT_CODE ON)
|
||||
target_link_libraries(java_graph PRIVATE ortools::ortools)
|
||||
target_link_libraries(jnigraph PRIVATE ortools::ortools)
|
||||
|
||||
93
ortools/java/Loader.java
Normal file
93
ortools/java/Loader.java
Normal file
@@ -0,0 +1,93 @@
|
||||
package com.google.ortools;
|
||||
|
||||
import com.sun.jna.Platform;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
|
||||
/** Load native libraries needed for using ortools-java.*/
|
||||
public class Loader {
|
||||
/** Try to locate the native libraries directory.*/
|
||||
private static URI getNativeResourceURI() throws IOException {
|
||||
ClassLoader loader = Loader.class.getClassLoader();
|
||||
String resource = Platform.RESOURCE_PREFIX + "/";
|
||||
URL resourceURL = loader.getResource(resource);
|
||||
Objects.requireNonNull(resourceURL,
|
||||
String.format("Resource %s was not found in ClassLoader %s",
|
||||
resource,
|
||||
loader));
|
||||
|
||||
URI resourceURI;
|
||||
try {
|
||||
resourceURI = resourceURL.toURI();
|
||||
} catch (URISyntaxException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
return resourceURI;
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private interface PathConsumer<T extends IOException> {
|
||||
void accept(Path path) throws T;
|
||||
}
|
||||
|
||||
/** Extract native resources in a temp directory.
|
||||
* @param resourceURI Native resource location.
|
||||
* @return The directory path containing all extracted libraries.
|
||||
*/
|
||||
private static Path unpackNativeResources(URI resourceURI) throws IOException {
|
||||
Path tempPath;
|
||||
tempPath = Files.createTempDirectory("ortools-java");
|
||||
tempPath.toFile().deleteOnExit();
|
||||
|
||||
PathConsumer<?> visitor;
|
||||
visitor = (Path sourcePath) -> Files.walkFileTree(sourcePath, new SimpleFileVisitor<Path>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
Path newPath = tempPath.resolve(sourcePath.getParent().relativize(file).toString());
|
||||
Files.copy(file, newPath);
|
||||
newPath.toFile().deleteOnExit();
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
|
||||
Path newPath = tempPath.resolve(sourcePath.getParent().relativize(dir).toString());
|
||||
Files.copy(dir, newPath);
|
||||
newPath.toFile().deleteOnExit();
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
});
|
||||
|
||||
FileSystem fs = FileSystems.newFileSystem(resourceURI, Collections.emptyMap());
|
||||
Path p = fs.provider().getPath(resourceURI);
|
||||
visitor.accept(p);
|
||||
return tempPath;
|
||||
}
|
||||
|
||||
/** Unpack and Load the native libraries needed for using ortools-java.*/
|
||||
public static void loadNativeLibraries() {
|
||||
try {
|
||||
URI resourceURI = getNativeResourceURI();
|
||||
Path tempPath = unpackNativeResources(resourceURI);
|
||||
// Load the native library
|
||||
System.load(
|
||||
tempPath.resolve(Platform.RESOURCE_PREFIX)
|
||||
.resolve(System.mapLibraryName("jniortools"))
|
||||
.toString());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
40
ortools/java/Test.java
Normal file
40
ortools/java/Test.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.google.ortools;
|
||||
|
||||
import com.google.ortools.Loader;
|
||||
|
||||
import com.google.ortools.linearsolver.MPConstraint;
|
||||
import com.google.ortools.linearsolver.MPObjective;
|
||||
import com.google.ortools.linearsolver.MPSolver;
|
||||
import com.google.ortools.linearsolver.MPVariable;
|
||||
|
||||
/**
|
||||
* @author Mizux
|
||||
*/
|
||||
public class Test {
|
||||
private static void testLP() {
|
||||
MPSolver solver =
|
||||
new MPSolver("SimpleLpProgram", MPSolver.OptimizationProblemType.GLOP_LINEAR_PROGRAMMING);
|
||||
MPVariable x = solver.makeNumVar(0.0, 1.0, "x");
|
||||
MPVariable y = solver.makeNumVar(0.0, 2.0, "y");
|
||||
System.out.println("Number of variables = " + solver.numVariables());
|
||||
MPConstraint ct = solver.makeConstraint(0.0, 2.0, "ct");
|
||||
ct.setCoefficient(x, 1);
|
||||
ct.setCoefficient(y, 1);
|
||||
System.out.println("Number of constraints = " + solver.numConstraints());
|
||||
MPObjective objective = solver.objective();
|
||||
objective.setCoefficient(x, 3);
|
||||
objective.setCoefficient(y, 1);
|
||||
objective.setMaximization();
|
||||
solver.solve();
|
||||
System.out.println("Solution:");
|
||||
System.out.println("Objective value = " + objective.value());
|
||||
System.out.println("x = " + x.solutionValue());
|
||||
System.out.println("y = " + y.solutionValue());
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Loader.loadNativeLibraries();
|
||||
testLP();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,10 @@ package com.google.ortools.constraintsolver;
|
||||
/**
|
||||
* Represents a function that accepts two int-valued arguments and produces a
|
||||
* long-valued result. This is the {@code int}{@code int}-to-{@code long} primitive
|
||||
* specialization for {@link Function}.
|
||||
* specialization for {@code Function}.
|
||||
*
|
||||
* <p>This is a functional interface
|
||||
* whose functional method is {@link #applyAsLong(long, long)}.
|
||||
* @see Function
|
||||
* @see IntToLongFunction.
|
||||
* whose functional method is {@link #applyAsLong(int, int)}.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface IntIntToLongFunction {
|
||||
|
||||
@@ -20,8 +20,6 @@ package com.google.ortools.constraintsolver;
|
||||
*
|
||||
* <p>This is a functional interface
|
||||
* whose functional method is {@link #applyAsLong(long, long, long)}.
|
||||
* @see BinaryOperator
|
||||
* @see LongUnaryOperator.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface LongTernaryOperator {
|
||||
|
||||
@@ -16,11 +16,10 @@ package com.google.ortools.constraintsolver;
|
||||
/**
|
||||
* Represents a predicate (boolean-valued function) uppon
|
||||
* three {@code long}-valued operands. This is the {@code long}-consuming primitive type
|
||||
* specialization of {@link Predicate}.
|
||||
* specialization of {@code Predicate}.
|
||||
*
|
||||
* <p>This is a functional interface
|
||||
* whose functional method is {@link #test(long, long, long)}.
|
||||
* @see Predicate
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface LongTernaryPredicate {
|
||||
|
||||
@@ -604,7 +604,7 @@ public final class CpModel {
|
||||
/**
|
||||
* Adds {@code Reservoir(times, demands, actives, minLevel, maxLevel)}.
|
||||
*
|
||||
* @see #addReservoirConstraintWithActive(IntVar[], long[], actives, long, long) Reservoir
|
||||
* @see #addReservoirConstraintWithActive(IntVar[], long[], IntVar[], long, long) Reservoir
|
||||
*/
|
||||
public Constraint addReservoirConstraintWithActive(IntVar[] times, int[] demands,
|
||||
IntVar[] actives, long minLevel, long maxLevel) throws MismatchedArrayLengths {
|
||||
|
||||
107
ortools/java/pom-local.xml.in
Normal file
107
ortools/java/pom-local.xml.in
Normal file
@@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>@JAVA_PACKAGE@</groupId>
|
||||
<artifactId>@JAVA_PROJECT@</artifactId>
|
||||
<version>@PROJECT_VERSION@</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.groupId}:${project.artifactId}</name>
|
||||
<description>Google OR-Tools Java project.</description>
|
||||
<url>https://github.com/google/or-tools</url>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Corentin "Mizux" Le Molgat</name>
|
||||
<email>corentinl@google.com</email>
|
||||
<organization>Google LLC</organization>
|
||||
<organizationUrl>http://www.google.com</organizationUrl>
|
||||
</developer>
|
||||
<developer>
|
||||
<name>Laurent Perron</name>
|
||||
<email>lperron@google.com</email>
|
||||
<organization>Google LLC</organization>
|
||||
<organizationUrl>http://www.google.com</organizationUrl>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/google/or-tools.git</connection>
|
||||
<developerConnection>scm:git:ssh://github.com:google/or-tools.git</developerConnection>
|
||||
<url>http://github.com/google/or-tools/tree/master</url>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<issueManagement>
|
||||
<system>GitHub Issues</system>
|
||||
<url>http://github.com/google/or-tools/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>@JAVA_PACKAGE@</groupId>
|
||||
<artifactId>@JAVA_NATIVE_PROJECT@</artifactId>
|
||||
<version>@PROJECT_VERSION@</version>
|
||||
<type>jar</type>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna-platform</artifactId>
|
||||
<version>5.5.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>3.11.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
92
ortools/java/pom-native.xml.in
Normal file
92
ortools/java/pom-native.xml.in
Normal file
@@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>@JAVA_PACKAGE@</groupId>
|
||||
<artifactId>@JAVA_NATIVE_PROJECT@</artifactId>
|
||||
<version>@PROJECT_VERSION@</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.groupId}:${project.artifactId}</name>
|
||||
<description>Google OR-Tools Java project.</description>
|
||||
<url>https://github.com/google/or-tools</url>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Corentin "Mizux" Le Molgat</name>
|
||||
<email>corentinl@google.com</email>
|
||||
<organization>Google LLC</organization>
|
||||
<organizationUrl>http://www.google.com</organizationUrl>
|
||||
</developer>
|
||||
<developer>
|
||||
<name>Laurent Perron</name>
|
||||
<email>lperron@google.com</email>
|
||||
<organization>Google LLC</organization>
|
||||
<organizationUrl>http://www.google.com</organizationUrl>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/google/or-tools.git</connection>
|
||||
<developerConnection>scm:git:ssh://github.com:google/or-tools.git</developerConnection>
|
||||
<url>http://github.com/google/or-tools/tree/master</url>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<issueManagement>
|
||||
<system>GitHub Issues</system>
|
||||
<url>http://github.com/google/or-tools/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/*.cxx</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>javadoc-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
103
ortools/java/pom-test.xml.in
Normal file
103
ortools/java/pom-test.xml.in
Normal file
@@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>@JAVA_PACKAGE@</groupId>
|
||||
<artifactId>@JAVA_TEST_PROJECT@</artifactId>
|
||||
<version>@PROJECT_VERSION@</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.groupId}:${project.artifactId}</name>
|
||||
<description>Google OR-Tools Java project.</description>
|
||||
<url>https://github.com/google/or-tools</url>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Corentin "Mizux" Le Molgat</name>
|
||||
<email>corentinl@google.com</email>
|
||||
<organization>Google LLC</organization>
|
||||
<organizationUrl>http://www.google.com</organizationUrl>
|
||||
</developer>
|
||||
<developer>
|
||||
<name>Laurent Perron</name>
|
||||
<email>lperron@google.com</email>
|
||||
<organization>Google LLC</organization>
|
||||
<organizationUrl>http://www.google.com</organizationUrl>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/google/or-tools.git</connection>
|
||||
<developerConnection>scm:git:ssh://github.com:google/or-tools.git</developerConnection>
|
||||
<url>http://github.com/google/or-tools/tree/master</url>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<issueManagement>
|
||||
<system>GitHub Issues</system>
|
||||
<url>http://github.com/google/or-tools/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>@JAVA_PACKAGE@</groupId>
|
||||
<artifactId>@JAVA_PROJECT@</artifactId>
|
||||
<version>@PROJECT_VERSION@</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,43 +1,101 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
<project
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.google.ortools</groupId>
|
||||
<artifactId>ortools</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>@PROJECT_VERSION@</version>
|
||||
<groupId>@JAVA_PACKAGE@</groupId>
|
||||
<artifactId>@JAVA_PROJECT@</artifactId>
|
||||
<version>@PROJECT_VERSION@</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>OR-Tools</name>
|
||||
<url>https://developers.google.com/optimization/</url>
|
||||
<name>${project.groupId}:${project.artifactId}</name>
|
||||
<description>Google OR-Tools Java project.</description>
|
||||
<url>https://github.com/google/or-tools</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>3.11.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Corentin "Mizux" Le Molgat</name>
|
||||
<email>corentinl@google.com</email>
|
||||
<organization>Google LLC</organization>
|
||||
<organizationUrl>http://www.google.com</organizationUrl>
|
||||
</developer>
|
||||
<developer>
|
||||
<name>Laurent Perron</name>
|
||||
<email>lperron@google.com</email>
|
||||
<organization>Google LLC</organization>
|
||||
<organizationUrl>http://www.google.com</organizationUrl>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<build>
|
||||
<directory>${project.basedir}</directory>
|
||||
<outputDirectory>${project.build.directory}/lib</outputDirectory>
|
||||
<sourceDirectory>${project.basedir}/ortools</sourceDirectory>
|
||||
</build>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/google/or-tools.git</connection>
|
||||
<developerConnection>scm:git:ssh://github.com:google/or-tools.git</developerConnection>
|
||||
<url>http://github.com/google/or-tools/tree/master</url>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<issueManagement>
|
||||
<system>GitHub Issues</system>
|
||||
<url>http://github.com/google/or-tools/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>3.11.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
|
||||
@@ -3,15 +3,16 @@ set_property(SOURCE linear_solver.i PROPERTY SWIG_MODULE_NAME main)
|
||||
set_property(SOURCE linear_solver.i PROPERTY COMPILE_DEFINITIONS
|
||||
${OR_TOOLS_COMPILE_DEFINITIONS} ABSL_MUST_USE_RESULT)
|
||||
set_property(SOURCE linear_solver.i PROPERTY COMPILE_OPTIONS
|
||||
-package ${OR_TOOLS_JAVA}.linearsolver)
|
||||
swig_add_library(java_linear_solver
|
||||
-package ${JAVA_PACKAGE}.linearsolver)
|
||||
swig_add_library(jnilinear_solver
|
||||
TYPE OBJECT
|
||||
LANGUAGE java
|
||||
OUTPUT_DIR ${PROJECT_BINARY_DIR}/java/com/google/${PROJECT_NAME}/linearsolver
|
||||
OUTPUT_DIR
|
||||
${PROJECT_BINARY_DIR}/java/${JAVA_PROJECT}/${JAVA_PACKAGE_PATH}/linearsolver
|
||||
SOURCES linear_solver.i)
|
||||
|
||||
target_include_directories(java_linear_solver PRIVATE ${JNI_INCLUDE_DIRS})
|
||||
set_target_properties(java_linear_solver PROPERTIES
|
||||
target_include_directories(jnilinear_solver PRIVATE ${JNI_INCLUDE_DIRS})
|
||||
set_target_properties(jnilinear_solver PROPERTIES
|
||||
SWIG_USE_TARGET_INCLUDE_DIRECTORIES ON
|
||||
POSITION_INDEPENDENT_CODE ON)
|
||||
target_link_libraries(java_linear_solver PRIVATE ortools::ortools)
|
||||
target_link_libraries(jnilinear_solver PRIVATE ortools::ortools)
|
||||
|
||||
@@ -1069,8 +1069,6 @@ class MPVariable {
|
||||
/**
|
||||
* Advanced usage: returns the basis status of the variable in the current
|
||||
* solution (only available for continuous problems).
|
||||
*
|
||||
* @see MPSolver::BasisStatus.
|
||||
*/
|
||||
MPSolver::BasisStatus basis_status() const;
|
||||
|
||||
@@ -1224,8 +1222,6 @@ class MPConstraint {
|
||||
* into "linear_expression + slack = 0" with slack in [-ub, -lb], then this
|
||||
* status is the same as the status of the slack variable with AT_UPPER_BOUND
|
||||
* and AT_LOWER_BOUND swapped.
|
||||
*
|
||||
* @see MPSolver::BasisStatus.
|
||||
*/
|
||||
MPSolver::BasisStatus basis_status() const;
|
||||
|
||||
|
||||
@@ -3,15 +3,16 @@ set_property(SOURCE sat.i PROPERTY SWIG_MODULE_NAME main)
|
||||
set_property(SOURCE sat.i PROPERTY COMPILE_DEFINITIONS
|
||||
${OR_TOOLS_COMPILE_DEFINITIONS} ABSL_MUST_USE_RESULT)
|
||||
set_property(SOURCE sat.i PROPERTY COMPILE_OPTIONS
|
||||
-package ${OR_TOOLS_JAVA}.sat)
|
||||
swig_add_library(java_sat
|
||||
-package ${JAVA_PACKAGE}.sat)
|
||||
swig_add_library(jnisat
|
||||
TYPE OBJECT
|
||||
LANGUAGE java
|
||||
OUTPUT_DIR ${PROJECT_BINARY_DIR}/java/com/google/${PROJECT_NAME}/sat
|
||||
OUTPUT_DIR
|
||||
${PROJECT_BINARY_DIR}/java/${JAVA_PROJECT}/${JAVA_PACKAGE_PATH}/sat
|
||||
SOURCES sat.i)
|
||||
|
||||
target_include_directories(java_sat PRIVATE ${JNI_INCLUDE_DIRS})
|
||||
set_target_properties(java_sat PROPERTIES
|
||||
target_include_directories(jnisat PRIVATE ${JNI_INCLUDE_DIRS})
|
||||
set_target_properties(jnisat PROPERTIES
|
||||
SWIG_USE_TARGET_INCLUDE_DIRECTORIES ON
|
||||
POSITION_INDEPENDENT_CODE ON)
|
||||
target_link_libraries(java_sat PRIVATE ortools::ortools)
|
||||
target_link_libraries(jnisat PRIVATE ortools::ortools)
|
||||
|
||||
@@ -3,15 +3,16 @@ set_property(SOURCE sorted_interval_list.i PROPERTY SWIG_MODULE_NAME main)
|
||||
set_property(SOURCE sorted_interval_list.i PROPERTY COMPILE_DEFINITIONS
|
||||
${OR_TOOLS_COMPILE_DEFINITIONS} ABSL_MUST_USE_RESULT)
|
||||
set_property(SOURCE sorted_interval_list.i PROPERTY COMPILE_OPTIONS
|
||||
-package ${OR_TOOLS_JAVA}.util)
|
||||
swig_add_library(java_util
|
||||
-package ${JAVA_PACKAGE}.util)
|
||||
swig_add_library(jniutil
|
||||
TYPE OBJECT
|
||||
LANGUAGE java
|
||||
OUTPUT_DIR ${PROJECT_BINARY_DIR}/java/com/google/${PROJECT_NAME}/util
|
||||
OUTPUT_DIR
|
||||
${PROJECT_BINARY_DIR}/java/${JAVA_PROJECT}/${JAVA_PACKAGE_PATH}/util
|
||||
SOURCES sorted_interval_list.i)
|
||||
|
||||
target_include_directories(java_util PRIVATE ${JNI_INCLUDE_DIRS})
|
||||
set_target_properties(java_util PROPERTIES
|
||||
target_include_directories(jniutil PRIVATE ${JNI_INCLUDE_DIRS})
|
||||
set_target_properties(jniutil PROPERTIES
|
||||
SWIG_USE_TARGET_INCLUDE_DIRECTORIES ON
|
||||
POSITION_INDEPENDENT_CODE ON)
|
||||
target_link_libraries(java_util PRIVATE ortools::ortools)
|
||||
target_link_libraries(jniutil PRIVATE ortools::ortools)
|
||||
|
||||
Reference in New Issue
Block a user