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

Lombok #125

Closed
robertmircea opened this issue Oct 8, 2016 · 11 comments
Closed

Lombok #125

robertmircea opened this issue Oct 8, 2016 · 11 comments
Labels

Comments

@robertmircea
Copy link

How can I use Selma together with Lombok? It seems that Selma does not see the getters/setters generated by Lombok.

Failed to generate mapping method for type ..OtpData to .....resources.OtpDataResource not supported on ....model.OtpData --> Add a custom mapper or 'withIgnoreFields' on @Mapper or @Maps to fix this ! If you think this a Bug in Selma please report issue here
@slemesle
Copy link
Collaborator

slemesle commented Oct 9, 2016

The only way to get it work is to build separate jars :
one for lombok enabled beans and the other with selma.

@Musikolo
Copy link

Musikolo commented Jan 5, 2017

@slemesle, it's clear the issue with Lombok is just that at the time that Selma checks for a certain getter or setter method, Lombok processor didn't run, leading to Selma to fail. However, I think that if we would have a way to tell Selma, hey, don't worry if you don't find getters or setters, they will be available in runtime, it could continue generating mappers and complete successfully. In addition, when Maven (or whatever you use) completes, all the generated code should compile seamlessly too.

I'm sorry if I'm oversimplifying or missing anything important, but would that be possible? Would it possible adding a parameter to @Mapper such as withIgnoreNonexistentAccessors={true, false} to ignore nonexistent getters and setters?

Solving this issue would be really appreciated, and would make Selma way more flexible.

Thank you!

@TehBakker
Copy link

Yep, I'm facing this issue and will probably have to not use Selma because of it.
Shame really.

@jeantil
Copy link

jeantil commented Feb 20, 2017

Lombok is a compile time annotation pre-processor, so is selma.
Isn't it possible to setup the build so that selma runs "after" lombok and thus can use the lombok generated code ? It seems processors run in multiple rounds It might be worth trying not to fail on the first processing round (maybe log a warning - and make it configurable) and retry generation in the next round, and only fail on processingIsOver if there remain types with missing getter/setters.

@Musikolo
Copy link

The only solution as of today, is to have your beans in a separate module than your mapper is. This way maven (or whatever you have) will compile your beans first and then your mapper, making the whole process possible.

@anaice
Copy link

anaice commented Apr 27, 2017

I was able to generate the Lombok + Selma classes with:

pom.xml file:

<plugins>
   <build>    
      <plugin>
            <groupId>org.bsc.maven</groupId>
            <artifactId>maven-processor-plugin</artifactId>
            <version>3.3.1</version>
            <configuration>
                <defaultOutputDirectory>
                    ${project.build.directory}/generated-sources/selma
                </defaultOutputDirectory>
                <processors>
                    <processor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor</processor>                   
                    <processor>fr.xebia.extras.selma.codegen.MapperProcessor</processor>
                </processors>             
            </configuration>
            <executions>
                <execution>
                    <id>process</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>process</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>fr.xebia.extras</groupId>
                    <artifactId>selma-processor</artifactId>
                    <version>0.15</version>
                </dependency>
            </dependencies>
  </plugin>
 </plugins>
</build>

then : mvn generate-sources

@slemesle
Copy link
Collaborator

slemesle commented May 1, 2017

Hi @anaice, thanks for this update.
Is it possible for you to provide a short sample project we can include in the source tree and point to it from the documentation ?

@razvanone
Copy link

razvanone commented May 18, 2017

I was able to run a spring-boot project using a slightly modified maven 'build' tag:

<build>
	<plugins>
		<!-- Spring Boot Maven -->
		<plugin>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-maven-plugin</artifactId>
		</plugin>

		<plugin>
			<groupId>org.bsc.maven</groupId>
			<artifactId>maven-processor-plugin</artifactId>
			<version>3.3.1</version>
			<configuration>
				<defaultOutputDirectory>
					${project.build.directory}/generated-sources/selma
				</defaultOutputDirectory>
				<processors>
					<processor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor</processor>
					<processor>fr.xebia.extras.selma.codegen.MapperProcessor</processor>
				</processors>
			</configuration>
			<!--executions>
				<execution>
					<id>process</id>
					<phase>generate-sources</phase>
					<goals>
						<goal>process</goal>
					</goals>
				</execution>
			</executions-->
			<dependencies>
				<dependency>
					<groupId>fr.xebia.extras</groupId>
					<artifactId>selma-processor</artifactId>
					<version>1.0</version>
				</dependency>
			</dependencies>
		</plugin>
	</plugins>

	<pluginManagement>
		<plugins>
			<!--This plugin's configuration is used to store Eclipse m2e settings 
				only. It has no influence on the Maven build itself. -->
			<plugin>
				<groupId>org.eclipse.m2e</groupId>
				<artifactId>lifecycle-mapping</artifactId>
				<version>1.0.0</version>
				<configuration>
					<lifecycleMappingMetadata>
						<pluginExecutions>
							<pluginExecution>
								<pluginExecutionFilter>
									<groupId>org.codehaus.mojo</groupId>
									<artifactId>aspectj-maven-plugin</artifactId>
									<versionRange>[1.0,)</versionRange>
									<goals>
										<goal>process</goal>
										<goal>test-compile</goal>
										<goal>compile</goal>
									</goals>
								</pluginExecutionFilter>
								<action>
									<execute />
								</action>
							</pluginExecution>
						</pluginExecutions>
					</lifecycleMappingMetadata>
				</configuration>
			</plugin>
		</plugins>
	</pluginManagement>
</build>

Observe that I commented out the in the maven-processor-plugin. I can run a spring-boot project with both lombok and selma with mvn -U clean spring-boot:run. Just add this build section to your projects pom.xml. The 'pluginManagement' section is for solving the Eclipse “Plugin execution not covered by lifecycle configuration”.

@ajay-kmr
Copy link

I am able to solve this issue by proper selection of lombok and selma version.
Below is the sample code from my build.gradle file:-
dependencies { compileOnly("org.projectlombok:lombok:1.16.14") compileOnly("fr.xebia.extras:selma-processor:1.0") compile("fr.xebia.extras:selma:1.0") }

Note that Lombok 1.16.14 or newer is required.

@yugaga
Copy link

yugaga commented Jan 7, 2019

@ajay-kmr This trick was working for me until now. Don't know what's happening, perhaps the upgrade of Gradle.

@Anshulrathi
Copy link

Worked for me too !!

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

No branches or pull requests

10 participants