Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't compile with lombok #5942

Closed
freemanpolys opened this issue Jun 16, 2017 · 18 comments
Closed

Can't compile with lombok #5942

freemanpolys opened this issue Jun 16, 2017 · 18 comments
Milestone

Comments

@freemanpolys
Copy link

Overview of the issue

./mvnw and mvn clean install fail when adding lombok dependency but run successfully when launched from Intellij IDE
Find the error below :

INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] src/main/java/web/rest/core/service/impl/ProductServiceImpl.java:[18,29] cannot find symbol
  symbol:   method builder()
  location: class com.test.one.web.rest.core.model.Product
Motivation for or Use Case

Use lombok annotations for my custom POJOs setter/getter and builder.

Maven build failed.

Reproduce the error

add lombok dependency in the pom.xml

        <!-- jhipster-needle-maven-add-dependency -->
        <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.16.16</version>
            <scope>provided</scope>
        </dependency>

create new java class as below

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class Product {
    private String name;
}

Run ./mvnw or maven clean install

JHipster Version(s)

generator-jhipster@4.4.1

JHipster configuration

{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.test.one",
      "nativeLanguage": "fr"
    },
    "jhipsterVersion": "4.4.1",
    "baseName": "airpayapi",
    "packageName": "com.test.one",
    "packageFolder": "com/test/one",
    "serverPort": "8081",
    "authenticationType": "jwt",
    "hibernateCache": "hazelcast",
    "clusteredHttpSession": false,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "postgresql",
    "searchEngine": "elasticsearch",
    "messageBroker": false,
    "serviceDiscoveryType": "eureka",
    "buildTool": "maven",
    "enableSocialSignIn": false,
    "enableTranslation": true,
    "applicationType": "microservice",
    "testFrameworks": [
      "gatling"
    ],
    "jhiPrefix": "jhi",
    "skipClient": true,
    "skipUserManagement": true,
    "nativeLanguage": "fr",
    "languages": [
      "fr",
      "en"
    ],
    "clientPackageManager": "yarn"
  }
}
@PierreBesson
Copy link
Contributor

PierreBesson commented Jun 16, 2017

JHipster doesn't offically support Lombok. Please use stackoverflow to ask for help.
See #3895 and other Lombok issues.

@jdubois
Copy link
Member

jdubois commented Jun 16, 2017

Yes and I'll need to update my list of days lost because of Lombok... Why the hell do people use it?

@xetys
Copy link
Member

xetys commented Jun 16, 2017

possibly Lombok is an example for anti-patterns, looks like a good idea, while it's actually not 😄

@freemanpolys
Copy link
Author

freemanpolys commented Jun 17, 2017

We use Lombok to avoid writing annoying setter/getter and it inject builder pattern too :)
@PierreBesson I don't understand, JHispter is just a Spring Boot + Angular project generator right ?
Why is Lombok working in a Spring Initializr project and not in in a JHipster one ?

@jdubois
Copy link
Member

jdubois commented Jun 17, 2017

Because we do so much more than Spring Initializer...
I've spent so many days on projects failing because of Lombok, I have no idea why people want to use this. There's one "smart" guy who gains a few minutes for not generating his getter/setter, and then you have whole teams stuck, production system failing, and consultants billed to solve the issue. That thing is costing so many $$$.
Note that I shouldn't complain too much, I'm one the guys who are paid to solve those issues... Already happened on 4 different projects, and counting...

@freemanpolys
Copy link
Author

Ok I see, I'm one of this "lazy" guys :)
Beyond Jpa - Hibernate , do you plan to support mybatis? I use to use it and Spring Boot too.

@jdubois
Copy link
Member

jdubois commented Jun 17, 2017

"smart", I said "smart" :-)

@xetys
Copy link
Member

xetys commented Jun 17, 2017

I explain that, as Julien did this so many times. We have some policies. In general, they are talking about providing a minimum of fancy stuff, and try to be maximal conform with default configuration. Sure, there are tons of different solutions in every single stack JHipster provides, as Lombok for POJOs, Mybatis as Hibernate replacement, minimum 1337 different (distributed) caching solutions, angular plugins etc...
As soon as we decide to support one more of those options, we are responsible for offering a working solution across all future releases. The more new stuff we support, the longer it takes to create the next really stable release. The benefit for the majority of our users is small, while the waiting time for useful stuff gets long.

That's why we focus on the necessary features, which helps a lot of people.

Especially that I don't get why people do hype Lombok so hard. The most of them are using IntelliJ or Eclipse, where you just do a fast combo and get your getter/setters

@freemanpolys
Copy link
Author

Ok I get it. I have to stick to JHipster policies because it's a great generator which do cool things. Thanks guys.

@andidev
Copy link
Member

andidev commented Jun 17, 2017

@freemanpolys
I have no problem using lombok in JHipster projects. Are you sure you configured everything correctly?

@freemanpolys
Copy link
Author

freemanpolys commented Jun 17, 2017

I don't make any configuration usually with my Spring Boot project. I just add the dependency and use Lombok @DaTa , @builder annotations. As JHipster does much more than Spring Initializer, I was supposing that it will behave and do at least things that Spring Boot project use to do :(

@freemanpolys
Copy link
Author

Anyway @andidev, which configs do you do ?

@jdubois
Copy link
Member

jdubois commented Jun 17, 2017

Not sure, but we added the Afterburner module for Jackson recently : that's the kind of thing that won't work well with Lombok

@freemanpolys
Copy link
Author

Ok @jdubois. @andidev, we have to definitely stick to JHipster policies :-)

@andidev
Copy link
Member

andidev commented Jun 17, 2017

@jdubois jdubois modified the milestone: 4.5.5 Jun 19, 2017
@jimmysyss
Copy link

The maven project Jhipster generated uses a annotationProcessorPaths in the maven compile plugin, that's why it cannot look up the latest lombok unless we specify lombok as one of the annotation processor.

Working code is as followed.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>${maven-compiler-plugin.version}</version>
    <configuration>
        <annotationProcessorPaths>
            <path>
                <groupId>org.mapstruct</groupId>
                <artifactId>mapstruct-processor</artifactId>
                <version>${mapstruct.version}</version>
            </path>
            <!-- For JPA static metamodel generation -->
            <path>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-jpamodelgen</artifactId>
                <version>${hibernate.version}</version>
            </path>
			<path>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.16.18</version>
            </path>
        </annotationProcessorPaths>
    </configuration>
</plugin>

@pdinc-oss
Copy link

<version>${maven-compiler-plugin.version}</version>
...
            <version>${hibernate.version}</version>

version numbers?

@PierreBesson
Copy link
Contributor

Please don't comment on an old issue.
If you think this issue still applies, please create a new ticket with proper details.

If you have a question please use Stack Overflow, and tag the question with jhipster. This helps the project to keep the issue tracker clean. Also, Stack Overflow will give your question a larger audience:

  • This will increase your chances to get an answer
  • Answers will be of higher quality, as there is a voting system
  • This will also help other users who might have the same issue, as questions are tagged and easily searchable

@jhipster jhipster locked as off-topic and limited conversation to collaborators Nov 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants