using Spoon-maven-plugin with Lombok
- Dominant language
- Java
- Stars
- 2k
- Forks
- 392
- Avg merge
- 11h 24m
- Merged PRs (30d)
- 36
Description
Hey, fairly new to Spoon here.
I'm using Lombok to generate constructors for me on this class:
```java
import lombok.*;
@Getter
@Setter
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
public class SourceData {
private SystemID systemID = SystemID.UNDEFINED;
private ServiceID serviceID = ServiceID.UNDEFINED;
private SourceType sourceType = SourceType.UNKNOWN;
//using Lombok generated constructor (erroring here)
public static final SourceData UNDEFINED = new SourceData(
SystemID.UNDEFINED,
ServiceID.UNDEFINED,
SourceType.UNKNOWN);
}
```
I'm trying to use the maven plugin to add another layer of functions to the class,
but when I compile I get the error:
```
...
[INFO] --- spoon-maven-plugin:3.4.2:generate (default) @ entity ---
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by fr.inria.gforge.spoon.util.ClasspathHacker (file:/C:/Users/111770/.m2/repository/fr/inria/gforge/spoon/spoon-maven-plugin/3.4.2/spoon-maven-plugin-3.4.2.jar) to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of fr.inria.gforge.spoon.util.ClasspathHacker
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Running in NOCLASSPATH mode (doc: http://spoon.gforge.inria.fr/launcher.html).
[INFO] Running in FULLCLASSPATH mode (doc: http://spoon.gforge.inria.fr/launcher.html).
[INFO] Spoon version 8.1.0
[INFO] running Spoon...
[INFO] start processing...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.188 s
[INFO] Finished at: 2021-03-03T19:07:14-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal fr.inria.gforge.spoon:spoon-maven-plugin:3.4.2:generate (default) on project entity: Exception during the spoonify of the target project.: The constructor SourceData(SystemID, ServiceID, SourceType) is undefined at D:\data\entityGenerator\src\main\java\com\entity\SourceData.java:51 -> [Help 1]
...
```
I'm assuming that this is because the `Launcher` doesn't know how to handle the all args constructor that would have been generated, but isn't, because this is source code.
So my question is, is there a maven plugin configuration in which I can make this still work? Is there a way to configure the pom.xml so that the spoon-maven-plugin analyzes the compiled bytecode?
Contributor guide
Research direction
Start with SourceData.java and the spoon-maven-plugin configuration in pom.xml, then reproduce the failure using the Lombok-generated constructor shown in the issue. Read the plugin's source-processing and classpath modes to determine whether compiled bytecode can be analyzed; done means the documented configuration works or the limitation is reproduced with a focused test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100