Skip to content

Maven-Plugin adds wrong source folder to eclipse project Java Build path #2437

@jfiala

Description

@jfiala

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

project.addCompileSourceRoot(output.toString());

to

String sourceJavaFolder = output.toString() + "/" + configOptions.get(CodegenConstants.SOURCE_FOLDER);
            project.addCompileSourceRoot(sourceJavaFolder);

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions