In my POM I have this dependency
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>0.10.0-RC1</version>
<scope>provided</scope>
</dependency>
</dependencies>
Now I'm trying to use this in the Maven exec plugin like this:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>delombok-source</id>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath>
<dependency>org.projectlombok:lombok</dependency>
</classpath>
<argument>lombok.core.Main</argument>
<argument>delombok</argument>
<argument>src/main/java</argument>
<argument>-d</argument>
<argument>target/src-delomboked</argument>
</arguments>
</configuration>
</plugin>
But every time I execute exec:exec
, I get a "java.lang.NoClassDefFoundError: lombok/core/Main" error. Some testing showed that this is because the dependency is declared in the provided scope
Why can't the exec plugin use provided dependencies? Second, is there any way for the exec plugin to use that dependency without changing the dependency scope?
Found out the answer later: Simply add this to your config
<classpathScope>compile</classpathScope>
In hindsight this makes sense as lombok is a compile time annotation processor, not a runtime dependency.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With