Skip to content

Instantly share code, notes, and snippets.

@GabriellCosta
Created August 30, 2019 17:12
Show Gist options
  • Save GabriellCosta/5dafb81258196c82d6025252b22e730d to your computer and use it in GitHub Desktop.
Save GabriellCosta/5dafb81258196c82d6025252b22e730d to your computer and use it in GitHub Desktop.
New Android Module
//The basic configuration for your module build.gradle here
//change {YOUR_PACKAGE_NAME_HERE} with the your package name, DO NOT REMOVE .moduleName
<?xml version="1.0" encoding="utf-8"?>
<manifest package="{YOUR_PACKAGE_NAME_HERE}.moduleName"/>
//The basic configuration for your module build.gradle here
apply plugin: "com.android.library"
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
#!/bin/bash
BASEDIR=$(dirname "$0")
echo "module name"
read moduleName
echo "Where module is located?"
read moduleLocation
mkdir -p $moduleLocation/$moduleName
#Create build.gradle file in module
cp $BASEDIR/build.gradle $moduleLocation/$moduleName/build.gradle
#Create base src folder in module
mkdir -p $moduleLocation/$moduleName/src/main/kotlin
#Create a AndroidManifest in module
cp $BASEDIR/AndroidManifest.xml $moduleLocation/$moduleName/src/main/AndroidManifest.xml
#Add the given module name to package name in androidManifest
sed -i "s/moduleName/$moduleLocation.$moduleName/" $moduleLocation/$moduleName/src/main/AndroidManifest.xml
#Create .gitignore file in module
cp $BASEDIR/.gitignore $moduleLocation/$moduleName/.gitignore
echo "add :$moduleLocation:$moduleName to settings.gradle"
@GabriellCosta
Copy link
Author

Put all this files inside a folder, than use moduleMaker.sh

In my project they are located in Android_Project/tools/moduleMaker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment