-    ≉  Under 1 min read

Delombok Java Beans

If you are using Lombok you can let lombok generate via the Maven Plugin the source code.

There are several approaches. Per se, Lombok expects a dedicated source folder src/main/lombok. If you have your Java Beans not in that folder, you can configure in the build section of the lombok maven plugin the sourceDirectory.

 <!-- delombok for source analysis-->
<build>
<plugins>
    <plugin>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok-maven-plugin</artifactId>
        <version>1.16.18.0</version>
        <executions>
            <execution>
                <phase>generate-sources</phase>
                <goals><goal>delombok</goal></goals>
            <configuration>
                <addOutputDirectory>false</addOutputDirectory>
                <sourceDirectory>src/main/java/model</sourceDirectory>
            </configuration>
        </execution>
    </executions>
    </plugin>
</plugins>
</build>

If you are using the default, you need to add this source folder to the maven compiler plugin.

<build>    
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <includes><include>src/main/lombok</include></includes>
            </configuration>
        </plugin>
    </plugins>
</build>

Tan-Vinh Nguyen

Just a coder

Similar Stories


Development

List dependency tree in Apache Maven

Do you ever run into the situation that a open source library uses a logging framework and you don’t know which one? If you use Apache Maven as build tool, the easiest solution is just to invoke... Read on

Java

Build single module from multi module pom

If case you want to test or build only a project (sub module) you have several options since Maven 2.1 Read on

Open Source

The Maven Cookbook

The Maven Cookbook from Sonatype has a couple of interesting sections and topics, e.g. OSGi, JUnit and Scala.

Read on