Skip to content

Commit

Permalink
Merge pull request #320 from stephanenicolas/dlemures/removing-regist…
Browse files Browse the repository at this point in the history
…ries

TP 2.0
  • Loading branch information
dlemures committed Feb 1, 2019
2 parents 2483d2d + 056229f commit dbbe1d2
Show file tree
Hide file tree
Showing 136 changed files with 1,512 additions and 2,334 deletions.
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ android:
components:
# https://github.com/travis-ci/travis-ci/issues/5036
- tools
- build-tools-26.0.2
- android-26
- build-tools-28.0.3
- android-28
- extra-android-m2repository

jdk:
Expand Down Expand Up @@ -37,7 +37,9 @@ cache:
- $HOME/.android/build-cache

script:
- ./gradlew clean check -x :smoothie-sample:lint
- ./gradlew clean check
- ./gradlew -b toothpick-sample/build.gradle clean check
- ./gradlew -b smoothie-sample/build.gradle clean check -x lint

after_success:
- ./gradlew jacocoTestReport coveralls
Expand Down
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
<!-- Continue from top -->

## Release version 1.1.4 (To be released)
## Release version 2.0.0 (To be released)

* support incremental annotation processing. All processors are now incremental and isolating.
* remove all registries, TP 2.x doesn't use registries any more. They were actually slower than not using them after
we reworked on registries to enable obfuscation. Reflection is now used to load the factories and member injectors,
this is normal (and all other annotation processor based libs do that too) and there is no impact on performance.
* support multiple rounds of annotation processing.
* generated classes now use `__` instead of `$$` to make TP more compliant with some tools.
* removed the generate ContextSingleton annotation
* smoothie now binds the ClipClipboardManager service. Thx to Cody Henthrone for this. Sorry we were late merging this !
* smoothie now contains non support and non android x bindings. We have introduced 2 new artifacts:
smoothie-support and smoothie-androidx that respectively support the old legacy support library and the new android X libs).
* toothpick-testing now only contains core testing classes. New artifacts have been introduced to support junit 4 nd junit 5 (resp. : toothpick-testing-junit4, toothpick-testing-junit5)
* added a consumer proguard file

## Release version 1.1.3 (March 10th, 2018)

