Custom Executor


Source link: https://github.com/brunodles/cexec

Cexec Task - Custom Execute

This is a simple executor, sometimes the default exec task does not work as expected.

I wrote this simple task just to trigger some terminal commands from a gradle task. It may looks strange if you only know the basic gradle commands.

Try to imagine the following situations:

  • Run something before install the app on android. Like the development backEnd App, mocked Api or anything like thad. So we can use a task to do that for us.
  • Send a command to adb. I use it to clean app data.

I use the cexec task to do those tasks.

How to use

Add JitPack in your build.gradle.

buildscript {

  repositories {

maven {
 url "https://jitpack.io" 
}

  
}

  dependencies {

classpath 'com.github.brunodles:cexec:-SNAPSHOT'
  
}
 
}

You can add this just before use, in your all level projectPath/app/build.gradle. Or in your root level projectPath/build.gradle. Suggested if you plan to use it in more than one module.

Create a Task

To Create a new task you just need to edit the code bellow.

task name(type: com.github.brunodles.cexec.Cexec) {

  description "<say something>" // <- this will appear when you list tasks for your project
  command "<command>" // <- the terminal command you want to run
  printCommand <true|false> // <- true if you want to see the command printed before it's execution. Useful if you have some complex command with variables. 
}

Samples

This code just calls the ifconfig, to get information about the network

task ifconfig(type: com.github.brunodles.cexec.Cexec) {

  description "Just print something on screen"
  command "ifconfig"
  printCommand false 
}

This code calls adb to clean the app data.

android.applicationVariants.all {
 variant ->
  task ("cleanAppData${
variant.name.capitalize()
}
", type:com.github.brunodles.cexec.Cexec) {

description "Clean app data on device"

command "adb shell pm clear ${
variant.applicationId
}
"
  
}
 
}

Shortening task type

If you have multiple tasks extending Cexec, you can do as follows.

In your build.gradle add the import line, before the first task, it can also be on the top of the file. Now yu can put only Cexec for the task type.

import com.github.brunodles.cexec.Cexec task ifconfig(type: Cexec) {

Contributing

You can contribute but showing your custom tasks, or submitting a new task. Issues are welcome, create one and we will discourse about it. If you saw any error, please reports, it will be a great help.

Licence

You can use any code you found here, some of then I found on the internet too.

I'm using the MIT Licence, take a look on Licence.

If you're using this plugin, please give me some credits too.

Sources

Gradle

Ip Inject

This one have many sources, I don't remember where I found it at first, it was on 2014. Now we have many articles about it, so I'll link then.

JitPack

Resources

A simple API Wrapper of OpenWeatherMap.org for Android. It uses Retrofit 2.0 and currently supports 5-Day Forecasts and Current Forecast for any Lat/Lon given location.

Xmpp based client for Android.

A material banner component.

Android library to realize the various states and transitions in a ProgressBar.

A log library focused on high extensibility.

A group of toggle buttons, supports multiple / single selection.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes