https://github.com/kdabir/mksrc
Gradle plugin to create source directories and autogenerate settings.gradle file
https://github.com/kdabir/mksrc
create dirs gradle-plugin source
Last synced: about 1 year ago
JSON representation
Gradle plugin to create source directories and autogenerate settings.gradle file
- Host: GitHub
- URL: https://github.com/kdabir/mksrc
- Owner: kdabir
- License: mit
- Created: 2018-04-17T03:53:05.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-06-28T23:14:35.000Z (about 5 years ago)
- Last Synced: 2025-02-13T21:50:06.312Z (over 1 year ago)
- Topics: create, dirs, gradle-plugin, source
- Language: Groovy
- Homepage: https://plugins.gradle.org/plugin/com.kdabir.mksrc
- Size: 233 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Make Source Dirs Gradle Plugin
[](https://plugins.gradle.org/plugin/com.kdabir.mksrc)
1. Creates source directory structure as per the applied plugins (`java`, `groovy`, `kotlin`, `scala`, `war`) and custom `sourceSet` dirs
2. Automatically generate / updates `settings.gradle` file to include child projects based on convention
## Usage
Apply the plugin to the project
plugins {
id "com.kdabir.mksrc" version "1.1.1"
}
The plugin adds `makeSourceDirs` to the project. Run the following command
$ gradle makeSourceDirs
Based on the plugins applied to project (and configured `sourceSets`), the source dirs will be created
$ tree src
src
├── main
│ ├── java
│ └── resources
└── test
├── java
└── resources
## For multi-project builds
If the top level project doesn't need source dirs, but the subprojects do, then use `apply false` in `plugins` block
and apply the plugin to all `subprojects`. Adding the following snippet in the top level project's `build.gradle`
should work :
```
plugins {
id "com.kdabir.mksrc" version "1.1.1" apply false
}
subprojects {
apply plugin: 'com.kdabir.mksrc'
}
```
## Generating `settings.gradle` File Automatically
In a multi-module project, it is often pain to keep `settings.gradle` in sync with the nested modules/projects structure
(as we need to include sub-projects explicitly). Also, since all files are named `build.gradle`, it is hard to locate
the right build file for the sub-project (in IDEs). This plugin solves both the problems by using simple convention and
then generating/syncing `settings.gradle` file on-demand.
Instead of naming the build files for all sub-projects as `build.gradle`, we keep a `.gradle`
within the `/` dir. The plugin adds `generateSettingsFile` task to the project. This task
updates `settings.gradle` to include all sub projects' `/.gradle` into the build.
Usage:
$ gradle generateSettingsFile
> do commit your existing settings.gradle to version control before calling this task.