Expand Down
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,28 +78,32 @@ Currently Toothpick has 2 sets of examples :
* one [for Android](https://github.com/stephanenicolas/toothpick/tree/master/smoothie-sample)

## Setup

The latest version of TP is provided by a badge at the top of this page.

For Android :
```groovy
#android setup using gradle 2.2.3
#android setup using gradle 3.3.0
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:3.3.0'
}
}
...
dependencies {
compile 'com.github.stephanenicolas.toothpick:toothpick-runtime:1.1.3'
// and for android -> compile 'com.github.stephanenicolas.toothpick:smoothie:1.1.3'
annotationProcessor 'com.github.stephanenicolas.toothpick:toothpick-compiler:1.1.3'
implementation 'com.github.stephanenicolas.toothpick:toothpick-runtime:2.x'
// and for android -> implementation 'com.github.stephanenicolas.toothpick:smoothie-androidx:2.x'
annotationProcessor 'com.github.stephanenicolas.toothpick:toothpick-compiler:2.x'
//highly recommended
testCompile 'com.github.stephanenicolas.toothpick:toothpick-testing:1.1.3'
testCompile 'mockito or easymock'
testImplementation 'com.github.stephanenicolas.toothpick:toothpick-testing-junit5:2.x'
testImplementation 'mockito or easymock'
}
```

Expand All @@ -110,21 +114,21 @@ For java:
<dependency>
<groupId>com.github.stephanenicolas.toothpick</groupId>
<artifactId>toothpick-compiler</artifactId>
<version>1.1.3</version>
<version>2.x</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.stephanenicolas.toothpick</groupId>
<artifactId>toothpick-runtime</artifactId>
<version>1.1.3</version>
<version>2.x</version>
<scope>compile</scope>
</dependency>

<!-- highly recommended-->
<dependency>
<groupId>com.github.stephanenicolas.toothpick</groupId>
<artifactId>toothpick-testing</artifactId>
<version>1.1.3</version>
<version>2.x</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -175,3 +179,7 @@ Visit [Toothpick's wiki](https://github.com/stephanenicolas/toothpick/wiki) !

* [Okuki](https://github.com/wongcain/okuki) is a simple, hierarchical navigation bus and back stack for Android, with optional Rx bindings, and Toothpick DI integration.
* [KotlinWeather](https://github.com/ekamp/KotlinWeather) is a simple example of using ToothPick with Kotlin and gradle integration using kapt.

# Credits

Most of the effort on version 2 has been actively supported by Groupon. Thanks for this awesome OSS commitment !
31 changes: 3 additions & 28 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ apply plugin: 'jacoco'
apply plugin: 'com.github.kt3k.coveralls'

buildscript {
apply from: 'deps.gradle'
repositories {
google()
jcenter()
}
dependencies {
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.6.3'
classpath deps.coverallPlugin
}
}

Expand Down Expand Up @@ -113,30 +115,3 @@ subprojects { project ->
}
}
}

ext.deps = [// Common
inject : 'javax.inject:javax.inject:1',

// Compiler
javapoet : 'com.squareup:javapoet:1.4.0',

// Android
android : 'com.google.android:android:4.1.1.4',
supportv4 : 'com.google.android:support-v4:r7',
supportAnnotations : 'com.android.support:support-annotations:23.3.0',
butterknife : 'com.jakewharton:butterknife:8.0.0',
butterknife_compiler: 'com.jakewharton:butterknife-compiler:8.0.0',
rxandroid : 'io.reactivex:rxandroid:0.23.0',

// Test dependencies
junit : 'junit:junit:4.12',
hamcrest : 'org.hamcrest:java-hamcrest:2.0.0.0',
truth : 'com.google.truth:truth:0.34',
compiletesting : 'com.google.testing.compile:compile-testing:0.11',
easymock : 'org.easymock:easymock:3.4',
powermock : 'org.powermock:powermock-easymock-release-full:1.6.4',
robolectric : 'org.robolectric:robolectric:3.4.2',

// Android Test Dependencies
espresso : 'com.android.support.test.espresso:espresso-core:2.2.2',
dexmaker : 'com.google.dexmaker:dexmaker:1.2',]
42 changes: 42 additions & 0 deletions deps.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
ext.deps = [// Common
inject : 'javax.inject:javax.inject:1',

// Compiler
javapoet : 'com.squareup:javapoet:1.11.1',

// Android
android : 'com.google.android:android:4.1.1.4',
androidPlugin : 'com.android.tools.build:gradle:3.3.0',
coverallPlugin : 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.6.3',
supportv4 : 'com.android.support:support-v4:28.0.0',
androidxv4 : 'androidx.legacy:legacy-support-v4:1.0.0',
butterknife : 'com.jakewharton:butterknife:10.0.0',
butterknife_compiler: 'com.jakewharton:butterknife-compiler:10.0.0',
rxandroid : 'io.reactivex:rxandroid:1.2.1',

// TP artifacts for composite builds
tp_smoothie : 'com.github.stephanenicolas.toothpick:smoothie:2.0.0',
tp_smoothie_androidx: 'com.github.stephanenicolas.toothpick:smoothie-androidx:2.0.0',
tp_smoothie_support : 'com.github.stephanenicolas.toothpick:smoothie-support:2.0.0',
tp : 'com.github.stephanenicolas.toothpick:toothpick:2.0.0',
tp_runtime : 'com.github.stephanenicolas.toothpick:toothpick-runtime:2.0.0',
tp_compiler : 'com.github.stephanenicolas.toothpick:toothpick-compiler:2.0.0',
tp_testing : 'com.github.stephanenicolas.toothpick:toothpick-testing:2.0.0',
tp_testing_junit4 : 'com.github.stephanenicolas.toothpick:toothpick-testing-junit4:2.0.0',
tp_testing_junit5 : 'com.github.stephanenicolas.toothpick:toothpick-testing-junit5:2.0.0',

// Test dependencies
junit4 : 'junit:junit:4.12',
junit5_api : 'org.junit.jupiter:junit-jupiter-api:5.3.2',
junit5_engine : 'org.junit.jupiter:junit-jupiter-engine:5.3.2',
hamcrest : 'org.hamcrest:java-hamcrest:2.0.0.0',
truth : 'com.google.truth:truth:0.42',
compiletesting : 'com.google.testing.compile:compile-testing:0.15',
easymock : 'org.easymock:easymock:3.4',
powermock : 'org.powermock:powermock-easymock-release-full:1.6.4',
powermock_rule : 'org.powermock:powermock-module-junit4-rule-agent:1.6.4',
robolectric : 'org.robolectric:robolectric:3.4.2',

// Android Test Dependencies
espresso : 'com.android.support.test.espresso:espresso-core:2.2.2',
dexmaker : 'com.google.dexmaker:dexmaker:1.2',]
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GROUP=com.github.stephanenicolas.toothpick
VERSION_NAME=1.1.4-SNAPSHOT
VERSION_NAME=2.0.0-SNAPSHOT

POM_PACKAGING=JAR
POM_DESCRIPTION=DI.
Expand Down
1 change: 0 additions & 1 deletion gradle/gradle-mvn-push.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ afterEvaluate { project ->
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.source
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.debugCompileClasspath
}

task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip

7 changes: 4 additions & 3 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
include ':toothpick'
include ':toothpick-javax-annotations'
include ':toothpick-generated-core'
include ':toothpick-compiler'
include ':toothpick-runtime'
include ':toothpick-testing'
include ':toothpick-sample'
include ':toothpick-testing-junit4'
include ':toothpick-testing-junit5'
include ':smoothie'
include ':smoothie-sample'
include ':smoothie-support'
include ':smoothie-androidx'

rootProject.name = 'toothpick-parent'
52 changes: 52 additions & 0 deletions smoothie-androidx/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath deps.androidPlugin
}

}

