jhunters / jprotobuf

A useful utility library for java programmer using google protobuf
Apache License 2.0
897 stars 283 forks source link

预编译插件,一个实体被多个实体依赖时预编译中断 #208

Open Aliang-code opened 8 months ago

Aliang-code commented 8 months ago
<plugin>
                <groupId>com.baidu</groupId>
                <artifactId>jprotobuf-precompile-plugin</artifactId>
                <version>2.2.8</version>
                <configuration>
                    <filterClassPackage>com.xxx</filterClassPackage>
                    <classpathScope>compile</classpathScope>
                    <generateProtoFile>true</generateProtoFile>
                    <compileDependencies>true</compileDependencies>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>precompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

compileDependencies为true时,某个实体被多个实体依赖,在第二次检测依赖时由于预编译文件已生成而直接退出,输出以下日志: no modify class 'xxx', will skip precompile. 看代码这里是不是应该把return改为continue呢 https://github.com/jhunters/jprotobuf/blob/0e326bf8704027adc8af182e7cebc0e7a9c38e30/jprotobuf-precompile-plugin/src/main/java/com/baidu/jprotobuf/mojo/JprotobufPreCompileMain.java#L164

jhunters commented 8 months ago

164行的 return 应该处理没有问题。但是 195行的return 不合理,应该是continue

jhunters commented 8 months ago

fix at 2.2.11

com.baidu
<artifactId>jprotobuf-precompile-plugin</artifactId>
<version>2.2.11</version>
Aliang-code commented 8 months ago

fix at 2.2.11 com.baidu jprotobuf-precompile-plugin 2.2.11 有NPE

Caused by: jodd.io.findfile.FindFileException: Scan entry error: EntryData{com.*.ApiAccountUnit'}; <--- java.lang.NullPointerException at jodd.io.findfile.ClassFinder.scanEntry(ClassFinder.java:377) at jodd.io.findfile.ClassFinder.scanClassFile(ClassFinder.java:324) at jodd.io.findfile.ClassFinder.scanClassPath(ClassFinder.java:307) at jodd.io.findfile.ClassFinder.scanPath(ClassFinder.java:239) at jodd.io.findfile.ClassFinder.scanPaths(ClassFinder.java:178) at jodd.io.findfile.ClassScanner.scan(ClassScanner.java:35) at jodd.io.findfile.ClassScanner.scanDefaultClasspath(ClassScanner.java:28) at com.baidu.jprotobuf.mojo.JprotobufPreCompileMain.main(JprotobufPreCompileMain.java:182) ... 6 more Caused by: java.lang.Exception at com.baidu.jprotobuf.mojo.JprotobufPreCompileMain$1.onEntry(JprotobufPreCompileMain.java:144) at jodd.io.findfile.ClassFinder.scanEntry(ClassFinder.java:375) ... 13 more Caused by: java.lang.NullPointerException at com.baidu.jprotobuf.mojo.JprotobufPreCompileMain.createProtoFile(JprotobufPreCompileMain.java:255) at com.baidu.jprotobuf.mojo.JprotobufPreCompileMain.access$500(JprotobufPreCompileMain.java:42) at com.baidu.jprotobuf.mojo.JprotobufPreCompileMain$1.onEntry(JprotobufPreCompileMain.java:136) ... 14 more

jhunters commented 8 months ago

收到,我分析一下

jhunters commented 8 months ago

npe是因为生成的Proto内容为null, 用 2.4.22 版本可以测试一下