OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
20.51k stars 6.27k forks source link

[BUG] generated java client fails 'mvn install' due to undefined version of maven-dependency-plugin #18977

Closed smaarster closed 1 week ago

smaarster commented 1 week ago

Bug Report Checklist

Description

When generating a java client the plugin configuration of the maven-dependency-plugin is not defined. That leads to a failing build with standard target 'mvn install' because of the maven-enforcer-plugin: Rule 1: org.apache.maven.enforcer.rules.RequirePluginVersions

Skipping the enforcer plugin is possible but not desirable.

openapi-generator version

7.2.0, 7.6.0, 7.7.0-SNAPSHOT

OpenAPI declaration file content or url

reproducable with the example pet store project.

Generation Details

generate -g java --skip-validate-spec --additional-properties=library=resttemplate

Steps to reproduce
  1. Generate java client
  2. 'mvn install' in generated client project
Related issues/PRs
Suggest a fix

It seems that all the mustache templates for pom.xml files do not contain a version for the dependency plugin. Setting a value there would most probably fix the issue.

wing328 commented 1 week ago

i tested with java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java --library resttemplate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o /tmp/resttemplate/

and both mvn clean package, gradle build run without issues

smaarster commented 1 week ago

Thanks for your test wing238, could you tell me which maven version you are using and/or show the config for the maven-dependency plugin (in pom.xml)?

wing328 commented 1 week ago
$ mvn --version
Apache Maven 3.9.5 (57804ffe001d7215b5e7bcb531cf83df38f93546)
Maven home: C:\Users\wing3\apache-maven-3.9.5
Java version: 17.0.10, vendor: Eclipse Adoptium, runtime: C:\Program Files\Eclipse Adoptium\jdk-17.0.10.7-hotspot
Default locale: en_HK, platform encoding: Cp1252
OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"

i'm using the auto-generated pom.xml in the java (resttemplate) client

smaarster commented 1 week ago

Thank you for your effort. The issue at my side was introduced through the enforcer-plugin on the parent pom I generated into the pom.xml. Still the question to me is, do you know why (in opposite to the other definitions) the version of the maven-dependency-plugin is not defined explicitely?