1. Introduction
Gradle plugin for generating .gitignore files using gitignore.io.
1.1. Features
-
Templates supplied by gitignore.io, so they are always up-to-date.
-
Automatic generation of the gitignore file based on the following project facets:
-
Programming Languages
-
Development Environment
-
Operating System
-
-
Generation of the gitignore file is completely configurable.
-
Support for pulling gitignore templates from locations other than gitignore.io.
For detailed information on getting started with this plugin and how to configure specific tasks, please refer to the documentation below.
2. Getting Started
The plugin can be applied with the plugin DSL or the buildscript syntax.
2.2. Buildscript Syntax
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.github.gregwhitaker:gradle-gitignore-plugin:2.2.0"
}
}
apply plugin: "com.github.gregwhitaker.gitignore"
No other configuration is necessary at this point. The plugin will auto-detect the appropriate gitignore facets
and automatically generate a .gitgnore
file.
If you wish to override any of the configuration options, you can
through the gitignore
extension detailed below.
3. Tasks
The plugin applies default tasks, which can be executed from the Gradle command line:
Task Name | Type | Usage | Description |
---|---|---|---|
Default |
|
Creates a .gitignore file for the project. |
|
Default |
|
Deletes the .gitignore file for the project. |
|
Default |
|
Lists all of the supported project facets. |
|
Default |
|
Prints the .gitignore file for the project. |
4. Create GitIgnore
There are a number of options for creating .gitignore
files with this plugin.
4.1. Simple Configuration
When using the plugin with simple configuration there is no need for a configuration block. Simply apply the plugin, as detailed above, and a .gitignore file will be automatically generated.
4.2. Advanced Configuration
The plugin uses "facets" to describe what rules to add to the .gitignore file. These facets correspond to the technology selections on the gitignore.io website.
When using advanced configuration the plugin will continue to automatically discover project facets, but you are also
able to add your own facets to the generation process by using the facets
configuration parameter.
gitignore {
facets = [
'linux',
'eclipse'
]
}
4.3. Manual Configuration
Automatic discovery of project facets can be disabled allowing you to configure all facets that will be used for generation of the .gitignore file by calling the noAutoDetect()
configuration method.
gitignore {
noAutoDetect()
facets = [
'java',
'idea',
'gradle'
]
}
4.4. External Configuration
In the event that you do not want to use gitignore.io to generate the .gitignore file you can insert any hosted document
using the url
configuration parameter.
gitignore {
url = 'https://raw.githubusercontent.com/gregwhitaker/gradle-gitignore-plugin/master/src/templates/template-gitignore?token=AFw8vOxtg_dhIKrIKO1-aKjhpcvuxB6Kks5YhFcIwA%3D%3D'
}