google-or-tools-java
google-or-tools-java copied to clipboard
Google OR-Tools for Java
= Google OR-Tools for Java :groupId: io.github.oliviercailloux :artifactId: google-or-tools :repository: google-or-tools-java
image:https://travis-ci.org/oliviercailloux/{repository}.svg?branch=master["Build Status", link="https://travis-ci.org/oliviercailloux/{repository}"] image:https://maven-badges.herokuapp.com/maven-central/{groupId}/{artifactId}/badge.svg["Artifact on Maven Central", link="http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22{groupId}%22%20a%3A%22{artifactId}%22"]
A project to publish Google OR-Tools as a dependable dependency in Maven.
This project contains no specific source code (except for a simple https://github.com/oliviercailloux/google-or-tools-java/blob/master/src/test/java/io/github/oliviercailloux/google_or_tools/TestRun.java[test] class). Everything comes from Google OR-Tools.
== Depending on Google OR-Tools Here is how to use this project as a dependency in your own project.
- Add this project as a dependency (find its Maven coordinates using the badge above) of your project
- To configure your library path correctly for tests, configure
maven-surefire-plugin
, see this https://github.com/oliviercailloux/google-or-tools-java/blob/master/pom.xml[pom] as an example - Copy the https://github.com/oliviercailloux/google-or-tools-java/tree/master/lib[lib] folder of this project into your own project (for linux, https://github.com/google/or-tools/issues/1103[hoping] that it will work), or replace its content with libraries appropriate for your OS: check inside the
lib
folder of the https://github.com/google/or-tools/releases/tag/v6.7.2[release] version corresponding to your OS - Copy the https://github.com/oliviercailloux/google-or-tools-java/blob/master/src/test/java/io/github/oliviercailloux/google_or_tools/TestRun.java[test] class from this project into your own project
- Run the unit test using Maven: it should load the native library, run the solver, and come out green
- To configure Eclipse so that it finds the native library, in the project properties,
Java Build Path
,Source
tab,google-or-tools/src/test/java
,Native library location
, specify asLocation path
:google-or-tools/lib
(for other IDEs, adapt accordingly) - Run
io.github.oliviercailloux.google_or_tools.TestRun
as JUnit test from your IDE, it should pass
The above configures your library path correctly only for running tests. You will probably want to make sure that your library path is set correctly for normal operation as well. Multiple manners exist, depending on your particular needs, how you want to distribute your project, …
== About more recent versions For reasons of time, I do not intend to keep this library systematically up-to-date. In other words, the version published here is older than the last version of Google OR-Tools, on which the https://developers.google.com/optimization/[developer] site is based. See also https://github.com/oliviercailloux/google-or-tools-java/issues/5[this] issue.
Please do not ask for updates: I will update only as my own projects require (meaning, rarely, if ever). Please rather add your voice – or thumb – https://github.com/google/or-tools/issues/202[here] in hope that the main developers publish the library to Maven Central themselves. In the meantime, you can also fork this repository and update it under your own groupId
: given the instructions below, it might (hopefully?) be easy.
== Making Google OR-Tools for Java
Here is how to re-make this project from scratch (except for the test class and pom.xml
, which I created manually).
- install https://developers.google.com/optimization/introduction/installing/source.html#prerequisites_linux[prerequisites]
- set
${dest}
variable - clone https://github.com/google/or-tools[OR-Tools] in a folder whose full path contain no space
-
git checkout v6.7.2
-
make third_party
-
make java
-
mv "ortools/gen/com" "${dest}/src/main/java/"
-
rmdir "${dest}/src/main/java/com/google/ortools/flatzinc" "${dest}/src/main/java/com/google/ortools/properties" "${dest}/src/main/java/com/google/ortools/sat"
- Download the library for https://github.com/google/or-tools/releases/tag/v6.7.2[Ubuntu 14] (this version seems to runs both on Travis and on my Debian system, probably out of pure luck)
- Extract the archive, move
or-tools_Ubuntu-14.04-64bit_v6.7.4981/lib/libortools.so
andlibjniortools.so
to"${dest}/lib/"