javagradlemaven-deploy-plugingithub-package-registry

Gradle/Maven deploy to github packages - Preserving parameter/argument names


I am publishing a package to github packages . In the published package, the argument names in interfaces are getting polluted.

this is how my interface class looks like-

public interface detailAPI {
  getDetails(@ApiParam(value = "", required = true)  @RequestParam(value = "userId", required = true) BigDecimal userId
}

After loading the package from github packages in another project , this is the class in my external dependencies -

public interface detailAPI {
    getDetails(@ApiParam(value = "",required = true) @RequestParam(value = "userId",required = true) BigDecimal var1
}

the argument "userID" has been changed to "var1" in the uploaded package. I'm assuming gradle/maven both do this for some optimisation.

All argument names have changes to vars, s1, s2...

Is there a way to prevent this ? Would appreciate your help.


Solution

  • I believe you need to compile with the -parameters flag.

    tasks {
        javaCompile {
            options.compilerArgs.add("-parameters")
        }
    }
    

    Reference: https://www.baeldung.com/java-parameter-reflection