Code Monkey home page Code Monkey logo

sputnik's Introduction

Alt Text

Sputnik

What is it?

Sputnik is a multi tool gradle plugin to help with common tedious tasks to do with gradle things.

It can :

  • Generate the 'versionName', 'versionCode' and apk file name for a project.
  • Add relevant proguard file to the application.
  • Perform checkstyle, findbugs, lint and PMD code quality checks during the build process of the application.

Versioning and APK naming

To enable Sputnik to change the versionCode/Name of your project, update your defaultConfig block to add sputnik dot calls for both

sputnik.versionName "1.0"
sputnik.versionCode 1

To give sputnik access to the name of the application so that it can rename the APK file as follows {appName}-{versionName} you must explicitly pass the value in with sputnik.appName(app_name_goes_here).

You can change the format of the outputted APK file with sputnik.apkName('${appName}-${versionName}') Acceptable parameters are :

  • appName
  • projectName
  • flavorName
  • buildType
  • versionName
  • versionCode
  • commitHash

Proguard

Available proguard files can be found at sputnik/resources/proguard or by running the gradle task listProguard to print the various keys for each proguard file that can be used. By default Sputnik will add the projects proguard-rules.pro file, or if it is a library project the proguard-library.pro file will be added. It will also add the standard Android proguard file proguard-android.txt, but the optimized version proguard-android-optimize.txt is also available for your proguarding pleasure.

To add proguard files to your project :

sputnik.proguard {
    include "android-optimize", "android-v7", "android-design"
    exclude "android"
}

The exclude call isn't needed unless there is a file you explicitly want to exclude. e.g. if you want to add the optimized Android proguard file instead of the standard version.

Then all you need to do is enable proguard within your projects buildType

 buildType {
   release {
     minifyEnabled true
     shrinkResources true
   }
 }

You can also delete the default proguardFiles getDefaultProguardFile...call as the proguard files will be applied using Sputnik from now on.

Code quality

Sputnik by default will enable all code quality checks. To disable add the following to your build.gradle

sputnik.enableQuality(false)

How to add it

Sputnik can be added to your project either from Bintray or Gradle's Plugin Portal.

####Gradle Plugin Portal To add Sputnik to a project, update the root build.gradle buildscript to include the following:

buildscript {
  repositories {
    // If you want to download from the Gradle Plugin Portal
    maven { url "https://plugins.gradle.org/m2/" }
    
    // If you want to download from jCenter
    jcenter()
  }
  
  dependencies {
    classpath 'com.tapadoo.android:sputnik:0.8.0'
  }
}

You then need to apply the plugin to the projects build.gradle

apply plugin: 'com.tapadoo.android.sputnik'

And that's it. Happy Sputniking.

Licence

See the LICENSE file for license rights and limitations.

sputnik's People

Contributors

jasonconnery avatar otormaigh 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.