22
33## Gradle Plugin
44
5+ [ :fontawesome-brands-github: View source] ( https://github.com/howtis/python-embed/tree/main/python-embed-gradle-plugin )
6+
57Add the plugin to ` build.gradle ` :
68
79``` groovy
@@ -53,6 +55,8 @@ The venv is rebuilt incrementally — only when dependencies change.
5355
5456## Spring Boot Starter
5557
58+ [ :fontawesome-brands-github: View source] ( https://github.com/howtis/python-embed/tree/main/python-embed-spring-boot-starter )
59+
5660For Spring Boot 3.x applications, add the starter:
5761
5862``` groovy
@@ -63,8 +67,79 @@ dependencies {
6367
6468This provides zero-code auto-configuration. See the [ Spring Boot guide] ( spring-boot.md ) .
6569
70+ ## Maven Plugin
71+
72+ [ :fontawesome-brands-github: View source] ( https://github.com/howtis/python-embed/tree/main/python-embed-maven-plugin )
73+
74+ Add the plugin to ` pom.xml ` :
75+
76+ ``` xml
77+ <build >
78+ <plugins >
79+ <plugin >
80+ <groupId >io.github.howtis</groupId >
81+ <artifactId >python-embed-maven-plugin</artifactId >
82+ <version >1.0.2</version >
83+ <executions >
84+ <execution >
85+ <goals >
86+ <goal >setup</goal >
87+ </goals >
88+ </execution >
89+ </executions >
90+ <configuration >
91+ <packages >
92+ <package >numpy</package >
93+ <package >torch</package >
94+ </packages >
95+ </configuration >
96+ </plugin >
97+ </plugins >
98+ </build >
99+ ```
100+
101+ ### Goals
102+
103+ | Goal | Phase | Description |
104+ | ------| -------| -------------|
105+ | ` setup ` | ` generate-resources ` | Creates a Python venv and installs packages |
106+ | ` properties ` | ` generate-resources ` | Generates ` META-INF/python-embed.properties ` for runtime discovery |
107+ | ` help ` | — | Displays usage information |
108+
109+ The ` properties ` goal automatically runs after ` setup ` via ` @Execute ` .
110+
111+ ### Configuration
112+
113+ | Parameter | Type | Default | Description |
114+ | -----------| ------| ---------| -------------|
115+ | ` packages ` | ` List<String> ` | ` [] ` | Pip packages to install |
116+ | ` pythonVersion ` | ` String ` | ` 3.12 ` | Python version for auto-download |
117+ | ` venvOutputDir ` | ` File ` | ` ${project.build.directory}/python-venv ` | Venv output directory |
118+ | ` requirementsFile ` | ` File ` | — | Path to ` requirements.txt ` |
119+ | ` pyprojectTomlFile ` | ` File ` | — | Path to ` pyproject.toml ` |
120+ | ` pipIndexUrl ` | ` String ` | — | Custom pip index URL |
121+ | ` pipExtraArgs ` | ` List<String> ` | ` [] ` | Extra pip install arguments |
122+ | ` skip ` | ` boolean ` | ` false ` | Skip plugin execution |
123+ | ` targetOs ` | ` String ` | auto-detected | Target OS: ` windows ` , ` linux ` , or ` macos ` |
124+
125+ ### Usage
126+
127+ ``` bash
128+ # Run setup directly
129+ mvn python-embed:setup
130+
131+ # Generate properties
132+ mvn python-embed:properties
133+
134+ # Show help
135+ mvn python-embed:help
136+
137+ # Skip plugin execution
138+ mvn compile -Dpython-embed.skip=true
139+ ```
140+
66141## Requirements
67142
68143- JDK 17+
69144- Python 3.8+ (auto-downloaded if absent via python-build-standalone)
70- - Gradle 8.x
145+ - Gradle 8.x (Gradle plugin) or Maven 3.9+ (Maven plugin)
0 commit comments