HardHat was created to simplify and automate tasks related to Android development with help of ToolBox and Colorify libraries.
Previously had created the same app making a Batch (for Windows) and a Bash (for macOS) scripts to make the task, maintain both of them is a hard task to do, but now with .Net Core can use and share the same code on both Operating Systems.
I don't like repetitive tasks and make a build is one of them... yuck!
The Code is Dark and Full of Errors! Console is your friend ... don't be afraid!
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
What things do you need to install?
- Java
- Android SDK
- Gradle
- Git
- Gulp
- Node.js (with NPM)
- SonarQube
- SonarScanner
- Sigcheck (only on Windows)
- .Net Core (optional)
It's recommended install it using a Package Manager.
OS | Instructions |
---|---|
win | Chocolatey |
mac | Brew and SDK Man |
Follow these steps to install on your local machine
Clone HardHat from GitHub on recommended path. Using this command on terminal:
OS | Command |
---|---|
win | git clone -b win https://github.com/deinsoftware/hardhat.git "D:\Applications\HardHat" |
mac | git clone -b mac https://github.com/deinsoftware/hardhat.git ~/Applications/HardHat/ |
Environment variables are, in short, variables that describe the environment in which programs run in.
Please verify that you have been configured all correctly. Paths in descriptions are examples (recommended) but use your own paths.
var | description |
---|---|
ANDROID_SDK_ROOT |
C:\Android\android-sdk |
ANDROID_HOME |
%ANDROID_SDK_ROOT% |
ANDROID_NDK_HOME |
%ANDROID_SDK_ROOT%\ndk-bundle |
ANDROID_BT_VERSION |
28.0.3 |
ANDROID_PROPERTIES |
D:\Applications\Android\Properties |
CHOCO_HOME |
C:\ProgramData\chocolatey |
CODE_HOME |
C:\Program Files\Microsoft VS Code |
GIT_HOME |
C:\Program Files\Git |
GRADLE_HOME |
%CHOCO_HOME% |
LFS_HOME |
C:\Program Files\Git LFS |
JAVA_HOME |
C:\Program Files\Java\jdk1.8.0_221 |
MYSQL_HOME |
C:\tools\mysql\mysql-5.7.18-winx64 |
NPM_HOME |
C:\Program Files\nodejs |
VPN_HOME |
C:\Program Files (x86)\CheckPoint\Endpoint Connect |
SIGCHECK_HOME |
%CHOCO_HOME% |
SONAR_QUBE_HOME |
D:\Applications\Sonar\Qube |
SONAR_SCANNER_HOME |
%CHOCO_HOME%\lib\sonarqube-scanner.portable\tools\sonar-scanner-3.3.0.1492-windows |
TASK_PROJECT |
D:\Applications\Task |
PATH |
%ANDROID_SDK_ROOT%\build-tools\%ANDROID_BT_VERSION%; %ANDROID_SDK_ROOT%\platform-tools; %ANDROID_SDK_ROOT%\platform-tools\bin; %ANDROID_SDK_ROOT%\tools; %CODE_HOME%\bin; %GIT_HOME%\cmd; %GRADLE_HOME%\bin; %JAVA_HOME%\bin; %LFS_HOME%\bin; %MYSQL_HOME%\bin; %NPM_HOME%; %SIGCHECK_HOME%\bin; %SONAR_QUBE_HOME%\bin\windows-x86-64; %SONAR_SCANNER_HOME%\bin; C:\ProgramData\Oracle\Java\javapath; |
On Windows need replace ANDROID_BT_VERSION
manually with your Android SDK Build Tool version (recommended use the last one).
Where are environment variables? In the System Properties window, click on the Advanced tab, then click the Environment Variables button near the bottom of that tab. In the Environment Variables window, highlight the Path variable in the "System variables" section and click the Edit button.
export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"
export ANDROID_HOME="$ANDROID_SDK_ROOT"
export ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk-bundle"
export ANDROID_BT_VERSION="$(ls -tr $ANDROID_SDK_ROOT/build-tools | sort | tail -1)"
export ANDROID_PROPERTIES="~/Applications/Android/Properties"
export GIT_HOME="/usr/local/bin/git"
export GRADLE_HOME="/usr/local/bin/gradle"
export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
export POSTGRESQL_HOME="/usr/local/opt/postgresql"
export SONAR_QUBE_HOME="~/Applications/Sonar/Qube"
export SONAR_SCANNER_HOME="~/Applications/Sonar/Scanner"
export TASK_PROJECT="~/Applications/Task"
export PATH="/opt/local/bin:/opt/local/sbin:/usr/local/sbin:$PATH"
export PATH="$ANDROID_SDK_ROOT/bin:$PATH"
export PATH="$ANDROID_SDK_ROOT/build-tools/$ANDROID_BT_VERSION:$PATH"
export PATH="$ANDROID_SDK_ROOT/platform-tools:$PATH"
export PATH="$ANDROID_SDK_ROOT/tools:$PATH"
export PATH="$ANDROID_NDK_HOME/:$PATH"
export PATH="$SONAR_QUBE_HOME/bin/macosx-universal-64:$PATH"
export PATH="$SONAR_SCANNER_HOME/bin:$PATH"
export PATH="$POSTGRESQL_HOME/bin:$PATH"
export LDFLAGS="-L$POSTGRESQL_HOME/lib"
export CPPFLAGS="-I$POSTGRESQL_HOME/include"
alias hh="sh ~/Applications/HardHat/mac.sh"
alias x="exit"
alias sb="source ~/.bash_profile"
On macOS ANDROID_BT_VERSION
automatically take the last Android SDK Build Tool version. But you can modify it and choose the version that you want. Skip GRADLE_HOME
and JAVA_HOME
if you install these libraries with SDKMan.
With HardHat alias, you can open it the application directly from a terminal window using the command hh
and RETURN key.
Where are environment variables? First, one thing to recognize about OS X is that it is built on Unix. This is where the .bash_profile comes in. When you start the Terminal app in OS X you get a bash shell by default. The bash shell comes from Unix and when it loads it runs the .bash_profile script. You can modify this script for your user to change your settings. This file is located at:
~/.bash_profile
Highly recommend auto-close option in combination with exit alias. It can be a useful combination to finish and close those unused terminals. Even to exit HardHat and close automatically his terminal window.
Recommended terminal configurations on macOS? Open a terminal window, go to 'Preference > Profiles. Auto close terminal on exit: Inside 'Shell' tab, select "Close if the shell exited cleanly" on "When the shell exits" option. Enable Numpad keys: Inside 'Advance' tab, deselect (turn off) "Allow VT100 application keypad mode" option.
Keep calm, you are almost done. Review these final steps and enjoy life, no more tedious and repetitive tasks stealing your precious time.
macOS users need add execute permission over some files. Open a terminal on installation path ~/Applications/HardHat/
recommended and run this commands:
chmod +x mac.sh
chmod +x mac.command
chmod +x cmd.sh
chmod +x HardHat
In order to run HardHat open a terminal and run this command:
OS | Path | Command |
---|---|---|
win | "D:\Applications\HardHat" |
win.bat |
mac | ~/Applications/HardHat/ |
sh mac.sh |
It's not mandatory but it's highly recommend create and Start Menu icon. This instructions only works with recommended path.
Use this commands on terminal (as Admin) to add an icon on your start menu:
:: Make Dir
md "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Android"
:: Copy Shortcut
cd /d "D:\Applications\HardHat\"
xcopy "HardHat.lnk" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Android"
Open star menu and over the Android section you will can see the link. Remember mark with 'pin to start' option if you are using Win10.
Copy the icon.png
content on the Clipboard. One way to do this is to open the picture in Preview, choose Edit > Select All
, then choose Edit > Copy
or press Command-C
.
Select mac.command
file, then choose File > Get Info
. At the top of the Info window, click the picture of the icon to select it, then choose Edit > Paste
or press Command-V
.
Select mac.command
file, then choose File > Make Alias
or press Command-L
name it as Hard Hat (with blank space between).
Just drag and drop Hard Hat (alias shortcut) to your Dock or Desktop.
Choose the desired letter combination and let HardHat work for you.
combination | action |
---|---|
p | Select a project inside path.dir/bsn/prd path (see Setup > Path Variables section) that starts with flt folder name. This project required to have an android.prj folder inside. |
pf | Select an APK file generated inside selected project on android.bld path with android.ext extension name (see Setup > Android Variables section). |
po | Open selected project in File Explorer. |
po-b | Open Android build path from selected project in File Explorer. |
pe | Open selected project on Editor. (see Usage > Configuration > Other Variable section). |
pi | Install selected file on an Android device. |
pp | Show path and full path about selected file. Copy this paths to clipboard. |
pv | Show full information, values, signature and hash about selected file. |
combination | action | path |
---|---|---|
pe>a | Android Studio. * | project/android |
pe>c | Visual Studio Code. | project |
pe>s | Sublime Text 3. | project |
pe>w | Web Storm. * | project |
pe>x | Xcode | project/ios |
* Requires enable Tools -> Create Command-line Launcher
and works only for Linux / macOS.
combination | action |
---|---|
pp>p | Copy project path to clipboard. |
pp>f | Copy file path to clipboard. |
pp>m | Copy mapping file path to clipboard. |
pp>d | Duplicate and rename selected file. |
pp>c | Compress selected file. |
combination | action |
---|---|
g | Show current GIT branch. |
gd | Discard files. Launch reset command over selected project. |
gp | Pull files. Launch pull command over selected project. |
gc | Clean files. Launch clean command over selected project and delete unversioned files over selected project. |
gd+p | Discard and Pull files over selected project. |
gr+p | Clean and Pull files over selected project. |
go | Discard, Clean and Pull (x2) files over selected project. |
combination | action |
---|---|
t | Task paths, Server and Log configuration. |
tw | Launch gulp watch command over selected project to TASK_PROJECT . |
tm | Launch gulp make command over selected project to TASK_PROJECT . |
to | Make a copy of project files (with an additional backup) and launch gulp obfuscate command over selected project to TASK_PROJECT . Lite type by default. |
to-l | Launch gulp obfuscate --type lite command on selected files. |
to-c | Launch gulp obfuscate --type complete command on all JS and CSS files. |
tr | Revert original files to selected project. |
tt | Launch gulp test command over selected project to TASK_PROJECT . Start server according to previous configuration. |
ts | Launch gulp server command over selected project to TASK_PROJECT . Start server according to previous configuration. |
tk | Run kill gulp command. |
tl | Launch gulp log command over selected project to TASK_PROJECT . |
See Environment Variables section for TASK_PROJECT
configuration.
combination | action |
---|---|
t>pw | Web Server path with configurations. |
t>pl | Log path with configurations. |
t>pe | Extension name for configurations. |
combination | action |
---|---|
t>si | Internal Path inside server configuration. |
t>sc | Configuration file with web server configuration. |
t>sf | Flavor. |
t>sn | Number. |
t>ss | Sync Browser on save. |
t>sp | Open shortcut in browser at start. |
combination | option | value |
---|---|---|
t>f:d | Flavor | dev |
t>f:q | Flavor | qa |
t>f:r | Flavor | drc |
t>f:m | Flavor | mnto |
t>f:v | Flavor | vsrv |
t>f:p | Flavor | prod |
t>n:1 | Number | 1 |
t>n:2 | Number | 2 |
t>n:3 | Number | 3 |
t>n:4 | Number | 4 |
t>n:5 | Number | 5 |
t>n:8 | Number | 8 |
t>n:8 | Number | 9 |
t>n:8 | Number | 10 |
t>n:8 | Number | 11 |
combination | action |
---|---|
t>ts | Sync Browser on save. |
t>tc | Coverage Path inside server configuration. |
combination | action |
---|---|
b | Configure your build type, flavor and dimensions. |
b>t | Type shortcut inside build configuration. This value can be empty. |
b>d | Dimension shortcut inside build configuration. This value can be empty. |
b>f | Flavor shortcut inside build configuration. This value can be empty. |
b>m | Mode shortcut inside build configuration. This value can be empty. |
bi | Install NPM packages configured on packages.json. |
bp | Copy pre-configured files inside ANDROID_PROPERTIES (see Environment Variables section) folder and copy inside android.prj folder in selected project (see Setup > Android Variables section). |
bc | Make clean project with gradle command line. |
bc-c | Make cleanBuildCache project with gradle command line. |
bg | Make build project with gradle command line. |
If you have some pre-configured files to be copied to the project path, add it on the ANDROID_PROPERTIES
path (see Environment Variables section) inside a Business folder. Files like:
- local.properties
- gradle.properties
- keystore/development.properties
- keystore/production.properties
combination | option | value |
---|---|---|
b>t:a | Type | assemble |
b>t:b | Type | bundle |
b>f:d | Flavor | dev |
b>f:q | Flavor | qa |
b>f:r | Flavor | drc |
b>f:m | Flavor | mnto |
b>f:v | Flavor | vsrv |
b>f:p | Flavor | prod |
b>m:d | Mode | Debug |
b>m:s | Mode | Stag |
b>m:r | Mode | Release |
combination | action |
---|---|
s | Select and show Sonar configuration. |
s>p | Protocol shortcut inside server configuration. |
s>s | Server shortcut inside server configuration. |
s>sd | Domain shortcut inside server configuration. |
s>sp | Port shortcut inside server configuration. |
s>i | Internal Path shortcut inside server configuration. |
sq | Starts sonar server over SONAR_QUBE_HOME (see Environment Variables section) |
ss | Launch sonar-scanner over SONAR_SCANNER_HOME (see Environment Variables section) inside selected project or his internal path. |
sb | Open sonar configuration on browser. |
combination | action |
---|---|
ad | Show device/emulator list. |
ar | Kill and Restart ADB server. |
ad | Make ADB launch logcat. |
aw | Make a ADB device dis/connection over Wifi. |
aw>i | IP shortcut inside wireless configuration. |
aw>p | Port shortcut inside wireless configuration. |
aw>c | Connect IP shortcut inside wireless configuration. |
as | Show device via ADB. |
combination | action |
---|---|
c | Configuration. |
i | Show information about commands version. |
e | Show information about environmental variables. |
x | Exit application, save progress and close terminal window. |
! | Repeat previous option. |
Choose c Configuration option on main menu and set the values.
combination | action |
---|---|
md | Development path |
mw | Choose workspace folder inside development path. |
mp | Projects folder name inside workspace folder path. |
mf | Filter name for project listing. |
combination | action |
---|---|
ap | Android folder path inside project |
ab | Build folder path inside android project. |
ae | Extension name for android application. |
ac | Hybrid folder to be processed with Tasks (Uglify & Minify). |
af | Filter extension name for files to be processed. |
combination | action |
---|---|
e | Command to open editor. |
v | VPN Site Name (only for Windows). |
t | Theme chooser. |
l | Enable or disable log on exceptions. |
Highly recommend this file and directory structure:
Developer
├── Workspace1
│ └── Projects
│ ├── _devBranch_1
│ │ ├── android
│ │ ├── ios
│ │ └── web
│ ├── _devBranch_2
│ │ ├── android
│ │ ├── ios
│ │ └── web
│ ├── _devBranch_3
│ │ └── ...
│ ├── _devBranch_n
│ │ └── ...
│ └── _distProject
│ ├── android
│ ├── ios
│ └── web
├── Workspace2
│ └── ...
├── WorkspaceN
│ └── ...
│
Applications
├── Android
│ ├── Gradle
│ ├── Keystore
│ │ ├── Workspace1
│ │ │ ├── dev.jks
│ │ │ └── prd.jks
│ │ ├── Workspace1_Flavor1
│ │ │ └── ...
│ │ ├── Workspace1_Flavor2
│ │ │ └── ...
│ │ ├── Workspace2
│ │ │ └── ...
│ │ └── WorkspaceN
│ │ └── ...
│ ├── PlayStore
│ ├── SDK
│ └── Properties
│ ├── Workspace1
│ │ ├── gradle.properties
│ │ ├── local.properties
| │ └── Keystore
│ │ ├── development.properties
│ │ └── production.properties
│ ├── Workspace1_Flavor1
│ │ └── ...
│ ├── Workspace1_Flavor2
│ │ └── ...
│ ├── Workspace2
│ │ └── ...
│ └── WorkspaceN
│ └── ...
├── Task
├── HardHat
└── Sonar
├── Qube
└── Scanner
- .Net Core - ASP.NET Core is a free and open-source web framework, and the next generation of ASP.NET, developed by Microsoft and the community.
- VS Code - Code editing redefined.
- SonarQube - Continuous code quality.
Please read CONTRIBUTING for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the HardHat on GitHub.
- Camilo Martinez [Equiman]
See also the list of contributors who participated in this project.
If this project help you reduce time to develop, you can give me a cup of coffee.
No sponsors yet! Will you be the first?
This project is licensed under the MIT License - see the LICENSE file for details.
- StackOverflow: The largest online community for programmers.
- XKCD: A web comic of romance, sarcasm, math and language... for making his font available.