-
Notifications
You must be signed in to change notification settings - Fork 282
Prepare Java release to Maven Central #968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
One point about the naming of the native libraries that may look like a detail, but is pretty important: The native libraries that are supposed to be packed into the JAR will need a version number suffix, like The reason: When loading a native library in Java with |
|
A few things to note:
|
|
@MarkCallow All that sounds OK to me. It sounds like there could be a path to properly handle the versioning, naming of the native libs, and (if the Travis->GitHub transition progresses) the packaging of the natives into JARs. Ideally, this could include the upload of the JARs to Sonatype/MavenCentral (maybe not strictly required, but certainly desirable). However, there already are places that carry a version number that would have to be adjusted manually. Specifically, the main
4.3.3-SNAPSHOT in this branch, but we'd have to check where this version will come from when all this is to be automated.
|
revision is overridden when Maven is run because the command run by the CMakeLists.txt is PROJECT_VERSION is set to KTX_VERSION in the top-level CMakeLists.txt and KTX_VERSION is the version with major.minor.patch. So version naming is already handled.
The Travis->GitHub transition is not essential. As I wrote, Java can use exactly the same techniques as we are using for python to package the native libraries into JARS and upload them to Sonatype/MavenCentral. Take a look at the workflow file I pointed you at. |
|
@javagl I am preparing the next release. As part of that I am creating a new GitHub Action to build just the documentation. This has lead to the following questions and requests regarding the Java wrapper documentation.
|
|
I haven't had the chance to make substantial progress here, but short notes:
It is possible to isolatedly build the documentation, using a plain maven call like
Both should be relatively easy. By default, I'll have a look at all this when I pick up the work on this PR again. |
|
I'm ready to prepare the next release. I would like the Java documentation to be included in the documentation package that will built when Java/JNI is included in the build configuration. That means
Note that the |
|
@MarkCallow I'll likely not be able to allocate enough time for sorting out the documentation before the next release is due. I did a very quick pass (the state is in https://github.com/javagl/KTX-Software/tree/include-java-docs ), but I have not used CMake/Doxygen extensively before. (I mean... I'm not even sure whether the documentation should be generated with |
Do it when you have time. The current release does not have documentation for the Java wrapper so it is not a major problem to also not have it in the upcoming release. Good question about whether to use Javadoc or Doxygen. Note that use of Doxygen will not remove the need to hack those DoxyLayout files. |
|
The latest main has a fix for the Windows build errors you are now seeing. The errors are due to an update to ClangCL which adds a new warning about mismatched function types in a cast. The fixes in |
And not one second earlier 😁
I don't have a strong opinion, but mainly because I haven't used Doxygen for Java yet. One could argue for javadoc because Java users are (more) familiar with that, or for Doxygen because it will likely cause a more consistent appearance on the website. (The javadoc-based results will be part of the Maven release anyhow...) I'll have a look and maybe share some previews if possible.
I'm not deeply involved here, and would first have to check: Is that cast safe? (A lot of context knowledge is required surrounding some of the OS-specific parts and some of the |
|
I have a question about this PR is this already on maven because I am making something in Java and in my build.gradle I need to use KTX tools but it isn't available on maven yet? I hope this is completed soon but no rush.i was just curious if a beta of this pr is on maven. |
|
@Thunderrock424242 No, the KTX library is not yet available in Maven Central. This PR aims at preparing that on a technical level. There are still several questions to be sorted out in that area (e.g. for the build process). After that, there will be some "organizational" questions (signing and the actual uploading). I'll try to allocate some time to proceed here. |
|
@javagl please make some progress on this. I would like to include these changes as part of the eventual 4.4.1 release. I have no date in mind but already have a collection of fixes I'd like to release. Please note that |
|
The repositories that I currently have on GitHub are the tip of an iceberg of open-source projects that I'm maintaining, to varying degrees. All this is happening solely in my spare time, in addition to the paid work that I have to do, in order to.... you know, ... be able to buy food. (I sometimes eat food). KTX-Software (and this PR in particular) may therefore only receive only a tiny, tiny fraction of my time. However, I do intend to wrap up this PR (when I find the time). And I took the note about |
Addresses #624
There is already some discussion about the related tasks and possible approaches in that issue, mainly starting at this comment. I'll try to summarize the current state of this PR and the open questions.
Organizational
One question that is not (yet) addressed with the PR is that of the actual deployment of the JARs to Maven Central. I'm not deeply familiar with (or may have forgotten) some of the details here. Maven is incredibly powerful, and it is possible to handle much of that release with Maven itself. In a perfect world (i.e. one that only involves Java 🙂 ), it is possible to set up Maven in a way so that a single Maven run can 0. define the version number for the release, 1. create a Git tag for this release, 2. check out this tag, 3. perform the build, 4. run the tests, 5. sign the JARs, 6. upload the JARs to the Maven Central 'staging' repository, 7. update the version numbers, ... (and more... heck, it can do anything, for what it's worth...)
However, for libraries that involve native libraries (as it is the case here), there are apparent caveats. For example, the run to build Linux- and Windows binaries can hardly happen on the same machine. (In theory, maybe, yes, but ... now throw in MacOS, and you're screwed...).
One reasonably painless path that I've been taking (for JCuda and JOCL) is:
Maybe someone wants to chime in with better approaches. (Preferably, going beyond the comment "You should use a better approach" ... ). In any case - regardless of whether it's fully automatic or semi-manual - there are some questions about authorization and authentification (for signing and the actual upload) where some Khronos Webmaster/Maven-Admin will have to contribute.
The current
mainstate of thepom.xmlcontains a few fragments of the infrastructure that are currently<!-- commented out -->. Maybe some of that can be re-used?Technical
The current state of this PR contains a few building blocks for the technical part of the deployment.
I added a copy of the
LibUtilsthat I've also been using for JOCL. It is a class that can load native libraries, depending on the target OS and architecture, either from local files, or from a JAR file. In order to do that, it unpacks the files from the JAR into a "temp" directory, and loads them from there. This class can be used to conveniently ensure that the required native libraries are loaded when any of the classes is loaded that usesnativefunctions.I updated the Maven
pom.xmlto prepare the handling of the native libraries:(One detail: I lowered the Java version requirement to 1.8. There is no reason to require Java 11 here...)
I added an execution of the
maven-resources-pluginthat takes all native libraries that are found in a/nativeLibrariessubdirectory of the project, and puts them into thetarget/libdirectory. From there, they will be packed into the JAR. (The libraries should be put into thenativeLibrariesdirectory by the native build processes)Right now, this is tailored to creating a single JAR that contains all native libraries. (This is the approach that I took for JOCL). Having "one JAR to rule them all" is convenient (e.g. for deployment). But it has drawbacks:
A better approach usually is to create dedicated JARs for each of the native libraries. This basically means that there would be
ktx-0.0.0.jarfor the main Java partktx-natives-0.0.0-windows-x86_64.jarcontaining only the Windows DLLktx-natives-0.0.0-linux-x86_64.jarcontaining only the Linux natives...This does involve some overhead for the POM: The right dependencies have to be added using profiles, but I already did that for JCuda (e.g. in the JCuda parent POM), and the same approach is used for other native libraries (like the LWJGL family of libraries, or java-cpp).
The next steps here will be to prepare the build infrastructure for creating the dedicated
ktx-natives...libraries where each contains only the natives that are required for the respective OS/architecture.