tess4j icon indicating copy to clipboard operation
tess4j copied to clipboard

Provide Modularization Support for tess4j (Module Descriptor module-info.java)

Open astrapi69 opened this issue 1 year ago • 6 comments

Hi @nguyenq,

I'm currently using tess4j in a modular Java project and encountered issues because tess4j lacks a module descriptor (module-info.java). Without it, I’m unable to include tess4j as a module in my project, which leads to errors such as error: Modul not found: tess4j requires tess4j;.

Proposed Solution:

Could you please consider adding modularization support for tess4j by including a module-info.java file? This would allow projects using the Java module system to include tess4j seamlessly as a required module.

An example of the required module descriptor might look like:


module tess4j {
    requires java.base;
    requires java.desktop;
    // Add any other necessary dependencies
    exports net.sourceforge.tess4j; // Export your main package(s)
}

Benefits:

  • Supports Java projects using the module system.
  • Improves integration with modularized applications and modern Java practices.

Thank you for considering this enhancement. Modularization would greatly improve compatibility and ease of use for Java developers working with the module system.

astrapi69 avatar Nov 11 '24 15:11 astrapi69

@astrapi69 Please submit a PR.

Thanks.

nguyenq avatar Nov 16 '24 22:11 nguyenq

Hello @nguyenq,

I have created and submitted a Pull Request to address the issue. The PR introduces a module-info.java file to provide modularization support for tess4j, ensuring compatibility with the Java Module System. It also updates the Maven Compiler Plugin configuration to target JDK 11.

Please feel free to review the changes, and let me know if there are any adjustments or additional enhancements required.

Thank you for considering this improvement, and I look forward to your feedback!

astrapi69 avatar Nov 19 '24 16:11 astrapi69

@astrapi69 There was a warning during compile:

Required filename-based automodules detected: [jai-imageio-core-1.4.0.jar, lept4j-1.20.0.jar]. Please don't publish this project to a public artifact repository!

I think I'll need to modularize lept4j, but what about jai-imageio-core? How can it be addressed?

Thanks.

nguyenq avatar Nov 25 '24 04:11 nguyenq

Hi @nguyenq may we can make a fork and modularize also jai-imageio-core. I just forked it now and will try to upgrade to jdk11

astrapi69 avatar Nov 27 '24 18:11 astrapi69

@astrapi69 I think it will need to be merged upstream to the original repo of jai-imageio-core, which hasn't received any code update for many years.

Alternatively, we can use a more actively developed image library TwelveMonkeys; however, a PR related to modularization has also been stuck in the neutral the past few years.

I probably will have to revert your PR to proceed with Tesseract 5.5.0 upgrade release.

nguyenq avatar Dec 01 '24 03:12 nguyenq

Hi @nguyenq,

Thank you for your feedback and for pointing out the challenges with jai-imageio-core and lept4j. I completely understand the need to prioritize the Tesseract 5.5.0 upgrade release.

To address these concerns:

For jai-imageio-core: Since the original repository has not received updates in years, I have already forked it and started working on adding a module-info.java to modularize it. Once the changes are stable, I will test its compatibility with tess4j. However, I agree that merging the changes upstream would be the ideal solution, so I will also attempt to reach out to the maintainers.

Alternatively, I can investigate replacing jai-imageio-core with TwelveMonkeys. While its modularization PR has been delayed, I will assess if this library offers better long-term compatibility and modernization for tess4j.

For lept4j: I’m happy to contribute to modularizing lept4j as a separate task. This will help reduce warnings and make tess4j’s modularization effort more robust.

Interim Solution: If needed, I can help maintain a modularized branch of tess4j, allowing developers using the Java Module System to experiment with it. This can coexist alongside a non-modularized release for users not yet adopting modularization.

I hope these steps provide a clear path forward. Please let me know if there are any specific priorities or adjustments you'd like to see.

Best regards, @astrapi69

astrapi69 avatar Dec 02 '24 14:12 astrapi69