Skip to content

Commit

Permalink
fix: kapt 高版本中不允许在注解驱动器的 init 中生成 class 了. 所以需要各位每个模块都配置一个 @ModuleApp…
Browse files Browse the repository at this point in the history
…Anno 注解
  • Loading branch information
fanqie committed Jul 12, 2024
1 parent fc38de4 commit efd2a1f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ComponentCompiler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies {
implementation 'com.squareup:javapoet:1.13.0'
implementation 'org.apache.commons:commons-lang3:3.14.0'
implementation 'org.apache.commons:commons-collections4:4.4'
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.google.code.gson:gson:2.11.0'
implementation project(':ComponentApi')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import com.xiaojinzi.component.anno.ModuleAppAnno;
Expand Down Expand Up @@ -65,7 +64,7 @@ public synchronized void init(ProcessingEnvironment processingEnvironment) {
centerServiceTypeElement = mElements.getTypeElement(ComponentConstants.CENTERSERVICE_CLASS_NAME);
routerCenterTypeElement = mElements.getTypeElement(ComponentConstants.ROUTERCENTER_CLASS_NAME);
classCacheTypeElement = mElements.getTypeElement(ComponentConstants.CLASSCACHE_CLASS_NAME);
createImpl(true);
// createImpl(true);
}

@Override
Expand Down Expand Up @@ -139,17 +138,23 @@ private void createImpl(boolean isDefault) {
.addMethod(initMapMethod)
.addJavadoc(classJavaDoc)
.build();

if (mFiler == null) {
throw new ProcessException("mFiler is null");
}

try {
JavaFile
JavaFile javaFile = JavaFile
.builder(pkg, typeSpec)
.indent(" ")
.build()
.writeTo(mFiler);
.build();
javaFile.writeTo(mFiler);
} catch (IOException e) {
throw new ProcessException(e);
} catch (Exception e) {
// ignore
}

}

private MethodSpec generateInitMapMethod() {
Expand Down

0 comments on commit efd2a1f

Please sign in to comment.