Kapt: Do not treat initially empty configurations specially (KT-27404)
This commit is contained in:
+2
-1
@@ -154,10 +154,11 @@ open class Kapt3AndroidIT : Kapt3BaseIT() {
|
|||||||
val project = Project("android-databinding", directoryPrefix = "kapt2")
|
val project = Project("android-databinding", directoryPrefix = "kapt2")
|
||||||
setupDataBinding(project, "app")
|
setupDataBinding(project, "app")
|
||||||
|
|
||||||
project.build("assembleDebug") {
|
project.build("assembleDebug", "assembleAndroidTest") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertKaptSuccessful()
|
assertKaptSuccessful()
|
||||||
assertFileExists("app/build/generated/source/kapt/debug/com/example/databinding/BR.java")
|
assertFileExists("app/build/generated/source/kapt/debug/com/example/databinding/BR.java")
|
||||||
|
assertFileExists("library/build/generated/source/kapt/debugAndroidTest/android/databinding/DataBinderMapperImpl.java")
|
||||||
|
|
||||||
if (isLegacyAndroidGradleVersion(androidGradlePluginVersion)) {
|
if (isLegacyAndroidGradleVersion(androidGradlePluginVersion)) {
|
||||||
assertFileExists("app/build/generated/source/kapt/debug/com/example/databinding/databinding/ActivityTestBinding.java")
|
assertFileExists("app/build/generated/source/kapt/debug/com/example/databinding/databinding/ActivityTestBinding.java")
|
||||||
|
|||||||
+3
-1
@@ -11,6 +11,7 @@ android {
|
|||||||
targetSdkVersion 24
|
targetSdkVersion 24
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
@@ -30,7 +31,8 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
kapt "com.android.databinding:compiler:$android_tools_version"
|
//kapt "com.android.databinding:compiler:$android_tools_version"
|
||||||
|
kaptAndroidTest "junit:junit:4.12"
|
||||||
compile 'com.android.support.constraint:constraint-layout:1.0.2'
|
compile 'com.android.support.constraint:constraint-layout:1.0.2'
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
}
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.databinding.test">
|
||||||
|
<application>
|
||||||
|
<activity android:name="com.example.databinding.test.BlankActivity"/>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package com.example.databinding.test
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
|
||||||
|
class BlankActivity : Activity() {}
|
||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
apply plugin: 'com.android.library'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
apply plugin: 'kotlin-kapt'
|
||||||
|
apply plugin: 'kotlin-android-extensions'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 27
|
||||||
|
buildToolsVersion "27.0.3"
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
minSdkVersion 21
|
||||||
|
targetSdkVersion 27
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dataBinding { enabled = true }
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
|
testImplementation 'junit:junit:4.12'
|
||||||
|
|
||||||
|
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||||
|
androidTestImplementation "com.android.support.test:rules:1.0.2"
|
||||||
|
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||||
|
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.maw.library">
|
||||||
|
<application>
|
||||||
|
<activity android:name="org.maw.library.BlankActivity"/>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
package org.maw.library
|
||||||
|
|
||||||
|
import android.support.v7.app.AppCompatActivity
|
||||||
|
|
||||||
|
class BlankActivity : AppCompatActivity() {
|
||||||
|
}
|
||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
package org.maw.library
|
||||||
|
|
||||||
|
import android.support.test.annotation.UiThreadTest
|
||||||
|
import android.support.test.rule.ActivityTestRule
|
||||||
|
import android.support.test.runner.AndroidJUnit4
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instrumented test, which will execute on an Android device.
|
||||||
|
*
|
||||||
|
* @see [Testing documentation](http://d.android.com/tools/testing)
|
||||||
|
*/
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class ExampleInstrumentedTest {
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
var activityTestRule = ActivityTestRule<BlankActivity>(BlankActivity::class.java)
|
||||||
|
|
||||||
|
|
||||||
|
@UiThreadTest
|
||||||
|
@Test
|
||||||
|
fun createAndAddView() {
|
||||||
|
|
||||||
|
val container = activityTestRule.activity.findViewById<ViewGroup>(android.R.id.content)
|
||||||
|
val testView = TestView(activityTestRule.activity)
|
||||||
|
|
||||||
|
container.addView(testView)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.maw.library"/>
|
||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
package org.maw.library
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.databinding.BindingAdapter
|
||||||
|
import android.databinding.DataBindingComponent
|
||||||
|
import android.databinding.DataBindingUtil
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.widget.FrameLayout
|
||||||
|
import android.widget.TextView
|
||||||
|
import org.maw.library.databinding.TestViewBinding
|
||||||
|
|
||||||
|
class TestView @JvmOverloads constructor(
|
||||||
|
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||||
|
) : FrameLayout(context, attrs, defStyleAttr) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
DataBindingUtil.inflate<TestViewBinding>(
|
||||||
|
LayoutInflater.from(context),
|
||||||
|
R.layout.test_view,
|
||||||
|
this,
|
||||||
|
true,
|
||||||
|
object : DataBindingComponent {
|
||||||
|
override fun getTextLabelBindingAdapter(): TextLabelBindingAdapter {
|
||||||
|
return TextLabelBindingAdpaterImpl()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TextLabelBindingAdapter {
|
||||||
|
@BindingAdapter("textLabel")
|
||||||
|
fun setTextLabel(
|
||||||
|
errorMessageView: TextView,
|
||||||
|
textLabelType: Int
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
class TextLabelBindingAdpaterImpl : TextLabelBindingAdapter {
|
||||||
|
override fun setTextLabel(
|
||||||
|
errorMessageView: TextView,
|
||||||
|
textLabelType: Int
|
||||||
|
) {
|
||||||
|
when (textLabelType) {
|
||||||
|
0 -> errorMessageView.text = "Zero"
|
||||||
|
1 -> errorMessageView.text = "One"
|
||||||
|
2 -> errorMessageView.text = "Two"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<data>
|
||||||
|
<import type="android.view.View" />
|
||||||
|
|
||||||
|
<variable
|
||||||
|
name="textLabelType"
|
||||||
|
type="Integer"/>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical" android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:textLabel="@{textLabelType}"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</layout>
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="app_name">library</string>
|
||||||
|
</resources>
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
include ':app'
|
include ':app', ':library'
|
||||||
|
|||||||
+1
-3
@@ -211,11 +211,9 @@ class Kapt3KotlinGradleSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
|||||||
|
|
||||||
val kaptExtension = project.extensions.getByType(KaptExtension::class.java)
|
val kaptExtension = project.extensions.getByType(KaptExtension::class.java)
|
||||||
|
|
||||||
val nonEmptyKaptConfigurations = kaptConfigurations.filter { it.dependencies.isNotEmpty() }
|
|
||||||
|
|
||||||
val context = Kapt3SubpluginContext(
|
val context = Kapt3SubpluginContext(
|
||||||
project, kotlinCompile, javaCompile,
|
project, kotlinCompile, javaCompile,
|
||||||
kaptVariantData, sourceSetName, kotlinCompilation, kaptExtension, nonEmptyKaptConfigurations
|
kaptVariantData, sourceSetName, kotlinCompilation, kaptExtension, kaptConfigurations
|
||||||
)
|
)
|
||||||
|
|
||||||
val kaptGenerateStubsTask = context.createKaptGenerateStubsTask()
|
val kaptGenerateStubsTask = context.createKaptGenerateStubsTask()
|
||||||
|
|||||||
Reference in New Issue
Block a user