Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-10711

Consider using add[Test]CompileSourceRoot in api component maven plugin

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.19.0
    • Component/s: tooling
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      When using camel-api-component-maven-plugin we must also add
      build-helper-maven-plugin to ensure that generated sources are added
      to the project for compilation.

      To avoid this configuration step it is possible to add the source path
      directly from the plugin by calling MavenProject.addCompileSourceRoot
      and MavenProject.addTestCompileSourceRoot.

      project.addCompileSourceRoot(this.generatedSrcDir.getAbsolutePath());
      project.addTestCompileSourceRoot(this.generatedTestDir.getAbsolutePath());
      

      This can maybe be done at the end of the execute method of ApiComponentGeneratorMojo and AbstractApiMethodGeneratorMojo.

      It could also be a nice idea to add boolean properties in AbstractGeneratorMojo in order to enable or disable the automatic addition of the source.

      @Parameter(defaultValue = "true", property = PREFIX + "addCompileSourceRoot", required = false)
      private boolean addCompileSourceRoot = true;
      @Parameter(defaultValue = "true", property = PREFIX + "addTestCompileSourceRoot", required = false)
      private boolean addTestCompileSourceRoot = true;
      
      if (this.addCompileSourceRoot) {
        project.addCompileSourceRoot(this.generatedSrcDir.getAbsolutePath());
      }
      if (this.addTestCompileSourceRoot) {
       project.addTestCompileSourceRoot(this.generatedTestDir.getAbsolutePath());
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                davsclaus Claus Ibsen
                Reporter:
                mcollovati Marco Collovati
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: