-
Notifications
You must be signed in to change notification settings - Fork 0
Type Definition Libraries
If one provided component depends on members from another, you need to add the latter's JAR as a compile-only dependency of the project that will provide the former. Your provided components might also depend on members you gave to students in your Machine Project's starter code. In that case, you will need to create a JAR for those so that your provided component(s) can compile. I like to create a typedefs IntelliJ project containing all custom types used throughout the project. But since the resulting JAR is never going to be registered as an eMPire provided component—the working version is already given in the starter code—only definitions, not implementations, are necessary. The method signatures must match exactly so that the members expected by provided components' compiled class files are actually there at runtime, but all method bodies can be stubs:
throw new NoSuchMethodError("STUB!");
That will make it very clear if you accidentally loaded the type definition library at runtime.
Plain Java projects cannot have Android library dependencies (e.g. the Android SDK or libraries like Volley), which is a problem if you have logic classes that work with Android types. You can create another type definition library for just the Android classes you need. The fully-qualified names still need to match, e.g. your Context stub needs to go in the android.content package. A lot of Android classes have a lot of members, but you only need to define the ones used by your other components. For some classes, you might only need the type and not any of its methods. I recommend keeping Android-specific type definitions in their own IntelliJ project (I call mine google-typedefs). Your Android type definition library can be a compile-only dependency of your typedefs library and any other Java projects for provided JARs, but Android library projects for provided AARs can depend on just typedefs and the real Android artifacts from artifact repositories. That way, you will be able to use all members of all Android types in your provided AAR projects without worrying about duplicate classes on the compile classpath.