Open dallinbeutler opened 3 years ago
Hello @dallinbeutler, I can take a look.
I think a new goal for a post-compilation phase can be added to Spoon-maven-plugin that uses spoon-decompiler
to add class files as input resources.
In the meantime, have you considered using delombok? Spoon-maven-plugin adds to its input sources generated by other tools. It may be a safer option since bytecode can not always be decompiled to the correct source code.
yeah, I couldn't figure out how to get those steps to work with the maven plugin? Lombok and maven are both trying to work from the same source, and I don't know how best to chain this stuff.
And yeah, I'm using delombok for now. I figured with our teams impending integration of Spring Boot weaving backend stuff it would be a good question to bring up now.
Thanks again for taking a look!
This is actually something that troubled me in the past and i kinda followed @andrewbwogi suggestion by generating the project packages and then decompiling them with spoon-decompiler
.
If it helps, i'll post the code i did to overcome this below:
launcher = new Launcher();
File projectDir = new File(projectPath);
// search for .jar files
String[] extensions = new String[]{"jar"};
Collection<File> packageFiles = FileUtils.listFiles(
projectDir,
extensions,
true
);
for (File packageFile : packageFiles) {
String packagePath = packageFile.getPath();
// decompile .jar into a custom folder
String decompiledPackageSourcesPath = Constants.DECOMPILED_SOURCES_PATH
+ packagePath.substring(packagePath.lastIndexOf("/")+1)
+ File.separator;
new File(decompiledPackageSourcesPath).mkdirs();
new DecompiledResource(
packagePath,
null,
null,
decompiledPackageSourcesPath
);
// add new folder as input resource
launcher.addInputResource(decompiledPackageSourcesPath);
}
Hey, fairly new to Spoon here. I'm using Lombok to generate constructors for me on this class:
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:
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?