Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
5 of 6 tasks
smaarster opened this issue Jun 19, 2024 · 4 comments

Comments

@smaarster
Copy link

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
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
Copy link
Member

wing328 commented Jun 19, 2024

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
Copy link
Author

smaarster commented Jun 19, 2024

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
Copy link
Member

wing328 commented Jun 19, 2024

$ 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
Copy link
Author

smaarster commented Jun 19, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants