Talk about going through the source path when delombok

I didn't write much about the content at the company, but it was unusually packed, so I made a note. I was caught in a place where there was no such thing, but it was a story.

background

An error that cannot be verified when a test was executed on the product when introducing the inspection test. As for the contents, the tool cannot solve the code automatically generated by lombok, and the entire file will be excluded from the verification target.

Therefore, the purpose is to make it parseable by using the * delombok * function that can output the automatically generated code provided by lombok. It seems that the same method may be taken for javadoc generation.

Realization method

Since ant is used for build, add it to the target of ant based on the example described officially. https://projectlombok.org/features/delombok

There are some differences, but it seems that the class to be referenced differs depending on the version of lombok you are using. Specify the following class according to the version you are using.

<taskdef classname="lombok.delombok.ant.DelombokTask" name="delombok" classpath="lombok.jar" />

Error and error

When I run it with ant delombok, I get an error. Do you compile once when the code is output? I don't think I can refer to the library. Add the classpath used in normal compilation so that you can refer to the library.

<classpath refid="compile-classpath" />

Now I can compile it safely, but I still get an error ... It seems that the content is also a compile error and this time the java file in the product can not be referenced.

Normally, when compiling with javac, it is necessary to explicitly specify the source path with the `` `srcdir``` option. Otherwise, the path of the package in the java file cannot be resolved.

In delombok, the specified option is not described in the example. (I thought it would be nice from ant's home directory ...) I spend a few days without finding any documentation and not knowing what options to specify ...

After all, it was processed correctly if it was described appropriately from the options when executing the delombok command line.

<delombok verbose="true" encoding="UTF-8" to="[File output destination after processing]" sourcepath="[Source path]">

The final target was as follows.

  <target name="delombok">
    <taskdef classname="lombok.delombok.ant.DelombokTask" name="delombok" classpath="lombok.jar" />

    <delombok verbose="true" encoding="UTF-8" to="[File output destination after processing]" sourcepath="[Source path]">
      <fileset dir="Directory to be processed" includes="**/*.java" />
      <format value="suppressWarnings:skip" />
      <classpath refid="compile-classpath" />
    </delombok>
  </target>

Isn't there an official manual or documentation? ?? It seems likely, but I couldn't find it ...

After delombok, I will write another script that prepares a small script such as returning the multibyte character replaced with unicode.

Recommended Posts

Talk about going through the source path when delombok
About specifying the JAXRS path
When reading the source code
When deploying the source used twitter4j failed
About the speed when fetching values from HashMap
[CentOS 8] About the work when rebuilding ConoHa VPS
Creating an object without going through the constructor
About the mechanism when displaying the GUI with Docker