The problem

I found these problems with componentization

  1. Components can access all Public classes of other components, and the code is not cohesive
  2. Component dependency passing causes API downward incompatibility to crash
  3. API methods are written manually in MarkDown
  4. Modules that depend on each other behave like circular dependencies and cannot compile
  5. I wrote a Gradle pluginModuleExportSolve these problems

Code cohesion

B Module can access any Public class of A Module, which causes the dependency of the two modules, A and B Module, to be very heavy. Android Gradle plugin 3.0.0 after the implementation seems to solve this problem, but in fact, it does not work. It works for Module isolation, but not for class isolation, and there are a lot of risks associated with upgrading Android Gradle3.0.0. I came up with a way to solve this problem by modifying the Android Studio code hint feature so that Android Studio can’t display unexposed classes. It will not affect the original compilation process

Modify the XML file in the. Idea /libraries directory to replace classes.jar with empty.jar

Backwards compatible

Maven library dependency passing will cause methods to be deleted without compiling errors, and NoSuchMethodError will be reported easily

The scheme implementation compares the original abstract syntax tree

The code is derived

Two modules can not rely on directly, access interface needs to be split out of the interface module, which is more troublesome, to achieve a project automatically send two library function

"Groudid: artifactId: 1.0.0"
"Groudid: artifactId - API: 1.0.0"
Copy the code

Groudid :artifactId:1.0.0″ poM file, add artifactId jar as API

Cyclic dependencies are resolved by the API project that all other projects rely on, and the main project automatically adds impL dependencies

Document generation

The Javadoc task specifies that the Java files that need to be exported generate documents to be placed in our document center