gradle-robojava-plugin


Source link: https://github.com/kageiit/gradle-robojava-plugin

gradle-robojava-plugin

![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-gradle--robojava--plugin-brightgreen.svg?style=flat =18y)

Robojava is a Gradle plugin that allows simple integration of Robolectric into Android Studio. This plugin works by creating a stub java project. This allows extending it with powerful plugins that are compatible with gradle java projects, but not with gradle android projects, like Gradle Cobertura Plugin for example.

Usage

Assuming your project structure is a Multi Project Gradle Build, add the following to your root buildscript's dependencies section:

buildscript {

  dependencies {

classpath 'com.kageiit:robojava-plugin:1.+'
  
}
 
}

Then create a stub project at the same level as your android project with a build.gradle like so:

evaluationDependsOn(':myapp') ext.androidProject = 'myapp' // name of the android project ext.variant = 'freeDebug' // add the test variant flavor (remove if you do not have use flavors). See example project. apply plugin: 'cobertura' // add if you want code coverage. See example project. apply plugin: 'com.kageiit.robojava'

The settings.gradle in the project root:

include 'myapp', 'tdd'

You may need to also use a custom test runner (may not be required for library projects). Add the generated-sources directory as source directory for the androidTest source set:

sourceSets.androidTest.java.srcDirs += 'build/generated-sources'

This will allow you to configure your custom test runner easily, as the plugin generates code for obtaining the directory paths to the manifest, resources, assets etc. See the included example.

The final structure may look something like this:

This plugin was created mainly to address the problem of not being able to configure Android project tests easily for the IDE and TDD etc. You can now simply do the following:

  • Run/debug all robolectric tests in the IDE without any other manual intervention/configuration.
  • Run a set of tests via the commandline: ./gradlew test --tests com.exampe.MyActivityTest.testAwesomeMethod
  • NO modifications required to Android Studio. Configuration lives with the project.

Compatibility

This plugin was tested against versions

  • Android Studio - 1.1 Preview 1
  • Android Gradle Build Plugin - 1.0.0

Known Issues

  • Only one test variant can be chosen at a time to run, if you are running single tests via the commandline. This limitation will be removed in a future release. Although, you can run all tests of all variants/flavors by simply running `./gradlew test'.
  • All tests in the main source set are fully integrated into Android Studio, but product flavor integration is currently in progress. You can run them via the commandline, however.

License

Copyright 2014 Gautam Korlam  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

An easy-to-integrate tab bar for Android that completely respects the Material Design guidelines and supports all versions of Android since API 9!

Allows you to retrieve exceptions of an Android Wear app in your handheld's one. It is particularly useful if you're using a Crash Reporting library or if you implemented a way to retrieve crashes.

This plugin let's you easily use the jarjar tool in your gradle builds. This is handy for dependencies, which need to be repackaged, e.g. the full bouncy castle library for Android projects.

The OpenCV library for Android as Gradle project.

An utility library for Android to run actions in background. It handles orientation changes and delegates results to the visible Activity.

An implementation of the SQRL protocol. This library helps to parse, validate and create SQRL messages.

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