项目作者: xvik

项目描述 :
Gradle AnimalSniffer plugin
高级语言: Groovy
项目地址: git://github.com/xvik/gradle-animalsniffer-plugin.git
创建时间: 2015-12-20T10:52:05Z
项目社区:https://github.com/xvik/gradle-animalsniffer-plugin

开源协议:MIT License

下载


gradle-animalsniffer-plugin

License
CI
Appveyor build status
codecov

DOCUMENTATION https://xvik.github.io/gradle-animalsniffer-plugin

About

Use AnimalSniffer signatures to check (JDK, android SDK or any library) API compatibility
for java (kotlin, scala, groovy etc.), android and kotlin multiplatform projects.

General tool: signatures could be created for any library to check api compatibility against older library versions.
Android community adopted it for android SDK compatibility verification.

Easy way to check android SDK compatibility for java library.

NOTE: Initially, animalsniffer was created for java compatibility checks, but java signatures
for JDK 9+ are not published due to module nature: use
—release flag
to check JDK 9+ backwards compatibility

  1. compileJava {
  2. options.release = 11
  3. }

Features:

  • Works with:
    • Java (and related) plugins: java (java-library), kotlin, groovy (only with @CompileStatic), scala,
      or any other jvm language (which plugin use sourceSets)
    • Android projects (library and application plugins)
    • Kotlin multiplatform projects
  • Could create signatures for your or any
    3rd party
    library (to check compatibility against the older library version)
  • Special task to view signature file contents
  • Report errors to console (to simplify reaction), text file and CSV (for external tools)
  • Could merge existing signatures (e.g. for caching)
  • Compatible with gradle configuration cache (gradle 9+ requirement)
  • Debug tools to learn or check configuration

Used by:

Summary
  • Configuration extensions:
    • animalsniffer - check configuration
    • animalsnifferSignature - signature build configuration (optional)
  • Tasks:
    • animalsniffer[Target] - check “[target]” sources (source set, android variant or kotlin platform)
    • animalsnifferSignature - build signature (active when animalsnifferSignature configuration declared)
    • printAnimalsnifferTasks - print registered check tasks
    • printAnimalsnifferSourceInfo - print defailed project sources and compile tasks info (for debug reports)
    • type:BuildSignatureTask - custom signature build task may be used to merge signatures
    • type:SignatureInfoTask - view signature “contents”
  • Dependencies configuration: signature - signatures for check

Setup

Maven Central
Gradle Plugin Portal

  1. buildscript {
  2. repositories {
  3. mavenCentral()
  4. }
  5. dependencies {
  6. classpath 'ru.vyarus:gradle-animalsniffer-plugin:2.0.0'
  7. }
  8. }
  9. apply plugin: 'ru.vyarus.animalsniffer'

OR

  1. plugins {
  2. id 'ru.vyarus.animalsniffer' version '2.0.0'
  3. }

Compatibility

Plugin only works with plugins:

  • Jvm languages: java-base plugin (activated by any java-related plugin like java, java-library, groovy, scala, org.jetbrains.kotlin.jvm, etc.).
  • Android: com.android.library or com.android.application plugins (required 7.4.0 or greater)
  • Kotlin Multiplatform: org.jetbrains.kotlin.multiplatform plugin (required 1.7 or greater).

The plugin is compiled for Java 8 and tested for compatibility with Java 11, 17 and 21.

Gradle Version
7-8 2.0.0
5 1.7.2
4.x 1.4.6

Snapshots


Snapshots may be used through JitPack or GitHub packages

##### GitHub package

WARNING: Accessing GitHub package requires GitHub authorization!

Access token creation is described here

Add to settings.gradle (top most!) (exact commit hash might be used as version) :

groovy pluginManagement { repositories { gradlePluginPortal() maven { url = 'https://maven.pkg.github.com/xvik/gradle-animalsniffer-plugin' credentials { username = settings.ext.find('gpr.user') ?: System.getenv("USERNAME") password = settings.ext.find('gpr.key') ?: System.getenv("TOKEN") } } } }
In global gradle file ~/.gradle/gradle.properties add
gpr.user=<your github user name> gpr.key=<your github password or classic token>
(or credentials must be declared in environment: USERNAME/TOKEN (more usable for CI))
Read personal access tokens creation guide
Note that token needs only “package/read” permission
Use plugin snapshot (see the latest published package version):

groovy plugins { id 'ru.vyarus.animalsniffer' version '2.0.1-SNAPSHOT' }

##### JitPack
Add to settings.gradle (top most!) (exact commit hash might be used as version) :

groovy pluginManagement { resolutionStrategy { eachPlugin { if (requested.id.id == 'ru.vyarus.use-python') { useModule('ru.vyarus:gradle-animalsniffer-plugin:master-SNAPSHOT') } } } repositories { gradlePluginPortal() maven { url 'https://jitpack.io' } } }
Note: this would use the latest snapshot. To use exact commit version, go to
JitPack project page
* Use plugin without declaring version:

groovy plugins { id 'ru.vyarus.animalsniffer' }

Usage

Read documentation

Example projects

Check:

Signature build:

  • Classes - signature from project classes
  • Jars - signature from project jars (configuration)
  • Signatures - signature from other signatures
  • Mixed - signature from different sources

Full android and multiplatform projects (created with android studio and kotlin init site):

Might also like


gradle plugin generator