-
Notifications
You must be signed in to change notification settings - Fork 750
Upgrade of presets to 1.5
HGuillemet edited this page Jan 24, 2019
·
14 revisions
This is the procedure to transform a pre-1.5 JavaCPP presets to a 1.5 presets, compatible with the Java Platform Module System. OpenCV and ffmpeg presets have already been upgraded to 1.5 and can be used as a model for upgrading other presets.
In the following <PS>
is the name of the presets (e.g. ffmpeg
) and <LIB>
is the name of a native library (e.g. avcodec
).
- Delete and remove from repository all generated Java files located in
<PS>/src/main/java/org/bytedeco/javacpp
. Beware not to remove not-generated source files that may have been created in this directory. This can be safely done with a command like (using a unix shell):
cd <PS>/src/main/java/org/bytedeco/javacpp
git rm `grep -l 'DO NOT EDIT THIS FILE' *.java`
- Rename the
<PS>/src/main/java/org/bytedeco/javacpp
directory to<PS>/src/main/java/org/bytedeco/<PS>
, and adjust the packages and references in the helper and presets classes accordingly. A search&replace oforg.bytedeco.javacpp.presets
byorg.bytedeco.<PS>.presets
andorg.bytedeco.javacpp.helper
byorg.bytedeco.<PS>.helper
will do. - Create directory
<PS>/src/java/org/bytedeco/<PS>/<LIB>
for each native library. For presets with a single native library, you can skip this step. - Create directory
<PS>/src/java/org/bytedeco/global
- In the presets file
<PS>/src/java/org/<PS>/presets/<LIB>.java
: change the value of thetarget
property toorg.bytedeco.<PS>.<LIB>
, or toorg.bytedeco.<PS>
if you skipped step 3. Add after thetarget
property the new propertyglobal
, with valueorg.bytedeco.<PS>.global.<LIB>
. This is the name of the main class that will contain the global members of the library (not enclosed in a C++ class). - If some helper classes
<PS>/src/main/java/org/bytedeco/helper/<LIB>.java
contain static classes, move these classes out as standalone classes in the directory<PS>/src/main/java/org/bytedeco/<PS>/<LIB>
(or<PS>/src/main/java/org/bytedeco/<PS>
if you skipped step 3). Again, your IDE may help in such task by adapting the packages and changing references. Ensure these files are added to the repository. - Create
<PS>/src/main/java9/module-info.java
containing:Repeat themodule org.bytedeco.<PS> { requires transitive org.bytedeco.javacpp; exports org.bytedeco.<PS>.<LIB>; }
exports
line for each native library included in the presets (or omit<LIB>
if you skipped step 3). Also add any exported package that doesn't map a library, if such package exists. Add this file to the repository. - That's it. Give it a try with a
mvn clean install -pl .,<PS>
- If the build is successful, uncomment the lines related to the preset in the Travis config file
/.travis.yml
and AppVeyor config file/.appveyor.yml
. - Add the generated sources to the repository:
git add <PS>/src/gen
. - Publish a PR.