How to use - maxbalan/gradle-custom-init GitHub Wiki

Template List

The plugin can be used to build predefined project templates included in the plugin source, or it can be used for custom defined templates. For a more detailed information on how to use any of the available templates checkout following links:

Using the plugin

So far there are 2 ways to use the plugin

Though the bash script is a more convenient way to use the plugin as it automates most of the manual work, it does not mean you cannot use the plugin directly but in this case you will be required to do a few steps in order to initialize the plugin as it is not available directly from gradle source.

Requirements

Before jumping to any of the possible ways to initialize the plugin make sure you have the following requirements setup:

  • install gradle 2.1+ check gradle installation guide
  • GRADLE_HOME - make sure this environment variable is set and pointing to the right gradle source version

Use a bash script

The bash script is located here Copy the script to your machine and run with the following arguments, make sure to specify all the required parameters, though not all of them are required but in some cases when using some parameters may be dependent on the other, for a more detailed on how to build of a specific template checkout the wiki page of that template, for a complete list checkout available templates list

  • Required arguments:

  • Optional arguments:

    • -s or --project-target - set target directory where the project will be created. Default will be set or the directory where the script is being called from
    • -c or --custom-template - set a custom template source project it. For more details checkout custom-tempalte
    • -d or --custom-template-target - the properties is required if --custom-template implies a nested folder structure, this means that the it's not a direct link to the custom template you want to build. For more details checkout custom-tempalte
    • -l or --library-version-source - set the source to a .propeties file to override default provided properties. Useful when you want to replace predefined library versions
    • -g or --group - set group parameter in case of a gradle project. Default --project-target directory will be used
    • -p or --project-structure - set a project structure to be created when building a project

Use plugin directly

Comparing to the bash script this method requires a few manual steps before you are able to run the plugin.

  1. create a build.gradle file, e.g.:
build.gradle

plugins {
            id 'com.github.maxbalan.gradle-custom-init' version 'PLUGIN_VERSION'
}

Starting from gradle 5+ you won't be able to run build.gradle files without a settings.gradle one, a good practice is to create and empty one in the same directory as build.gradle

In order to check if everything is fine and you can run the task you should run the command in terminal in the same directory as buid.gradle

gradle tasks --all

and in the result you will see a section called Other tasks where custom-init task will be mentioned, as shown below:

Other tasks
-----------
custom-init

After making sure the plugin was loaded without issues you can run the task called custom-init with the following arguments, make sure to specify all the required parameters, though not all of them are required but in some cases when using some parameters may be dependent on the other, for a more detailed on how to build of a specific template checkout the wiki page of that template, for a complete list checkout available templates list

  • Required arguments:

  • Optional arguments:

    • --project-target - set target directory where the project will be created. Default will be set or the directory where the script is being called from
    • --custom-template - set a custom template source project it. For more details checkout custom-tempalte
    • --custom-template-target - the properties is required if --custom-template implies a nested folder structure, this means that the it's not a direct link to the custom template you want to build. For more details checkout custom-tempalte
    • --library-version-source - set the source to a .propeties file to override default provided properties. Useful when you want to replace predefined library versions
    • --group - set group parameter in case of a gradle project. Default --project-target directory will be used
    • --project-structure - set a project structure to be created when building a project