Skip to content

Commit 9453bde

Browse files
authored
Merge pull request #3 from skydoves/feature/whatif-android
Separate to whatIf and whatIf-android module
2 parents 63b2361 + 99704f2 commit 9453bde

File tree

20 files changed

+120
-73
lines changed

20 files changed

+120
-73
lines changed

.github/workflows/android.yml

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
push:
55
branches:
66
- master
7+
pull_request:
8+
branches:
9+
- master
710

811
jobs:
912
build:

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
Add a dependency code to your **module**'s `build.gradle` file.
2626
```gradle
2727
dependencies {
28-
implementation "com.github.skydoves:whatif:1.0.5"
28+
implementation "com.github.skydoves:whatif:1.0.6"
29+
implementation "com.github.skydoves:whatif-android:1.0.6" // for android extensions
2930
}
3031
```
3132

app/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies {
1919
implementation "androidx.appcompat:appcompat:$versions.androidxAppcompat"
2020
implementation "com.github.skydoves:balloon:$versions.balloon"
2121
implementation project(":whatif")
22+
implementation project(":whatif-android")
2223
}
2324

2425
apply from: '../spotless.gradle'

build.gradle

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
buildscript {
2-
apply from: './dependencies.gradle'
3-
repositories {
4-
google()
5-
jcenter()
6-
}
7-
dependencies {
8-
classpath "com.android.tools.build:gradle:$versions.gradleBuildTool"
9-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin"
10-
classpath "com.diffplug.spotless:spotless-plugin-gradle:$versions.spotlessGradle"
11-
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$versions.dokkaGradle"
12-
classpath "com.novoda:bintray-release:$versions.bintrayRelease"
13-
}
2+
apply from: './dependencies.gradle'
3+
repositories {
4+
google()
5+
jcenter()
6+
}
7+
dependencies {
8+
classpath "com.android.tools.build:gradle:$versions.gradleBuildTool"
9+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin"
10+
classpath "com.diffplug.spotless:spotless-plugin-gradle:$versions.spotlessGradle"
11+
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$versions.dokkaGradle"
12+
classpath "com.novoda:bintray-release:$versions.bintrayRelease"
13+
}
1414
}
1515

1616
allprojects {
17-
repositories {
18-
google()
19-
jcenter()
20-
}
17+
repositories {
18+
google()
19+
jcenter()
20+
}
2121
}
2222

2323
task clean(type: Delete) {
24-
delete rootProject.buildDir
24+
delete rootProject.buildDir
2525
}

