package-info.java is generated with the wrong package name and directory #315

Closed
opened 2025-12-26 23:11:49 +01:00 by ritzow · 2 comments
ritzow commented 2025-12-26 23:11:49 +01:00 (Migrated from github.com)

While trying to generate bindings for libpanel using the java-gi command line tool, I found that the package-info.java file path is generated using different code than the paths for other Java files.

Compare

github.com/jwharm/java-gi@7732f6a765/generator/src/main/java/org/javagi/JavaGI.java (L185)

to

github.com/jwharm/java-gi@7732f6a765/generator/src/main/java/org/javagi/JavaGI.java (L264)

The package-info.java incorrectly ends up in "panel/my/package/path" (panel is the name of the gobject library) with the package name panel.my.package.path in the resulting directory/JAR, whereas the rest of the code goes to the proper directory "my/package/path".

The packageName isn't passed into the generate method.

While trying to generate bindings for [libpanel](https://gitlab.gnome.org/GNOME/libpanel) using the `java-gi` command line tool, I found that the `package-info.java` file path is generated using different code than the paths for other Java files. Compare https://github.com/jwharm/java-gi/blob/7732f6a765028a0fa5a15c1ad78de1d083a7ae71/generator/src/main/java/org/javagi/JavaGI.java#L185 to https://github.com/jwharm/java-gi/blob/7732f6a765028a0fa5a15c1ad78de1d083a7ae71/generator/src/main/java/org/javagi/JavaGI.java#L264 The `package-info.java` incorrectly ends up in "panel/my/package/path" (panel is the name of the gobject library) with the package name panel.my.package.path in the resulting directory/JAR, whereas the rest of the code goes to the proper directory "my/package/path". The packageName isn't passed into the generate method.
jwharm commented 2025-12-27 22:24:03 +01:00 (Migrated from github.com)

Thanks for trying out java-gi and for providing feedback!

I tried to reproduce the issue but I don't see anything wrong.
The command:

~/Downloads/java-gi-0.13.1/bin/java-gi /usr/share/gir-1.0/Panel-1.gir --domain=my.package.path

results in the following generated files:

.
└── panel
    ├── module-info.java
    └── my
        └── package
            └── path
                └── panel
                    ├── ActionActivateFunc.java
                    ├── Action.java
                    ├── ActionMuxer.java
                    ├── Application.java
                    ├── Area.java
                    ├── ChangesDialog.java
                    ├── Dock.java
                    ├── DocumentWorkspace.java
                    ├── FrameCallback.java
                    ├── FrameHeaderBar.java
                    ├── FrameHeader.java
                    ├── FrameHeaderMethodHandles.java
                    ├── Frame.java
                    ├── FrameSwitcher.java
                    ├── FrameTabBar.java
                    ├── GridColumn.java
                    ├── Grid.java
                    ├── GSettingsActionGroup.java
                    ├── Inhibitor.java
                    ├── LayeredSettings.java
                    ├── MenuManager.java
                    ├── OmniBar.java
                    ├── package-info.java
                    ├── Paned.java
                    ├── Panel.java
                    ├── Position.java
                    ├── SaveDelegate.java
                    ├── SaveDialog.java
                    ├── SessionItem.java
                    ├── Session.java
                    ├── Settings.java
                    ├── Statusbar.java
                    ├── ThemeSelector.java
                    ├── ToggleButton.java
                    ├── Widget.java
                    ├── Workbench.java
                    ├── WorkspaceForeach.java
                    └── Workspace.java

Did you expect package-info.java to be in another location?

Thanks for trying out java-gi and for providing feedback! I tried to reproduce the issue but I don't see anything wrong. The command: ``` ~/Downloads/java-gi-0.13.1/bin/java-gi /usr/share/gir-1.0/Panel-1.gir --domain=my.package.path ``` results in the following generated files: ``` . └── panel ├── module-info.java └── my └── package └── path └── panel ├── ActionActivateFunc.java ├── Action.java ├── ActionMuxer.java ├── Application.java ├── Area.java ├── ChangesDialog.java ├── Dock.java ├── DocumentWorkspace.java ├── FrameCallback.java ├── FrameHeaderBar.java ├── FrameHeader.java ├── FrameHeaderMethodHandles.java ├── Frame.java ├── FrameSwitcher.java ├── FrameTabBar.java ├── GridColumn.java ├── Grid.java ├── GSettingsActionGroup.java ├── Inhibitor.java ├── LayeredSettings.java ├── MenuManager.java ├── OmniBar.java ├── package-info.java ├── Paned.java ├── Panel.java ├── Position.java ├── SaveDelegate.java ├── SaveDialog.java ├── SessionItem.java ├── Session.java ├── Settings.java ├── Statusbar.java ├── ThemeSelector.java ├── ToggleButton.java ├── Widget.java ├── Workbench.java ├── WorkspaceForeach.java └── Workspace.java ``` Did you expect `package-info.java` to be in another location?
ritzow commented 2025-12-27 22:32:46 +01:00 (Migrated from github.com)

I really appreciate you taking a look. You're right. My issue was that I had set --output to a Maven variable ${generatedOutputDir} and then added ${generatedOutputDir} as a source root in Maven. But java-gi creates a subdirectory panel so it can store the generated source for each module separately. All I had to do was add ${generatedOutputDir}/panel as a source root instead. For some reason it still partially worked when I configured it the wrong way in Maven, but only for the classes, and not the package-info. Funny! Thanks so much for the reply. This is really an awesome software project!

I really appreciate you taking a look. You're right. My issue was that I had set `--output` to a Maven variable `${generatedOutputDir}` and then added `${generatedOutputDir}` as a source root in Maven. But java-gi creates a subdirectory `panel` so it can store the generated source for each module separately. All I had to do was add `${generatedOutputDir}/panel` as a source root instead. For some reason it still partially worked when I configured it the wrong way in Maven, but only for the classes, and not the package-info. Funny! Thanks so much for the reply. This is really an awesome software project!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
java-gi/java-gi#315
No description provided.