gradle-errorprone-plugin


Source link: https://github.com/tbroyer/gradle-errorprone-plugin

Gradle error-prone plugin

This plugin configures JavaCompile tasks to use the error-prone compiler.

Requirements

This plugin depends on Gradle internal APIs, and is only guaranteed to work with the Gradle version it's been compiled against (check the wrapper task in the build.gradle.) It also depends on Javac internal APIs, directly exposed by error-prone.

Gradle error-prone plugin version Supported Gradle versions Supported error-prone version Supported javac version
0.0.1, 0.0.2 1.8 - 1.11 1.+ 7
0.0.3 1.8 - 1.12 1.+ 7
0.0.4 2.1 1.+ 7
0.0.5 2.2 - 2.3 1.+ 7
0.0.6 2.2 - 2.3 1.+¹, 2.+ 7, 8
0.0.7, 0.0.7.1 2.4 - 2.5 1.+¹, 2.+ 7, 8
0.0.8 2.6 - 3.4 1.+¹, 2.+ 7, 8
0.0.9 2.6 - 3.4 1.+¹, 2.+ 7, 8
0.0.10                         2.6 - 4.3   1.+¹, 2.+                     7, 8
0.0.11                         2.6 - 4.3   1.+¹, 2.+                     7, 8
0.0.12                         2.6 - 4.3   2.+                     8
0.0.13                         2.6 - 4.3   2.+                     8, 9
master                         2.6 - 4.3   2.+                     8, 9

¹: error-prone 1.x is only supported with JDK 7

Note: Gradle 2.0 is not supported; it lacks APIs to manipulate the actual compiler being used. Similarly, Gradle 3.5-rc-1 removed APIs this plugin uses, they've been reintroduced in 3.5-rc-2.

Usage

To use the error-prone plugin, first add it to your project following the instructions from the Gradle Plugin Portal¹, then make sure you have a repository configured that contains the com.google.errorprone:error_prone_core dependency; for example:

repositories {

mavenCentral() 
}

¹: For older versions of the plugins, please read the according version of this README

When applied, the net.ltgt.errorprone plugin automatically changes all JavaCompile tasks in the project to use the error-prone compiler. (Note: earlier versions used errorprone as the plugin identifier instead of net.ltgt.errorprone.)

You can configure the error-prone compiler using the JavaCompile's options.compilerArgs, for example:

tasks.withType(JavaCompile) {

options.compilerArgs += [ '-Xep:DeadException:WARN', '-Xep:GuardedByValidator:OFF' ] 
}

The plugin adds an errorprone configuration that automatically uses the latest release of error-prone. You can override it to use a specific version with:

dependencies {

errorprone 'com.google.errorprone:error_prone_core:2.0.21' 
}

or, for versions of the plugin before (and including) 0.0.8:

configurations.errorprone {

// 2.0.5 is the last version compatible with JDK 7
resolutionStrategy.force 'com.google.errorprone:error_prone_core:2.0.5' 
}

If you forked error-prone and changed the groupId, the syntax may vary (depending on the version of the plugin):

dependencies {

// Use my.company fork of error-prone
errorprone "my.company.errorprone:error_prone_core:latest.release" 
}

or

// Use my.company fork of error-prone configurations.errorprone {

resolutionStrategy.eachDependency {
 DependencyResolveDetails details ->
  if (details.requested.group == 'com.google.errorprone') {

 details.useTarget "my.company.errorprone:${
details.requested.name
}
:latest.release"
  
}

}
 
}

Advanced usage

If you want more control as to which task to change, you can apply the net.ltgt.errorprone-base plugin instead, which doesn't reconfigure any task. You'll then configure each task as follows (using the compileJava task as an example):

import net.ltgt.gradle.errorprone.ErrorProneToolChain  compileJava {

toolChain ErrorProneToolChain.create(project) 
}

You can go further and provide a configuration containing the com.google.errorprone:error_prone_core dependency (defaults to configurations.errorprone). The above configuration is thus equivalent to:

import net.ltgt.gradle.errorprone.ErrorProneToolChain  compileJava {

toolChain new ErrorProneToolChain(configurations.errorprone) 
}

Troubleshooting

If your build fails with a compiler error, before opening an issue here, first make sure you're not hitting an Error Prone bug.

  1. Re-run your Gradle build with --debug and locate the compiler arguments in the outputs.
    The plugin should output a line with Compiling with error-prone compiler; you can also search for -sourcepath in the output.
  2. Download the standalone Error Prone compiler (make sure you use the same version), and run it with those arguments.
    You might have to add an empty-string argument after -sourcepath (rendering of the arguments in Gradle output might omit the quotes for that empty string)

If those steps reproduce the issue, then it's an ErrorProne bug (in which case please report the issue to the Error Prone project); otherwise it might be a gradle-errorprone-plugin bug (and then I'd need a repro case to debug what's happening).

You can also try using different versions of Error Prone. If that fixes your problem, then again it likely is not a gradle-errorprone-plugin bug.

Resources

Android MediaPlayer/VideoView API-compatible media player library with exact seek, playback speed adjustment and DASH support.

SwitchDateTime Picker is a library for select a Date object in dialog with a DatePicker (Calendar) and a TimePicker (Clock) in the same UI.

AndroidMaryTTS is an open source Android offline text to speech application, built on top of MaryTTS. Can use own HMM-based voice in any android application with using this lib.

The IpGetter is a plugin which will help us to get the Ip of the current machine to use on a build.gradle.

You may ask, why do I need that? The answer is simple, you need that to replace your API URL for your computer address during development stage, to point to a MockApi or a under development api. That's the main idea.

Barcode Scanner powered by Google Mobile Vision Api.

ACR is an android library to simplify crash detection while your app is under development, crash will be automatically detect by the library then app tester/user can easily send the crash report on one click to developer that will help him to fix the issue.

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