Skip to content

Support enforcement of a specific uv version #308

@d-ryan-ashcraft

Description

@d-ryan-ashcraft

Provide symmetric functionality to enforce a uv version or version range like we can now do for Poetry (#302).

Test Steps

  • Build the latest version of the plugin: mvn clean install -Pbootstrap
  • (Assumes you are on uv 0.6.x) Execute the uv Enforcer Rule: mvn clean install -pl :habushu-uv-enforcer-rule -Puv -Dmaven.build.cache.skipCache=true
  • Validate that is passes:
...
[INFO] --- enforcer:3.5.0:enforce (enforce-poetry) @ habushu-uv-enforcer-rule ---
[INFO] Rule 0: org.technologybrewery.habushu.enforcer.RequireUvVersionRule(requireUvVersion) passed
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.677 s
[INFO] Finished at: 2025-03-26T13:08:01-04:00
[INFO] ------------------------------------------------------------------------
  • Update the required uv version to be higher than your current version (e.g., 0.7.0) by updating the examples/habushu-uv-enforcer-rule/pom.xml:
...
                        <configuration>
                            <rules>
                                <requireUvVersion>
                                    <version>>=0.7.0</version>
                                </requireUvVersion>
                            </rules>
                        </configuration>
...
  • Execute the Poetry Enforcer Rule: mvn clean install -pl :habushu-poetry-enforcer-rule -P uv -Dmaven.build.cache.skipCache=true
    Validate that is fails:
...
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.686 s
[INFO] Finished at: 2025-03-26T13:04:50-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.5.0:enforce (enforce-poetry) on project habushu-uv-enforcer-rule: 
[ERROR] Rule 0: org.technologybrewery.habushu.enforcer.RequireUvVersionRule(requireUvVersion) failed with message:
[ERROR] uv version 0.6.10 was installed - the project requires uv >=0.7.0. Please update uv by executing 'uv self update' or visit https://docs.astral.sh/uv/getting-started/installation/ for more information
...

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions