So, I have long wanted to use Lombok - and I am finally starting a project where I can use it. It is important to note that this will be a large enterprise-level application, and therefore the integration patterns used should be meaningful with a minimum number of hackers.
So, I looked at the lombok-maven plugin and the whole delombok fudge. I understand that this duplicates all my code and extends the lombok annotations where they are present. This gives me a second set of generated .java files that maven should use at compile time.
However, by creating these new source files, eclipse selects them and tries to pull them into my project. Thus, it takes millions (OK, slight exaggerations) of errors in relation to repetitive classes.
Some solution assumes that I am changing the <sourceDirectory> in my POM. This makes things no better, since mvn eclipse:eclipse now completely drop my src/main/java directory from the project - it will only show me the result of the delombok process.
Then comes the suggestion that I need to use one profile to compile / package the project, and the other mvn eclipse:eclipse . This is not an acceptable solution, since I have to spend enough time maintaining / explaining my already complicated maven setup - without having to enter an entire new profile (besides my existing profiles).
I hope for some inspiration to save me from recording Lombok for my project. This is a great tool for reducing the code of templates, but it just does not seem ready for use in real time in business, which I consider very disappointing: - (
The following is my POM:
<build> <sourceDirectory>target/generated-sources/delombok</sourceDirectory> <testSourceDirectory>target/generated-test-sources/delombok</testSourceDirectory> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> <plugin> <groupId>org.projectlombok</groupId> <artifactId>lombok-maven-plugin</artifactId> <version>1.12.2.0</version> <dependencies> <dependency> <groupId>sun.jdk</groupId> <artifactId>tools</artifactId> <version>1.7</version> <scope>system</scope> <systemPath>${java.home}/../lib/tools.jar</systemPath> </dependency> </dependencies> <executions> <execution> <id>delombok</id> <phase>generate-sources</phase> <goals> <goal>delombok</goal> </goals> <configuration> <encoding>UTF-8</encoding> <addOutputDirectory>false</addOutputDirectory> <sourceDirectory>src/main/java</sourceDirectory> </configuration> </execution> <execution> <id>test-delombok</id> <phase>generate-test-sources</phase> <goals> <goal>testDelombok</goal> </goals> <configuration> <encoding>UTF-8</encoding> <addOutputDirectory>false</addOutputDirectory> <sourceDirectory>src/test/java</sourceDirectory> </configuration> </execution> </executions> </plugin> </plugins> </build>
Currently, it only puts deliberated code in my eclipse project.
Final note. I am also very upset that I need to manually install lombok in all the eclipse installations that we are going to use. Mostly because it's me who will receive a phonecall from all developers who cannot make it work. I understand why it is not as simple as mvn eclipse:eclipse , but I still wanted to note my disappointment. If we had to manually configure each library for use on each development machine, we returned to the pre-maven days.