apply plugin: 'com.android.library'

repositories {
google()
}

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

defaultConfig {
minSdkVersion 15
}

lintOptions {
textReport true
textOutput 'stdout'
// We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks.
checkReleaseBuilds false
}
}

dependencies {
compileOnly project(':toothpick')
api project(':smoothie')
compileOnly deps.inject
compileOnly deps.androidxv4

testImplementation deps.androidxv4
testImplementation project(':toothpick-testing')
testImplementation deps.junit4
testImplementation deps.easymock
testImplementation deps.robolectric
}

apply from: rootProject.file('gradle/gradle-mvn-push.gradle')
4 changes: 4 additions & 0 deletions smoothie-androidx/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
POM_ARTIFACT_ID=smoothie-androidx
POM_NAME=smoothie android X
POM_DESCRIPTION='Toothpick package providing Android providers for the android X library'
POM_PACKAGING='aar'
2 changes: 2 additions & 0 deletions smoothie-androidx/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.github.stephanenicolas.toothpick.smoothie_androidx"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package toothpick.smoothie.module;

import android.app.Activity;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.loader.app.LoaderManager;
import android.view.LayoutInflater;
import toothpick.config.Module;
import toothpick.smoothie.provider.AndroidXFragmentManagerProvider;
import toothpick.smoothie.provider.AndroidXLoaderManagerProvider;
import toothpick.smoothie.provider.LayoutInflaterProvider;

public class SmoothieAndroidXActivityModule extends Module {
public SmoothieAndroidXActivityModule(FragmentActivity activity) {
bind(Activity.class).toInstance(activity);
bind(FragmentManager.class).toProviderInstance(new AndroidXFragmentManagerProvider(activity));
bind(LoaderManager.class).toProviderInstance(new AndroidXLoaderManagerProvider(activity));
bind(LayoutInflater.class).toProviderInstance(new LayoutInflaterProvider(activity));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package toothpick.smoothie.provider;

import android.app.Activity;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import javax.inject.Provider;

public class AndroidXFragmentManagerProvider implements Provider<FragmentManager> {
Activity activity;

public AndroidXFragmentManagerProvider(Activity activity) {
this.activity = activity;
}

@Override
public FragmentManager get() {
return ((FragmentActivity) activity).getSupportFragmentManager();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package toothpick.smoothie.provider;

import android.app.Activity;
import androidx.fragment.app.FragmentActivity;
import androidx.loader.app.LoaderManager;
import javax.inject.Provider;

public class AndroidXLoaderManagerProvider implements Provider<LoaderManager> {
Activity activity;

public AndroidXLoaderManagerProvider(Activity activity) {
this.activity = activity;
}

@Override
public LoaderManager get() {
return ((FragmentActivity) activity).getSupportLoaderManager();
}
}
Loading

0 comments on commit dbbe1d2

Please sign in to comment.