-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Maven-Plugin adds wrong source folder to eclipse project Java Build path #2437
Comments
The workaround for 2.1.5 is setting addCompileSourceRoot to "false" and using the build-helper-maven-plugin to add the source folder ourselves:
|
Pls let me know if I should add a PR for this. |
Seeing the same issue - thanks for posting the workaround :) |
@jfiala please file a PR when you've time. Thanks! |
The issue should be fixed. Please pull the latest master to give it a try. |
It seems still not fixed? Version 2.2.2, eclipse still not auto add generate source folder as source folder
|
Any specific reason for doing this? |
Man, coming from wsdl2java and the like this plugin is a PITA to get working. I've finally figured out the required voodoo to get usuable client code: <plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.2.3</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/swagger/myswagger.json</inputSpec>
<language>java</language>
<generateApis>false</generateApis>
<generateModels>true</generateModels>
<generateModelDocumentation>false</generateModelDocumentation>
<generateModelTests>false</generateModelTests>
<generateSupportingFiles>false</generateSupportingFiles>
<modelPackage>com.example.client</modelPackage>
<configOptions>
<dateLibrary>java8</dateLibrary>
<sourceFolder>swagger</sourceFolder>
</configOptions>
<output>target/generated-sources</output>
</configuration>
</execution>
</executions>
</plugin> This yields a reasonable layout which works in eclipse and Maven CLI:
|
version: swagger-codegen-maven-plugin-2.1.5
The option "addCompileSourceRoot" is true by default.
It adds the following path as source folder to the eclipse Java Build path
target/generated-sources/swagger
However, the generated sources are located at:
target/generated-sources/swagger/src/main/java
So after running mvn eclipse:eclipse Eclipse will show build errors, the Source folder has to be corrected manually.
CodeGenMojo.java should be corrected from
to
However, the code above is only working if the sourceFolder is configured the plugin configuration/configOptions. To make it working without the sourceFolder configuration, the actual source folder needs to be retrieved from the Generator.
The text was updated successfully, but these errors were encountered: