Is there an equivalent to precompiled script plugi...
# amper
l
Is there an equivalent to precompiled script plugins in Amper, or imports? I'd like to setup some base configs that I can use as a base for multiple modules, so I have a single place to configure things across a project.
z
👍🏼 1
👍 1
l
Any reason the name "template" was used? I don't have a better suggestion at the moment, but curious if there were other naming candidates. As I'm talking about that, I'm thinking that such a thing should be required to be used. It becomes much easier to create new modules afterwards, without having to do error-prone copy pasting.
a
Regarding naming: We have considered
template
,
mixin
snippet
,
part
and some other terms. Decided that templates describes the purpose the best: it’s is used to create a module with the prefefined configuration. But the resulting configuration could be overridden and fine-tuned. Not sure I understand what you think should be required. Could you elaborate?
l
I mean you wouldn't be able to create a module without defining a project-local template. That's a way to force preparing for reusability. Does it make more sense? I can keep elaborating.
a
That’s an interesting option. I would like to hear more thoughts behind that. What part of configuration should be required to be templated and what shouldn’t? How such approach would look like in different scenarios, such as a single-module project, a project with multiple similar modules and a single specific module (that as an app with multiple libs), KMP projects with dedicated platform-specific app modules. etc
l
The idea is to make it easy to go from a single-module project to a multi-module project, including a multi-apps project, by not treating single-module or single-shared module as special cases. That also means the documentation is the same, regardless of the cardinality/number of modules.
a
Hmm, I’m still not sure how this is connected with requirement to use templates. Could you give a rough example of such a project configuration?
l
I think templates are Amper the analogue to convention plugins in Gradle. These days, I always use convention plugins in Gradle projects, so I have a base config, and I can reuse it across multiple modules. I could not use convention plugins, which was how I started a few years ago, but it led to substantial configuration code duplication, switchin to convention plugins was hard. I wish convention plugins was the only way to setup even a single module (without the ceremony of setting convention plugins, nor buildSrc), so that I would have been ready to have reusable logic. I'd like that beginners never face this struggle with Amper, including myself, since I'm an Amper beginner at the moment. Pratically, that means I'd need to come up with a name for a template, like those:
kmp-lib-private
,
kmp-lib-published
,
android-app
,
wearos-app
,
ios-app
,
desktop-app
,
codegen-module
,
jvm-lib-private
, `android-lib-published`… Those templates, that the IDE could generate or reuse when needed, would use more primitive constructs, and most importantly, it'd be possible to change some configuration throughout all modules. Also, it'd be possible to introduce private templates (that is, designed only to be used in other templates), for example,
kmp-lib
(to be used in both private and published variants),
kotlin-lib-publishing
(to be used in
kmp-lib-published
and `android-lib-published`…), etc.
The idea is to minimize the amount of config code duplication to only what's truly unique to this module, like the dependencies, opt-ins, and maybe other specific things.
a
I think, I’m starting to get the idea. What is your intuition regarding the size/complexity of the project, where such required module templates start to make practical advantage?
l
Starting from 2 modules that should be of the same kind, or whenever your 1-3 modules projects grows and you want to modularize it, or share some parts as an internal, or public library
As soon as you need to change stuff across multiple modules, it becomes super easy because they already share some config that you can edit
I'd be happy to have such a thing even for single-module projects, but many of my projects are at least 2 modules, and some are around 60 or more.
a
I see how it could be advantageous to have a required template in projects where consistent configuration across the modules must be ensured. But that also might be unwanted limitation in projects with multiple modules in unique configurations. In any case, thanks for sharing the idea! I think it’s too early to incorporate it into Amper, but we’ll see if there more such requests in future