Search code examples
javaeclipsemavenswagger-codegenswagger-codegen-maven-plugin

Eclipse project does not recognize Swagger Codegen artefacts


I added Swagger Codegen to my Eclipse project by modifying my pom.xml file directly:

<plugin>
    <!--
        Plugin that provides API-first development using swagger-codegen to
        generate Spring-MVC endpoint stubs at compile time from a swagger definition file
    -->
    <groupId>io.swagger</groupId>
    <artifactId>swagger-codegen-maven-plugin</artifactId>
    <version>${swagger-codegen-maven-plugin.version}</version>
    <executions>
        <execution>
                <id>generate-swagger-javaclient</id>
                <phase>generate-sources</phase>
                <goals>
                    <goal>generate</goal>
                </goals>
                <configuration>
                    <inputSpec>src/main/resources/swagger/remote-api.json</inputSpec>
                    <language>java</language>
                    <apiPackage>com.myproj</apiPackage>
                    <modelPackage>com.myproj.model</modelPackage>
                    <generateSupportingFiles>true</generateSupportingFiles>
                    <generateApiTests>false</generateApiTests>
                    <configOptions>
                        <dateLibrary>java8</dateLibrary>
                    </configOptions>
                    <library>resttemplate</library>
                </configuration>
            </execution>
        </executions>
    
</plugin>

If I run Maven update or the Maven generate-sources target, I get all the artefacts generated in my Eclipse project's /target/generated-sources/swagger/src folder.

However, Eclipse does not recognize them. Am I supposed to edit my Eclipse build path manually like some commoner, or is Eclipse supposed to recognize this new source folder automatically?


Solution

  • The answer, at this time, is that adding the generated source folder to the build path seems to be mandatory.