gradle-gitdroid


Source link: https://github.com/lodlock/gradle-gitdroid

Gradle GitDroid (gradle-gitdroid)

This gradle plugin is designed for allowing Android dependencies using git. This allows you to use any Android library from a git repo based on commit or branch.

This project is still in development

What this plugin does

  • Looks for dependencies that have a git extension
  • Clone/pull from public or private repo
  • Replace repo project library versions
  • Compile git project
  • Upload compiled git project and all it's dependencies to local maven repo

Usage

To use this plugin: ####1. Add to project Gradle version < 2.1 classpath group: 'com.testfunction', name: 'gradle-gitdroid', version: '0.0.3' to your root build.gradle file in the buildscript dependencies section.

 buildscript {

repositories {

 jcenter()

}

dependencies {

 classpath 'com.android.tools.build:gradle:2.0.0-alpha3'

 classpath group: 'com.testfunction', name: 'gradle-gitdroid', version: '0.0.3'

}
  
}

In your module's build.gradle file add apply plugin: 'gradle-gitdroid'

Gradle version >= 2.1 In your module's build.gradle file add plugin:

plugins {

id "com.testfunction.gradle-gitdroid" version "0.0.3" 
}

####2. Configure Gradle GitDroid in your module's build.gradle file with the gitDroid closure:

gitDroid {

  workingDir = "C:/tmp/${
rootProject.name
}
/gitDroid"
  localRepo = getRepositories().mavenLocal().url
  automaticResolve = false 
}

If automaticResolve is set to true then every time the project is evaluated this plugin will look for git dependencies and if necessary compile them.

####3. Add a git extension to a dependency

compile (group: 'com.testfunction',

name:'lumberjill',

version:'HEAD',

ext: 'aar',

transitive: true ).ext {

  git = [

 repo : 'https://github.com/lodlock/LumberJill.git',

 remoteModule: 'lumberjill'
  ] 
}

Gradle GitDroid properties

#####Valid gitDroid properties:

Property Expects Default Description
automaticResolve boolean false Should Gradle GitDroid automatically handle git dependencies
buildModule boolean true Should run build commands against the supplied module or against base project
deleteSourceOnGitFailure boolean true If git command fails delete the current git source
localRepo URI repositories.mavenLocal().url Location to upload to. Should be included in dependency repositories
replaceValues Map<String, ArrayList> null Search and replace strings in git dependency build.gradle file
replaceValuesRegex Map<String, String> null Search and replace all matching strings in git dependency build.gradle file
test test closure See gitDroid.test
workingDir Directory rootProject + "git-tmp" The directory to clone/pull contents into to work with

#####Valid gitDroid.test properties: (Most do not need to be messed with)

Property Expects Default Description
filterConfig boolean true Filter dependencies based on config state
filterDependenciesByExternalModule boolean true Filter dependencies restrict to ExternalModuleDependency
forceRunInit boolean false Force init to run every time. (Slow)
pathLengthDieOnFailure boolean true On Windows machines die out if potential file path length would be too long
regexp regexp closure See gitDroid.test.regexp
useLifecycle boolean false Log archive task to lifecycle instead of debug

#####Valid gitDroid.test.regexp properties:

Property Expects Default Description
flags String "g" g global, i case insensitive, m multiline, s singleline
byLine boolean false Search one line at a time
encoding String "UTF-8" Encoding to use for search / replace

#####Full Gradle GitDroid DSL:

gitDroid {

  automaticResolve = false
  buildModule = true
  deleteSourceOnGitFailure = true
  localRepo = repositories.mavenLocal().url
  //optional replace all android build tools alpha1 with alpha3
  replaceValues = [ "com.android.tools.build:gradle:2.0.0-alpha3" : [

"com.android.tools.build:gradle:2.0.0-alpha1"

]
  ]
  //optional replace all android build tool versions with alpha3
  replaceValuesRegex = [ "com.android.tools.build:gradle:2.0.0-alpha3" :

 "(?<=['|\"])com\\.android\\.tools\\.build:gradle:.+?(?=['|\"])"
  ]
  test {

filterConfig = true

filterDependenciesByExternalModule = true

forceRunInit = false

pathLengthDieOnFailure = true

regexp {

 flags = "g"

 byLine = false

 encoding = "UTF-8"

}

useLifecycle = false
  
}

  workingDir = "C:/tmp/${
rootProject.name
}
/gitDroid" 
}

Declaring dependencies

Declare dependencies and attach git extension. It is recommended to include aar extension and setting transitive to true

compile (group: 'com.testfunction',

name:'lumberjill',

version:'HEAD',

ext: 'aar',

transitive: true ).ext {

  git = [

 repo : 'https://github.com/lodlock/LumberJill.git',

 keepUpdated : true,

 remoteModule: 'lumberjill',

 keepSource : true
  ] 
}

OR

compile ('com.testfunction:lumberjill:HEAD@aar') {

transitive = true 
}
.ext {

  git = [

 repo : 'https://github.com/lodlock/LumberJill.git',

 keepUpdated : true,

 remoteModule: 'lumberjill',

 keepSource : true
  ] 
}