dependencies.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ ext.versions = [
22
minSdkLib : 15,
33
minSdkDemo : 16,
44
compileSdk : 29,
5-
versionCode : 6,
6-
versionName : '1.0.5',
5+
versionCode : 7,
6+
versionName : '1.0.6',
77

88
gradleBuildTool : '3.6.3',
99
spotlessGradle : '4.5.1',

publish.gradle

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
apply plugin: 'com.novoda.bintray-release'
22
apply from: '../dependencies.gradle'
33

4-
publish {
5-
userOrg = 'devmagician'
6-
groupId = 'com.github.skydoves'
7-
artifactId = 'whatif'
8-
publishVersion = versions.versionName
9-
desc = 'WhatIf is kotlin extensions for expressing a single if-else statement, nullable and boolean.'
10-
website = 'https://github.com/skydoves/WhatIf'
11-
issueTracker = "${website}/issues"
12-
repository = "${website}.git"
4+
ext {
5+
metadata = [
6+
userOrg : 'devmagician',
7+
groupId : 'com.github.skydoves',
8+
publishVersion: versions.versionName,
9+
desc : 'WhatIf is kotlin extensions for expressing a single if-else statement, nullable and boolean.',
10+
website : 'https://github.com/skydoves/WhatIf',
11+
issueTracker : '${website}/issues',
12+
repository : 'https://github.com/skydoves/WhatIf.git',
13+
licences : ['Apache-2.0']]
1314
}

settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
include ':whatif-android'
12
include ':app', ':whatif'
23
rootProject.name='WhatifDemo'

whatif-android/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

whatif-android/build.gradle

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
apply plugin: 'com.android.library'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'org.jetbrains.dokka'
4+
apply from: '../dependencies.gradle'
5+
apply from: '../publish.gradle'
6+
7+
android {
8+
compileSdkVersion versions.compileSdk
9+
defaultConfig {
10+
minSdkVersion versions.minSdkLib
11+
targetSdkVersion versions.compileSdk
12+
versionCode versions.versionCode
13+
versionName versions.versionName
14+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15+
}
16+
testOptions {
17+
unitTests {
18+
includeAndroidResources = true
19+
}
20+
}
21+
}
22+
23+
publish {
24+
artifactId = 'whatif-android'
25+
userOrg = metadata.userOrg
26+
groupId = metadata.groupId
27+
publishVersion = metadata.publishVersion
28+
desc = metadata.desc
29+
website = metadata.website
30+
issueTracker = metadata.issueTracker
31+
repository = metadata.repository
32+
licences = metadata.licences
33+
}
34+
35+
36+
dependencies {
37+
api project(":whatif")
38+
39+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$versions.kotlin"
40+
implementation "androidx.appcompat:appcompat:$versions.androidxAppcompat"
41+
42+
testImplementation "junit:junit:$versions.junit"
43+
testImplementation "org.robolectric:robolectric:$versions.robolectric"
44+
}
45+
46+
dokka {
47+
outputFormat = 'html'
48+
outputDirectory = "$buildDir/javadoc"
49+
configuration {
50+
moduleName = 'whatif'
51+
}
52+
}
53+
54+
tasks.withType(Javadoc) {
55+
excludes = ['**/*.kt']
56+
options.addBooleanOption('Xdoclint:none', true)
57+
}
58+
59+
apply from: '../spotless.gradle'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<manifest package="com.skydoves.whatif_android" />

whatif/src/main/java/com/skydoves/whatif/WhatIfActivity.kt renamed to whatif-android/src/main/java/com/skydoves/whatif_android/WhatIfActivity.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.skydoves.whatif
17+
package com.skydoves.whatif_android
1818

1919
import android.app.Activity
2020
import android.os.Bundle
21+
import com.skydoves.whatif.WhatIfInlineOnly
22+
import com.skydoves.whatif.whatIfNotNull
2123

2224
/**
2325
* An expression for invoking [whatIf] when the

whatif/src/main/java/com/skydoves/whatif/WhatIfFragment.kt renamed to whatif-android/src/main/java/com/skydoves/whatif_android/WhatIfFragment.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616

1717
@file:Suppress("unused")
1818

19-
package com.skydoves.whatif
19+
package com.skydoves.whatif_android
2020

2121
import android.app.Activity
2222
import android.content.Context
2323
import android.os.Bundle
2424
import androidx.fragment.app.Fragment
2525
import androidx.fragment.app.FragmentActivity
26+
import com.skydoves.whatif.WhatIfInlineOnly
27+
import com.skydoves.whatif.whatIfNotNull
2628

2729
/**
2830
* An expression for invoking [whatIf] when the [Context] is not null.

whatif/src/test/java/com/skydoves/whatif/MainTestActivity.kt renamed to whatif-android/src/test/java/com/skydoves/whatif_android/MainTestActivity.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.skydoves.whatif
17+
package com.skydoves.whatif_android
1818

1919
import android.app.Activity
2020

whatif/src/test/java/com/skydoves/whatif/WhatIfActivityTest.kt renamed to whatif-android/src/test/java/com/skydoves/whatif_android/WhatIfActivityTest.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.skydoves.whatif
17+
package com.skydoves.whatif_android
1818

1919
import android.content.Intent
2020
import org.hamcrest.CoreMatchers.`is`
@@ -38,7 +38,8 @@ class WhatIfActivityTest {
3838
fun createActivity() {
3939
val intent = Intent()
4040
intent.putExtra("foo", "bar")
41-
this.controller = Robolectric.buildActivity(MainTestActivity::class.java, intent).create().start()
41+
this.controller = Robolectric.buildActivity(
42+
MainTestActivity::class.java, intent).create().start()
4243
this.mainTestActivity = controller.get()
4344
}
4445

whatif/build.gradle

+12-18
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
1-
apply plugin: 'com.android.library'
2-
apply plugin: 'kotlin-android'
1+
apply plugin: 'java-library'
2+
apply plugin: 'kotlin'
33
apply plugin: 'org.jetbrains.dokka'
44
apply from: '../dependencies.gradle'
55
apply from: '../publish.gradle'
66

7-
android {
8-
compileSdkVersion versions.compileSdk
9-
defaultConfig {
10-
minSdkVersion versions.minSdkLib
11-
targetSdkVersion versions.compileSdk
12-
versionCode versions.versionCode
13-
versionName versions.versionName
14-
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15-
}
16-
testOptions {
17-
unitTests {
18-
includeAndroidResources = true
19-
}
20-
}
7+
publish {
8+
artifactId = 'whatif'
9+
userOrg = metadata.userOrg
10+
groupId = metadata.groupId
11+
publishVersion = metadata.publishVersion
12+
desc = metadata.desc
13+
website = metadata.website
14+
issueTracker = metadata.issueTracker
15+
repository = metadata.repository
16+
licences = metadata.licences
2117
}
2218

2319
dependencies {
2420
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$versions.kotlin"
25-
implementation "androidx.appcompat:appcompat:$versions.androidxAppcompat"
2621
testImplementation "junit:junit:$versions.junit"
27-
testImplementation "org.robolectric:robolectric:$versions.robolectric"
2822
}
2923

3024
dokka {

whatif/src/main/java/com/skydoves/whatif/WhatIfInlineOnly.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ package com.skydoves.whatif
2323
)
2424
@DslMarker
2525
@Retention(AnnotationRetention.BINARY)
26-
internal annotation class WhatIfInlineOnly
26+
annotation class WhatIfInlineOnly

whatif/src/test/java/com/skydoves/whatif/WhatIfArrayUnitTest.kt

-5
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@ package com.skydoves.whatif
1919
import org.hamcrest.MatcherAssert.assertThat
2020
import org.hamcrest.core.Is.`is`
2121
import org.junit.Test
22-
import org.junit.runner.RunWith
23-
import org.robolectric.RobolectricTestRunner
24-
import org.robolectric.annotation.Config
2522

26-
@RunWith(RobolectricTestRunner::class)
27-
@Config(sdk = [21])
2823
class WhatIfArrayUnitTest {
2924

3025
@Test

whatif/src/test/java/com/skydoves/whatif/WhatIfCollectionsUnitTest.kt

-5
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@ package com.skydoves.whatif
1919
import org.hamcrest.MatcherAssert.assertThat
2020
import org.hamcrest.core.Is.`is`
2121
import org.junit.Test
22-
import org.junit.runner.RunWith
23-
import org.robolectric.RobolectricTestRunner
24-
import org.robolectric.annotation.Config
2522

26-
@RunWith(RobolectricTestRunner::class)
27-
@Config(sdk = [21])
2823
class WhatIfCollectionsUnitTest {
2924

3025
@Test

whatif/src/test/java/com/skydoves/whatif/WhatIfStringUnitTest.kt

-5
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@ package com.skydoves.whatif
1919
import org.hamcrest.CoreMatchers.`is`
2020
import org.hamcrest.MatcherAssert.assertThat
2121
import org.junit.Test
22-
import org.junit.runner.RunWith
23-
import org.robolectric.RobolectricTestRunner
24-
import org.robolectric.annotation.Config
2522

26-
@RunWith(RobolectricTestRunner::class)
27-
@Config(sdk = [21])
2823
class WhatIfStringUnitTest {
2924

3025
@Test

whatif/src/test/java/com/skydoves/whatif/WhatIfUnitTest.kt

-5
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@ package com.skydoves.whatif
1919
import org.hamcrest.MatcherAssert.assertThat
2020
import org.hamcrest.core.Is.`is`
2121
import org.junit.Test
22-
import org.junit.runner.RunWith
23-
import org.robolectric.RobolectricTestRunner
24-
import org.robolectric.annotation.Config
2522

26-
@RunWith(RobolectricTestRunner::class)
27-
@Config(sdk = [21])
2823
class WhatIfUnitTest {
2924

3025
@Test

0 commit comments

Comments
 (0)