File tree Expand file tree Collapse file tree
AndroidAnnotations/androidannotations/src/main/java/org/androidannotations Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919import static org .androidannotations .helper .CanonicalNameConstants .PRODUCE ;
2020import static org .androidannotations .helper .CanonicalNameConstants .SUBSCRIBE ;
2121import static org .androidannotations .helper .ModelConstants .TRACE_OPTION ;
22+ import static org .androidannotations .rclass .ProjectRClassFinder .RESOURCE_PACKAGE_NAME_OPTION ;
2223
2324import java .io .IOException ;
2425import java .io .PrintWriter ;
264265import org .androidannotations .validation .rest .RestValidator ;
265266
266267@ SupportedSourceVersion (SourceVersion .RELEASE_6 )
267- @ SupportedOptions ({ TRACE_OPTION , ANDROID_MANIFEST_FILE_OPTION })
268+ @ SupportedOptions ({ TRACE_OPTION , ANDROID_MANIFEST_FILE_OPTION , RESOURCE_PACKAGE_NAME_OPTION })
268269public class AndroidAnnotationProcessor extends AbstractProcessor {
269270
270271 private final TimeStats timeStats = new TimeStats ();
Original file line number Diff line number Diff line change 2626
2727public class ProjectRClassFinder {
2828
29+ public static final String RESOURCE_PACKAGE_NAME_OPTION = "resourcePackageName" ;
30+
2931 private ProcessingEnvironment processingEnv ;
3032
3133 public ProjectRClassFinder (ProcessingEnvironment processingEnv ) {
@@ -35,7 +37,7 @@ public ProjectRClassFinder(ProcessingEnvironment processingEnv) {
3537 public Option <IRClass > find (AndroidManifest manifest ) {
3638
3739 Elements elementUtils = processingEnv .getElementUtils ();
38- String rClass = manifest . getApplicationPackage ( ) + ".R" ;
40+ String rClass = getRClassPackageName ( manifest ) + ".R" ;
3941 TypeElement rType = elementUtils .getTypeElement (rClass );
4042
4143 if (rType == null ) {
@@ -46,4 +48,12 @@ public Option<IRClass> find(AndroidManifest manifest) {
4648
4749 return Option .<IRClass > of (new RClass (rType ));
4850 }
51+
52+ public String getRClassPackageName (AndroidManifest manifest ) {
53+ if (processingEnv .getOptions ().containsKey (RESOURCE_PACKAGE_NAME_OPTION )) {
54+ return processingEnv .getOptions ().get (RESOURCE_PACKAGE_NAME_OPTION );
55+ } else {
56+ return manifest .getApplicationPackage ();
57+ }
58+ }
4959}
You can’t perform that action at this time.
0 commit comments