Dependency version number can be anything

Git properties

Bold entries are required

Property Expects Default Description
buildJavaDocs boolean true Include javadoc in local repo
buildSource boolean true Include code source in local repo
credentials Map sshKey or username and password
forceBuild boolean false Used internally to force a build of the dependency
keepSource boolean false Keep the cloned source code after completion
keepUpdated boolean false This dependency should regularly check for newer versions
ref String Commit, Tag, or Branch reference desired
refType Enum Automatic Can be Automatic, Branch, Commit, or Tag
remoteModule String The module desired in the project
remoteModules ArrayList null Multiple desired modules from the project
repo String The repository to clone/pull from
uploadDependencies boolean true Upload a copy of all of the git project dependencies

Gradle GitDroid dependency git DSL:

git = [
  buildJavaDocs : true,
  buildSource : true,
  credentials : [ sshKey:'path/to/ssh/key', username:passedUserName, password:passedPassword ],
  forceBuild : false,
  keepSource : false,
  keepUpdated : false,
  ref : 'ab0886261d09c867c012647fbccb9342082c7880', //branch, commit, or tag
  refType : 'Automatic',
  remoteModule : 'lumberjill', //the directory name of the module desired
  remoteModules : ['module1', 'module2'],
  repo : 'https://github.com/lodlock/LumberJill.git', //the url of the repo
  uploadDependencies : true //also upload a copy of dependencies to the gitDroid.localRepo ]

Basic Example

rootProject build.gradle

 buildscript {

repositories {

 jcenter()

}

dependencies {

 classpath 'com.android.tools.build:gradle:2.0.0-alpha3'

}
  
}

 allprojects {

buildDir = "C:/tmp/${
rootProject.name
}
/${
project.name
}
" //short buildDir to avoid Windows path limit

repositories {

 jcenter()

 maven {

  url mavenLocal().url

 
}

}
  
}

 task clean(type: Delete) {

delete rootProject.buildDir  
}
 

module build.gradle

plugins {

id "com.testfunction.gradle-gitdroid" version "0.0.3" 
}
  apply plugin: 'com.android.application'  android {

  compileSdkVersion 23
  buildToolsVersion "23.0.2"

defaultConfig {

applicationId "com.testfunction.testgradleplugin"

minSdkVersion 16

targetSdkVersion 23

versionCode 1

versionName "1.0"

generatedDensities = []
  
}

  buildTypes {

release {

 minifyEnabled false

 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

}

  
}
 
}
  dependencies {

  compile fileTree(dir: 'libs', include: ['*.jar'])
  testCompile 'junit:junit:4.12'

 compile 'com.android.support:appcompat-v7:23.1.1'

 compile (group: 'com.testfunction',

 name:'lumberjill',

 version:'HEAD',

 ext: 'aar',

 transitive: true
  ).ext {

git = [

  repo : 'https://github.com/lodlock/LumberJill.git',

  buildJavaDocs : true,

  keepUpdated : true,

  remoteModule: 'lumberjill',

  keepSource : true

]
  
}

compile ('com.github.michaldrabik:tapbarmenu:gitDroid@aar') {

transitive = true
  
}
.ext {

git = [

  repo : 'https://github.com/michaldrabik/TapBarMenu.git',

  ref : 'd17b48f167f3d121c00dfb5ad7fd7f39b8fc18d2',

  remoteModule: 'library',

  keepSource: true

]
  
}

compile ("com.github.DeveloperPaul123:FilePickerLibrary:gitDroid@aar") {

transitive = true
  
}
.ext {

git = [

  repo: 'https://github.com/DeveloperPaul123/FilePickerLibrary.git',

  ref : '02782b398c6ab590947a3beba6a0d2545c4caf4d',

  remoteModule: 'FPlib',

  keepSource: true

]
  
}
 
}
  gitDroid {

  workingDir = "C:/tmp/${
rootProject.name
}
/gitDroid"
  localRepo = getRepositories().mavenLocal().url
  automaticResolve = false
  test {

pathLengthDieOnFailure = false
  
}

  replaceValuesRegex = [

 "com.android.tools.build:gradle:2.0.0-alpha3" :

 "(?<=['|\"])com\\.android\\.tools\\.build:gradle:.+?(?=['|\"])"
  ] 
}

Notes

If you are working in Windows you should set a short workingDir path to help avoid reaching the Windows path limit.

Resources

Record moments of your life or choose exist video or gif animation as watch face for your Android Wear device.

A ConstraintLayout group that allows for simple staggered animations.

Gencycler is a compile time annotation processor, that writes the RecyclerView adapter code for you.

A simple easy-to-use service manager for Android. You can use this library without even declaration of your service in manifest.

Built over JobIntentService so it is compatible with all OS versions including Android O. ServiceManager can be used from any place with context only.

This python code is used to generate the drawable icons for various screen sizes.

This tool allows you to tweak your layout in real time just like inspect element in the browser.

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