Skip to content

Commit

Permalink
[API] Automatic Module Names (#105)
Browse files Browse the repository at this point in the history
* Initial implementation of Automatic Module Names

* Fix using java 17 for publishing

* Roll build back to jdk 1.8

* Fix package name for imgui.lwjgl3 module

* Reworking package change to prevent breaking backwards compatability
  • Loading branch information
tlf30 committed Jan 21, 2022
1 parent 6f48a70 commit 8c1ef20
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 11 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ dependencies {
3. Add the jar to your classpath.
</details>

#### Java Module System
If using Java 9 modules, you will need to require the `imgui.app` module.


## Binding
Using binding without the wrapper requires to "attach" it to your application manually.
You can refer to [imgui-app](https://github.com/SpaiR/imgui-java/blob/v1.86.0/imgui-app) module and see how things are done there.
Expand Down Expand Up @@ -247,6 +251,16 @@ dependencies {
4. Provide a VM option: `imgui.library.path` or `java.library.path`. It should point to the folder where you've placed downloaded native libraries.
</details>

#### Java Module System
If using Java 9 modules, imgui-java has Automatic Module Names:

| Package | Module |
|--------------------|---------------|
| imgui-java-app | imgui.app |
| imgui-java-binding | imgui.binding |
| imgui-java-lwjgl3 | imgui.lwjgl3 |
| imgui-java-natives | imgui.natives |

## Extensions
- [ImNodes](https://github.com/Nelarius/imnodes/tree/857cc860af05ac0f6a4039c2af33d982377b6cf4) | [Example](https://github.com/SpaiR/imgui-java/blob/v1.86.0/example/src/main/java/ExampleImNodes.java) <br>
A small, dependency-free node editor for dear imgui. (A good choice for simple start.)
Expand Down
3 changes: 3 additions & 0 deletions imgui-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jar {
include 'imgui-java64.dll'
into 'io/imgui/java/native-bin/'
}
manifest {
attributes 'Automatic-Module-Name': 'imgui.app'
}
}

shadowJar {
Expand Down
2 changes: 1 addition & 1 deletion imgui-app/src/main/java/imgui/app/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Application class from which ImGui applications extend.
* Serves as an abstraction layer to hide all low-level details about window creation and rendering routine.
*
* <h3>Life-cycle</h3>
* <h2>Life-cycle</h2>
* <p>The entry point for ImGui applications is the Application class and {@link #launch(Application)} method.
* It initializes application instance and starts the main application loop.
*
Expand Down
3 changes: 3 additions & 0 deletions imgui-binding-natives/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ jar {
include "$libName" // this is fine
into 'io/imgui/java/native-bin/'
}
manifest {
attributes 'Automatic-Module-Name': 'imgui.natives'
}
}

apply from: "$rootDir/publish.gradle"
Expand Down
6 changes: 6 additions & 0 deletions imgui-binding/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ tasks.register('generateLibs', GenerateLibs) {

apply from: "$rootDir/publish.gradle"
configurePublishing('imgui-java-binding', 'JNI based binding for Dear ImGui')

jar {
manifest {
attributes 'Automatic-Module-Name': 'imgui.binding'
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package imgui.glfw;
package imgui.lwjgl3.glfw;

final class ImGuiImplGlfwNative {
public final class ImGuiImplGlfwNative {
private ImGuiImplGlfwNative() {
}

Expand All @@ -10,9 +10,15 @@ private ImGuiImplGlfwNative() {
#endif
*/

// GLFW hack: Hide icon from task bar
// Applied only for windows
static native void win32hideFromTaskBar(long hwndPtr); /*
/**
* GLFW hack: Hide icon from task bar
* Applied only for windows
*
* Internal Use Only.
* FIXME: Once Java Module System has been implemented, this function should only be exported
* to the imgui.lwjgl module.
*/
public static native void win32hideFromTaskBar(long hwndPtr); /*
#if defined(_WIN32)
HWND hwnd = (HWND)hwndPtr;
LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
Expand Down
6 changes: 6 additions & 0 deletions imgui-lwjgl3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ dependencies {

apply from: "$rootDir/publish.gradle"
configurePublishing('imgui-java-lwjgl3', 'Backend LWJGL3 implementation for imgui-java')

jar {
manifest {
attributes 'Automatic-Module-Name': 'imgui.lwjgl3'
}
}
1 change: 1 addition & 0 deletions imgui-lwjgl3/src/main/java/imgui/glfw/ImGuiImplGlfw.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import imgui.flag.ImGuiMouseCursor;
import imgui.flag.ImGuiNavInput;
import imgui.flag.ImGuiViewportFlags;
import imgui.lwjgl3.glfw.ImGuiImplGlfwNative;
import org.lwjgl.PointerBuffer;
import org.lwjgl.glfw.GLFWCharCallback;
import org.lwjgl.glfw.GLFWCursorEnterCallback;
Expand Down
12 changes: 7 additions & 5 deletions publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ ext.configurePublishing = { packageName, packageDesc ->
}
}
}
signing {
def signingKeyId = System.getenv('SIGNING_KEY_ID')
def signingKey = System.getenv('SIGNING_KEY')
useInMemoryPgpKeys(signingKeyId, signingKey, '')
sign publishing.publications.mavenJava
if (System.getenv('SIGNING_KEY_ID') != null) {
signing {
def signingKeyId = System.getenv('SIGNING_KEY_ID')
def signingKey = System.getenv('SIGNING_KEY')
useInMemoryPgpKeys(signingKeyId, signingKey, '')
sign publishing.publications.mavenJava
}
}
}

0 comments on commit 8c1ef20

Please sign in to comment.