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

1.2.0.Beta2 doesn't generate sources in Eclipse #1207

Closed
eximius313 opened this issue May 22, 2017 · 13 comments
Closed

1.2.0.Beta2 doesn't generate sources in Eclipse #1207

eximius313 opened this issue May 22, 2017 · 13 comments

Comments

@eximius313
Copy link

I'm using mapstruct-jdk8 version 1.2.0.Beta2 (Beta2 because I use Lombok as well) together with Hibernate Static Metamodel Generator.
My configuration in Eclipse is as following:
image

Files generated by Hibernate Static Metamodel Generator are placed inside .apt_generated folder while Mapstruct generated files are missing

Could you please fix that?

@filiphr
Copy link
Member

filiphr commented May 22, 2017

Did it work with previous versions?

Do you use some build tool? If yes how does the setup look like in it, does it build OK with it?

Does it work if you don't have lombok?

@eximius313
Copy link
Author

eximius313 commented May 22, 2017

1)I don't know - I started project with this version
2)I use gradle, but this issue is present in fresh Eclipse import. I'm providing the test case.
showcase_apt_mapstruct.zip

  • Import to Eclipse (project will not yet compile)
  • invoke ./gradlew eclipse (in order to configure paths)
  • Project should compile and Metamodel classes are generated, but not Mapstruct
  • Run tests on both "backend" and "frontend" to see results

3)I must use Lombok

@agudian
Copy link
Member

agudian commented May 22, 2017

Well, after importing the projects in Eclipse (I ran gradlew eclipse first), the metamodel and the mapper were generated. However, Lobmok didn't run... But I don't have the lombok agent in Eclipse, so that might be expected:

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2017-05-22T20:50:26+0200",
    comments = "version: 1.2.0.Beta2, compiler: Eclipse JDT (IDE) 1.2.100.v20160418-1457, environment: Java 1.8.0_112 (Oracle Corporation)"
)
@Component
public class UserMapperImpl implements UserMapper {

    @Override
    public UserDTO userToUserDto(User user) {
        if ( user == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO();

        return userDTO;
    }
}

Is frontend/.apt_generated empty for you?

@filiphr
Copy link
Member

filiphr commented May 22, 2017

I also tried the example (without eclipse) and the mappers were also generated but in frontend/build/generated/source/apt/main.

@agudian Lombok must have run, because otherwise we cannot generate the Mappers. Both the User and the UserDTO need Lombok so we can use the methods.

@filiphr
Copy link
Member

filiphr commented Jul 2, 2017

I am going to close this one as the problem is not related to MapStruct and also it works for me without Eclipse and for @agudian in Eclipse.

@filiphr filiphr closed this as completed Jul 2, 2017
@evser
Copy link

evser commented Oct 10, 2017

See: #1159
Thanks @jmax01, it helps, but I've found several more steps that should be performed:

  1. gradlew clean cleanEclipse eclipse
  2. Import project to Eclipse
  3. Remove lombok.jar javaagent from Eclipse
  4. Restart Eclipse
  5. Trigger generation of a class annotated with @Mapper (edit this class or rebuild project)
  6. Add lombok.jar javaagent to Eclipse
  7. Restart Eclipse

Now all classes will be generated properly.
P. S. Check you configuration files (pom.xml/build.gradle) : https://github.com/mapstruct/mapstruct-examples/tree/master/mapstruct-lombok
And don't forget to add 'eclipse-wtp' plugin.

@sjaakd
Copy link
Contributor

sjaakd commented Oct 15, 2017

@filiphr : should we document these steps somewhere?

@eximius313
Copy link
Author

@sjaakd, as far as I understood you have to add the org.mapstruct.ap.spi.AstModifyingAnnotationProcessor.class file to the lombok.jar first, so I think it's just a workaround. It (perhaps) works, but it's ugly...

@evser
Copy link

evser commented Oct 15, 2017

@eximius313 yes, you're right. But this step is not enough, it's only the first step, you need 7 additional ones. That's what I was trying to say.

@filiphr
Copy link
Member

filiphr commented Oct 15, 2017

@sjaakd I've created mapstruct/mapstruct.org#65 for our website. We can add this under the eclipse setup or maybe as an FAQ, I don't know what is the best.

@evser
Copy link

evser commented Oct 15, 2017

I would propose to check my solution once again on a clean Eclipse instance, just to make sure that all steps are really valid (I checked them several times, but hope that they work not only for me).

@agudian
Copy link
Member

agudian commented Oct 15, 2017

This really looks like a coincidence and not like something that will continue to work within one project. Eg the removing and adding of the lombok agent and the triggering of the mapper generation in between restarts doesn’t sound like something that has an actual effect on persisted configuration values in Eclipse. Hence I wouldn’t add it to the docs...

I think it’s more something that the lombok guys might need to look into, right?

@filiphr
Copy link
Member

filiphr commented Oct 15, 2017

@agudian you might be right. To be honest I didn't read all the steps completely (and I don't know Eclipse a lot).

One thing I know is that there are issues with the lombok agent (multiple people have been complaining that it does not work with MapStruct and the AstModifyingAnnotationProcessor. I think the Lombok guys should do something about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants