lombok
Very spicy additions to the Java programming language.
Project Lombok spice up your java
My android project builds fine with lombok 1.16.0, but once I change my dependency to target 1.16.2, I get the following error everywhere I'm using a lombok annotation:
Error:(20, 1) error: package javax.annotation does not exist
The Android SDK does not include all javax packages. What I'm wondering is if this is a bug in 1.16.2 or do I now have to add a dependency to javax.annotation
?
Note: This is in Android Studio with Lombok plugin 0.8.8
Source: (StackOverflow)
I want to use a data class in Lombok. Since it has about a dozen fields, I annotated it with @Data
in order to generate all the setters and getter. However there is one special field for which I don't want to the accessors to be implemented.
How does Lombok omit this field?
Source: (StackOverflow)
Do you know any Lombok alternatives ?
Using Lombok we can forget about messing class with getters and setters and toString, I want use it in my project however I wonder if there are any better alternatives?
I am using Java 1.7.. and cannot change to 1.8.
Source: (StackOverflow)
In case you don't know, Project Lombok helps with some of the annoyances of Java with stuff like generating getters and setters with annotations and even simple JavaBean like generation with @Data. It could really help me, especially in 50 different event objects where you have up to 7 different fields that need to be constructed and hidden with getters. I could remove almost a thousand lines of code with this.
However I'm worried that in the long run it will be a regretful decision. Flamewars will erupt in the ##Java Freenode channel when I mention it, providing code snippets will confuse possible helpers, people will complain about missing JavaDoc, and future commiters might just remove it all anyway. I would really enjoy the positive, but I'm worried about the negative.
So: Is it safe to use on any project, small or large? Are the positive effects worth the negatives?
Source: (StackOverflow)
I'm trying to use Lombok in my project that I'm developing using IntelliJ IDEA 11.
I've installed 3rd-party plugin for IDEA and it seems working fine because IDEA sees all autogenerated methods/fields.
So I have a class that uses Slf4j. I annotated it like this
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class TestClass
{
public TestClass()
{
log.info("Hello!");
}
}
But when I build my project compiler spits: cannot find symbol variable log
.
Could you please tell me what I'm missing here ?
Update: It turned out it's RequestFactory annotation process that fails.
input files: {com.zasutki.courierApp.server.TestServlet, com.mine.courierApp.server.model.DatastoreObject}
annotations: [javax.inject.Singleton, javax.inject.Inject, lombok.Getter, lombok.Setter, com.googlecode.objectify.annotation.Id, com.googlecode.objectify.annotation.OnSave]
Processor com.google.web.bindery.requestfactory.apt.RfValidator matches [lombok.Getter, com.googlecode.objectify.annotation.Id, javax.inject.Inject, lombok.Setter, com.googlecode.objectify.annotation.OnSave, javax.inject.Singleton] and returns false.
cannot find symbol variable log
Any ideas on workarounds ?
Update2: Perhaps it's not something readers want to hear but I ended up switching to Scala.
Source: (StackOverflow)
I met lombok today.
I'm very anxious to know how it works.
A Java Geek Article gives some clues but it's not perfectly clear to me:
Java 6 removes apt and make javac able
to manage annotations, streamlining
the process to obtain a simpler
single step computing. This is the
path taken by Lombok.
Maybe with Java 6 the compile process will be:
javac -> apt -> lombok apt process -> read class files and add set/get methods using ASM?
Could you show me more details about the mechanism?
Source: (StackOverflow)
I have a multimodule java project built with Maven to which I want to generate javadocs with javadoc:aggregate
. The project structure looks like:
parent
├─lomboklib
└─other
I am also using Project Lombok to generate some methods in the project. I have successfully configured it to work with single modules by first running delombok with the Lombok maven plugin. For single modules (lomboklib), this will generate source code in
target/generated-sources/delombok
which is then processed by maven-javadoc-plugin and the javadoc tool. This was originally solved in This SO question.
How can I configure the javadoc:aggregate
report to also use the generated sources?
I've put up a sandbox of the problem with all the module definitions in Github. Ideally, I should be able to run
mvn clean compile javadoc:aggregate
In the parent project, and have the whole thing compile and get javadocs for the entire project.
Source: (StackOverflow)
- I've installed the plugin for intellij idea(lombok-plugin-0.8.6-13).
- Added lombok.jar into classpath
- I can find getters and setters in the window of structure. And Intellij shows no error.
- Setting - Lombok plugin - Verified Intellij configuration for lombok, it shows that "configuration of IntelliJ seems to be ok".
It seems everything is OK. But when I compile a test, errors come: can not find the methods getXXX and setXXX.
I opened the .class file with IntelliJ and find out that there is no setXXX and getXXX methods.
Could somebody tell me why?
- plugin:lombok-plugin-0.8.6-13
- lombok.jar:1.14.0
- idea:13.0.2 for linux
- jdk:1.7.0_21
Source: (StackOverflow)
In my Maven based project I'm using Lombok to save some boilerplate code. Furthermore I'm using a Spring Data library which uses AspectJ to get things done. Sadly, Lombok and AspectJ don't play nicely together out of the box, as the AspectJ compiler recompiles the Java files. So the implemented Getter and Setters of Lombok are lost.
I decided to delombok my code using the Lombok Maven plugin. This code is then passed to AspectJ. This is the basic flow:
Sources in /src/main/java or /src/test/java
=> [Delombok]
=> Delomboked sources in /target/generated-sources/delombok or /target/generated-test-sources/delombok
=> [AspectJ]
=> Compiled results in /target/classes or /target/test-classes
However, one downside to this approach: I seem to have lost debug support using IntelliJ.
Breakpoints set in a /src/main/java or /target/generated-sources/delombok Java file are never hit. I run the project using the IntelliJ Maven plugin, selecting a lifecycle item (e.g. "test"), the debug hooks. Sadly, the breakpoints are never hit.
What can be done to get back debugging support?
Source: (StackOverflow)
Configure cobertura to ignore certain blocks of code
From what I have read from above question, there's no way in Cobertura to exclude given code part from being tested versus having coverage in tests.
Is that true? / Is it possible in any simmilar tool?
I'm usuing Lombok annotations @Getter
, @Setter
and so on, which are great, but they result in being 'red' in coverage report, even if I'm testing getter and setter methods. - I would like to do something with that... Is there any way to fix this?
Source: (StackOverflow)
I configure lombok in eclipse Luna with Maven. Annotation is added properly, but no getter and setter are generated.
eclipse.ini
`-vm E:\Program Files\Java\jdk1.7.0_60\bin`
`-vmargs`
`-Dosgi.requiredJavaVersion=1.7`
`-javaagent:F:\Tools\Java Lib\Lombok\lombok.jar`
`-Xbootclasspath/a:F:\Tools\Java Lib\Lombok\lombok.jar`
`-Xms40m`
`-Xmx512m`
Source: (StackOverflow)
I'm trying to run Dagger 2 as well as Lombok on my Java project. Lombok has to run first, of course, but whether it actually does seems to be up to chance. At first I suspected I could specify the order by the respective position of the library jars in the class path, but that order evidently gets ignored.
Is there a way to specify the order for them to run somehow, or do I simply have to live with not being able to combine two APs ?
I have produced an SSCCE test case.
A simple git clone
& mvn compile
is enough to demonstrate the issue - if you comment line 18 and uncomment lines 20-21 in App.java, it will compile, even though the Lombok notation in line 18 creates an identical constructor. The problem is that Lombok seems to run after Dagger.
Source: (StackOverflow)