GithubHelp home page GithubHelp logo

morristech / cexec Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brunodles/cexec

0.0 1.0 0.0 61 KB

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

License: MIT License

Groovy 100.00%

cexec's Introduction

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

cexec's People

Contributors

brunodles avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.