What's the best way to streamline the creation of new modules in a Gradle project with IntelliJ?
Every time I create a new Gradle module I have a small todo list before I write any code. Whenever I create a new library module, I do the following after IntelliJ does its normal boilerplate setup.
- Apply the java-library plugin (and often checkerframework).
- Add lombok preprocessors.
- Add dependency
compileOnly 'org.slf4j:slf4j-api:${slf4jVersion}'. - Bump JUnit version.
- Add testing dependencies.
testImplementation 'org.junit.jupiter:junit-jupiter-params:${junitVersion}'testRuntimeOnly 'ch.qos.logback:logback-classic:${logbackVersion}'
- Copy-paste standard config to
src/test/resources/logback-test.xml. - Create empty packages at
src/main/javaandsrc/test/javawith the same name as the group name.
This only takes a few minutes each time, but I have gotten annoyed enough to spend time writing this question in search of better way.
I don't know the best way to begin to approach this. I don't even know if I should be looking for a solution through Gradle or IntelliJ. I have found info about structuring projects, creating templates, custom tasks, custom plugins, etc. I feel this must be a common enough task that there is an established best practice.
I'm not asking for much technical detail about how to implement the solution. I can probably figure it out once I know what kind of solution to use.
You can try to do it in the following way:
File | New | Project | New Project | GradleAdd the needed configuration
File | New Project Setup | Save Project as TemplateCreate a new project using a custom template.
Open your main project and add a new project as module under
File | Project Structure | Modules | + | Import ModuleRepeat the last two steps when adding a new module with a custom setup.