Languages
[Edit]
EN

Maven + Intellij IDEA - enable lombok annotation processor from pom.xml instead of Intellij IDEA level

7 points
Created by:
Tyreese-Aguirre
289

Quick solution:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>my-project</groupId>
	<artifactId>my-project</artifactId>
	<version>1.0</version>

	<name>my-project</name>
	<packaging>jar</packaging>

    <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web/2.4.3 -->
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.4.3</version>
		<relativePath/>
	</parent>

	<properties>
		<java.version>1.8</java.version>
		<spring.version>${project.parent.version}</spring.version>
		<maven.compiler.source>${java.version}</maven.compiler.source>
		<maven.compiler.target>${java.version}</maven.compiler.target>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
	</properties>

	<dependencies>
        <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.6</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

	<!-- https://github.com/dirask/spring-boot-web-jsp-example -->
	<build>
		<finalName>${project.artifactId}</finalName>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.7.0</version>
				<configuration>
					<annotationProcessorPaths>
						<path>
							<groupId>org.projectlombok</groupId>
							<artifactId>lombok</artifactId>
							<version>1.18.6</version>
						</path>
					</annotationProcessorPaths>
					<source>${maven.compiler.source}</source>
					<target>${maven.compiler.target}</target>
					<verbose>true</verbose>
				</configuration>
			</plugin>
		</plugins>
	</build>

</project>

Note: provided scope used with lombok prevents embedding into the output JAR package.

See also

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join