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

Plugin does not work from inside Eclipse #509

Closed
javadch opened this issue Jul 8, 2018 · 10 comments · Fixed by #1332
Closed

Plugin does not work from inside Eclipse #509

javadch opened this issue Jul 8, 2018 · 10 comments · Fixed by #1332

Comments

@javadch
Copy link

javadch commented Jul 8, 2018

I have the following plugin spec in my eClipse POM:

<plugin>
  <groupId>org.openapitools</groupId>
  <artifactId>openapi-generator-maven-plugin</artifactId>
  <version>3.1.0</version>
  <executions>
    <execution>
    <phase>generate-resources</phase>
      <goals>
        <goal>generate</goal>
      </goals>
    <configuration>
      <inputSpec>${project.basedir}/src/main/resources/api.yaml</inputSpec>
      <generatorName>spring</generatorName>
    <configOptions>
    <dateLibrary>joda</dateLibrary>
    <sourceFolder>src/gen/java/main</sourceFolder>
    <modelPackage>services.nano.timex.models</modelPackage>
    <apiPackage>services.nano.timex.apis</apiPackage>
    <invokerPackage>services.nano.timex.invokers</invokerPackage>
    <delegatePattern>true</delegatePattern>
    <hideGenerationTimestamp>false</hideGenerationTimestamp>
  </configOptions>
  <library>spring-boot</library>
</configuration>
</execution>
</executions>
</plugin>

It generates the output artifacts using the mvn clean package command, but does not generate the code form inside Eclipse! The IDE complains about the node saying:

Description Resource Path Location Type Plugin execution not covered by lifecycle configuration: org.openapitools:openapi-generator-maven-plugin:3.1.0:generate (execution: default, phase: generate-resources) pom.xml /timex-backend-api line 34 Maven Project Build Lifecycle Mapping Problem

How can I fix this?

@wing328
Copy link
Member

wing328 commented Jul 9, 2018

@javadch I could be wrong but I don't think the issue is with the OpenAPI Generator plugin.

Would the following article help?

http://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html

@wing328 wing328 added this to the 3.1.1 milestone Jul 9, 2018
@jmini
Copy link
Member

jmini commented Jul 9, 2018

@wing328 : yes and no. Our maven plugin could be a little bit more eclipse IDE friendly by integrating some additional metadata. This way no error would be displayed in Eclipse IDE.

@wing328
Copy link
Member

wing328 commented Jul 9, 2018

@jmini 👌 please share more so that the community can help add the metadata.

@jmini jmini modified the milestones: 3.1.1, 3.1.2 Jul 18, 2018
@wing328 wing328 modified the milestones: 3.1.2, 3.2.0 Jul 25, 2018
@wing328 wing328 modified the milestones: 3.2.0, 3.2.1 Aug 6, 2018
@wing328 wing328 modified the milestones: 3.2.1, 3.2.2 Aug 14, 2018
@wing328 wing328 removed this from the 3.2.2 milestone Aug 22, 2018
@andreas-eternach
Copy link
Contributor

andreas-eternach commented Oct 26, 2018

@jmini 👌 please share more so that the community can help add the metadata.

I guess it is described here how to make the plugin compatible. I will give it a try http://www.eclipse.org/m2e/documentation/m2e-making-maven-plugins-compat.html

edit:

for me the full builds work after adding the lifecycle-mapping, but the source-code-generation also happens in incremental builds even when the openapi-definition has not changed.

To prevent unneccessary builds, the plugin needs to be modified. Before doing smthing it needs to check if the json defintion has changed by using the BuildContext (see https://github.com/sonatype/sisu-build-api/blob/master/src/main/java/org/sonatype/plexus/build/incremental/BuildContext.java).

lifecycle-mapping-metadata.xml.txt

@wing328
Copy link
Member

wing328 commented Oct 26, 2018

@andreas-eternach thanks! Let me know if you need help with the PR.

@andreas-eternach
Copy link
Contributor

probably the file
openapi-generator/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java needs to be updated accordingly.

@wing328
Copy link
Member

wing328 commented Oct 27, 2018

@javadch can you please try the fix by #1332 to see if it works for you?

Instructions to fetch the fix:

git checkout -b andreas-eternach-master master
git pull https://github.com/andreas-eternach/openapi-generator.git master

@andreas-eternach
Copy link
Contributor

@javadch can you please try the fix by #1332 to see if it works for you?

Instructions to fetch the fix:

git checkout -b andreas-eternach-master master
git pull https://github.com/andreas-eternach/openapi-generator.git master

@javadch after pulling the repo as described by @wing328 you need to

  1. cd modules/openapi-generator-maven-plugin
  2. mvn install
  3. in your eclipse-maven-project update the plugin verion to 3.3.2-SNAPSHOT
  4. in eclipse update your eclipse-maven-project by pressing Alt-F5

wing328 pushed a commit that referenced this issue Nov 4, 2018
* feat: OpenApi-generation from within eclipse (#509)

* Added life-cycle-mapping for recognition by M2E
* Make BuildContext injectable by M2E in oder to detect if json-source
has been modified and a regeneration is required.

* core: fix indentation problems, remove commented code
@wing328
Copy link
Member

wing328 commented Nov 4, 2018

@javadch the fix by @andreas-eternach has been merged into master. Please give it a try to see if it works for you.

Thanks @andreas-eternach for contributing the fix.

A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this issue Feb 27, 2019
…APITools#1332)

* feat: OpenApi-generation from within eclipse (OpenAPITools#509)

* Added life-cycle-mapping for recognition by M2E
* Make BuildContext injectable by M2E in oder to detect if json-source
has been modified and a regeneration is required.

* core: fix indentation problems, remove commented code
nilskuhn pushed a commit to nilskuhn/openapi-generator that referenced this issue Apr 6, 2023
…typescript-eslint-monorepo

chore(deps): update typescript-eslint monorepo to v5 (major)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants