All Projects → retropiler → Retropiler

retropiler / Retropiler

Licence: other
PoC of Java8 Standard Library for Android for API version >= 15

Programming Languages

java
68154 projects - #9 most used programming language
java8
65 projects

Projects that are alternatives of or similar to Retropiler

Gradle Css Plugin
Gradle plugin for working with CSS
Stars: ✭ 125 (-21.38%)
Mutual labels:  gradle-plugin
Kotlin Gradle Plugin Template
🐘 A template to let you started with custom Gradle Plugins + Kotlin in a few seconds
Stars: ✭ 141 (-11.32%)
Mutual labels:  gradle-plugin
Gradle License Report
A plugin for generating reports about the licenses of third party software using Gradle
Stars: ✭ 152 (-4.4%)
Mutual labels:  gradle-plugin
Gradle Eclipse Aar Plugin
Gradle plugin to use Android AAR libraries on Eclipse.
Stars: ✭ 127 (-20.13%)
Mutual labels:  gradle-plugin
Findbugs Android
Gradle plugin that creates FindBugs reports for android projects
Stars: ✭ 133 (-16.35%)
Mutual labels:  gradle-plugin
Moko Resources
Resources access for mobile (android & ios) Kotlin Multiplatform development
Stars: ✭ 142 (-10.69%)
Mutual labels:  gradle-plugin
Reckon
Infer a project's version from your Git repository.
Stars: ✭ 124 (-22.01%)
Mutual labels:  gradle-plugin
Shipkit
Toolkit for shipping it used by Mockito library
Stars: ✭ 157 (-1.26%)
Mutual labels:  gradle-plugin
Gradle Nexus Staging Plugin
Automatize releasing Gradle projects to Maven Central.
Stars: ✭ 132 (-16.98%)
Mutual labels:  gradle-plugin
Shortbread
Android library that creates app shortcuts from annotations
Stars: ✭ 1,803 (+1033.96%)
Mutual labels:  gradle-plugin
Forma
Meta build system with Android and Gradle support.
Stars: ✭ 127 (-20.13%)
Mutual labels:  gradle-plugin
Gson Plugin
辅助 Gson 库的 gradle 插件,防止 Json 数据解析类型异常。
Stars: ✭ 133 (-16.35%)
Mutual labels:  gradle-plugin
Android Snapshot Publisher
Gradle plugin to deploy Android Snapshot Versions
Stars: ✭ 145 (-8.81%)
Mutual labels:  gradle-plugin
Bytex
ByteX is a bytecode plugin platform based on Android Gradle Transform API and ASM. 字节码插件开发平台
Stars: ✭ 2,140 (+1245.91%)
Mutual labels:  gradle-plugin
Gradle Android Plugin
[Deprecated] Gradle Android Plugin 中文版使用手册,如有纰漏,望斧正
Stars: ✭ 155 (-2.52%)
Mutual labels:  gradle-plugin
Jib
🏗 Build container images for your Java applications.
Stars: ✭ 11,370 (+7050.94%)
Mutual labels:  gradle-plugin
Gradle Pitest Plugin
Gradle plugin for PIT Mutation Testing
Stars: ✭ 144 (-9.43%)
Mutual labels:  gradle-plugin
Versioning
Gradle plug-in to generate version information from the SCM branch (Git or Svn)
Stars: ✭ 157 (-1.26%)
Mutual labels:  gradle-plugin
Buildkonfig
BuildConfig for Kotlin Multiplatform Project
Stars: ✭ 156 (-1.89%)
Mutual labels:  gradle-plugin
Gradle Aem Plugin
Swiss army knife for Adobe Experience Manager related automation. Environment setup & incremental AEM application build which takes seconds, not minutes.
Stars: ✭ 145 (-8.81%)
Mutual labels:  gradle-plugin

Retropiler CircleCI Download

"Java8 support" in Android is sometimes misunderstood because it includes a few independent issues.

Java8 Language Feature is usually syntactic one, for example lambda expressions or default methods; in Android, this is solved by tools like retrolambda or desugar.

Java8 API, or Standard Library, is runtime library on the platform. The support of Standard Library in Android is more difficult than Language Feature, because dex, Dalvik executable file format, does not allow bundle Standard Library in APK. In fact, it was considered impossible -- before this project shows its possibility.

Retropiler deals with the latter: it makes dex to bundle Java8 standard library by replacing its references to the original ones.

For example, the following code works on devices with Android API level 15 after processing by retropiler:

import java.util.Optional;

Optional<String> optStr = Optional.of("foo");

assertThat(optStr.get(), is("foo")); // it works!

Here is the magic.

The basic idea is that replacing Java8-specifc classes / methods to the bundled version of them with bytecode weaving.

That is, the above code is transformed into:

import io.github.retropiler.runtime.java.util._Optional;

_Optional<String> optStr = _Optional.of("foo");

assertThat(optStr.get(), is("foo")); // it works!

It can work even on Android API 15.

Installation

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'io.github.retropiler:retropiler-gradle-plugin:0.0.5'
    }
}

apply plugin: 'io.github.retropiler'

Supported Classes

Iterable#forEach()

Arrays.asList("foo", "bar").forEach(item -> {
    Log.d("XXX", item);
});

java.util.Optional

Optional<String> optStr = Optional.of("baz");
optStr.ifPresent(str -> {
    Log.d("XXX", str);
});

Part of java.util.function package

Not all the functions are tested yet.

Customizing Runtime Class Mapping

You can customize mapping of stndard class to alternative runtime class:

apply plugin: 'io.github.retropiler'

retropiler {
    // the default runtime package
    runtimePackage "io.github.retropiler.runtime"

    // the default mapping function
    mapClassName { ext, ctClass ->
        // e.g. map java.util.Optional to io.github.retropiler.runtime.java.util._Optional
        "${ext.runtimePackage}.${ctClass.packageName}._${ctClass.simpleName}"
    }
}

Methods Count

Retropiler depends on Retrolambda to transform lambda expressions to anonymous classes.

The methods defined in runtime/ are here:

io.github.retropiler:retropiler-runtime:0.0.5

Caveats

  • This project is incubating so use of it in production is not recommended.
  • The gradle plugin automatically applies retrolambda
  • The gradle plugin does not support Android SDK's desugar (bundled in the build tools for Android O)
    • Will support desugar after its stable release

See Also

Release Engineering

There are three modules to publish:

  • plugin/ - Gradle plugin
  • runtime/ - runtime library
  • annotations/ - annotation library

You can publish them by:

make publish

with properties in ~/.gradle/gradle.properties:

bintrayUser=$user
bintrayKey=$key

Authors and Contributors

FUJI Goro (gfx).

And contributors are listed here: Contributors

The class library in runtime module comes from Open JDK via AOSP.

Licenses

The Java source files in runtime/ module which were copied from AOSP, are licensed under GPL v2+CE as described in each file.

Other modules except for runtime/ are licensed under Apache License 2.0:

Copyright (c) 2017 The Retropiler Project.

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].