Reputation: 4932
I'm using lombok within IntelliJ. Everything works as expected even when I test the project with maven mvn clean test
everything is ok. But when I want to execute test from within IDE I'm getting errors:
org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #3 of class path resource [sql/core-base-schema.sql]: CREATE ALIAS GETTEXT AS'
String getText(Long textId, String langId) {
return "testText";
}'; nested exception is org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "/org/h2/dynamic/GETTEXT.java:5: warning: Can't initialize javac processor due to (most likely) a class loader problem: java.lang.NoClassDefFoundError: com/sun/tools/javac/processing/JavacProcessingEnvironment
public class GETTEXT {
^
at lombok.javac.apt.LombokProcessor.init(LombokProcessor.java:83)
at lombok.core.AnnotationProcessor$JavacDescriptor.want(AnnotationProcessor.java:87)
at lombok.core.AnnotationProcessor.init(AnnotationProcessor.java:140)
at lombok.launch.AnnotationProcessorHider$AnnotationProcessor.init(AnnotationProcessor.java:69)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$ProcessorState.<init>(JavacProcessingEnvironment.java:500)
...
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.processing.JavacProcessingEnvironment
at java.lang.ClassLoader.findClass(ClassLoader.java:530)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at lombok.launch.ShadowClassLoader.loadClass(ShadowClassLoader.java:422)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 55 more
1 warning
"; SQL statement:
CREATE ALIAS GETTEXT AS'
String getText(Long textId, String langId) {
return "testText";
}' [42000-191]
When I add system property -Dlombok.disable=true
to run configuration then test executes correctly.
Question is: how can I configure IntelliJ to be able to run JUnit tests from within it or How can I set global property for JUnit tests to disable lombok?
Upvotes: 0
Views: 1948
Reputation: 19968
You need to add the following dependency:
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<scope>system</scope>
<version>1</version>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
See the issue 1058 in Project Lombok and also the the question/answer Compiling a Java Class in memory with `lombok` annotations and Java JDK 8
Upvotes: 0
Reputation: 2085
Have you added Lombok plugin and turned on Annotation Processing (Settings -> Build, Execution, Deployment -> Compiler -> Annotation Processors -> check box "Enable annotation processing")?
Upvotes: 1
Reputation: 19968
You can add any system properties to run configurations within IntelliJ. To have that as a default, you can add the properties to JUnit default configuration in the same dialog (either choose JUnit from the ‘Defaults’ category or press the ‘Edit Defaults’ button).
That’s the answer to your question pertaining the global property. However, fixing the setup for tests to simply run woyld be better. Cannot help there for the moment, however.
Upvotes: 1