Skip to content

Commit 10b1f53

Browse files
committed
Add jdk4py to package extras
1 parent 6d285d9 commit 10b1f53

File tree

6 files changed

+50
-5
lines changed

6 files changed

+50
-5
lines changed

.github/workflows/publish.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
run: pipx install poetry
1919
- uses: actions/setup-python@v5
2020
with:
21-
python-version: '3.13'
21+
python-version: 3.x
2222
cache: poetry
2323
- name: Setup Poetry to publish
2424
run: |

.pre-commit-config.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ repos:
4242
- id: mypy
4343
files: ^openapi_generator_cli/
4444
args: [--strict]
45-
# additional_dependencies:
45+
additional_dependencies:
46+
- jdk4py
4647
- repo: https://github.com/igorshubovych/markdownlint-cli
4748
rev: v0.43.0
4849
hooks:

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ pip install openapi-generator-cli
3838
pip install openapi-generator-cli==4.3.1
3939
```
4040

41+
You can also install with [`jdk4py`] instead of `java` binary. (`python>=3.10` is required)
42+
43+
```sh
44+
pip install openapi-generator-cli[jdk4py]
45+
```
46+
4147
After installation `openapi-generator-cli` command will be available in your virtual environment or globally depending on your installation.
4248

4349
To check the version, for example. Type the following command
@@ -61,4 +67,5 @@ Please raise an issue, happy to hear from you :)
6167

6268
[OpenAPITools/openapi-generator]: <https://github.com/OpenAPITools/openapi-generator>
6369
[maven repository]: <https://mvnrepository.com/artifact/org.openapitools/openapi-generator-cli>
70+
[`jdk4py`]: <https://github.com/activeviam/jdk4py>
6471
[official openapi-generator docs]: <https://github.com/OpenAPITools/openapi-generator#3---usage>

openapi_generator_cli/__init__.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44

55
import importlib.resources
66
import os
7+
import shutil
78
import subprocess
89
import sys
10+
from typing import TYPE_CHECKING
11+
12+
if TYPE_CHECKING:
13+
from pathlib import Path
914

1015

1116
def run(args: list[str] | None = None) -> subprocess.CompletedProcess[bytes]:
@@ -21,7 +26,18 @@ def run(args: list[str] | None = None) -> subprocess.CompletedProcess[bytes]:
2126
subprocess.CompletedProcess[bytes]: The result of running the OpenAPI Generator CLI.
2227
2328
"""
24-
arguments = ["java"]
29+
java_path: Path | str | None
30+
try:
31+
from jdk4py import JAVA
32+
33+
java_path = JAVA
34+
except ImportError:
35+
java_path = shutil.which("java")
36+
if not java_path:
37+
msg = "java runtime is not found in PATH"
38+
raise RuntimeError(msg)
39+
40+
arguments = [java_path]
2541

2642
java_opts = os.getenv("JAVA_OPTS")
2743
if java_opts:

poetry.lock

+19-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ documentation = "https://github.com/OpenAPITools/openapi-generator#3---usage"
3838

3939
[tool.poetry.dependencies]
4040
python = ">=3.9,<4"
41+
jdk4py = { version = "^21.0.4.1", optional = true, python = ">=3.10" }
4142

4243
[tool.poetry.group.dev.dependencies]
4344
mypy = ">=0.991,<1.14"
@@ -46,6 +47,9 @@ taskipy = "^1.10.3"
4647
pytest = ">=7.2.2,<9.0.0"
4748
natsort = "^8.4.0"
4849

50+
[tool.poetry.extras]
51+
jdk4py = [ "jdk4py" ]
52+
4953
[tool.poetry.scripts]
5054
openapi-generator-cli = "openapi_generator_cli:cli"
5155

0 commit comments

Comments
 (0)