Android Extensions: Allow to disable specific features of Android Extensions (#KT-23244)
This commit is contained in:
+29
@@ -331,6 +331,11 @@ fun getSomething() = 10
|
||||
|
||||
@Test
|
||||
fun testAndroidExtensionsManyVariants() {
|
||||
if (isLegacyAndroidGradleVersion(androidGradlePluginVersion)) {
|
||||
// Library dependencies are not supported in older versions of Android Gradle plugin (< 3.0)
|
||||
return
|
||||
}
|
||||
|
||||
val project = Project("AndroidExtensionsManyVariants", gradleVersion)
|
||||
val options = defaultBuildOptions().copy(incremental = false)
|
||||
|
||||
@@ -346,6 +351,30 @@ fun getSomething() = 10
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAndroidExtensionsSpecificFeatures() {
|
||||
val project = Project("AndroidExtensionsSpecificFeatures", gradleVersion)
|
||||
val options = defaultBuildOptions().copy(incremental = false)
|
||||
|
||||
project.build("assemble", options = options) {
|
||||
assertFailed()
|
||||
assertContains("Unresolved reference: textView")
|
||||
}
|
||||
|
||||
File(project.projectDir, "app/build.gradle").modify { it.replace("[\"parcelize\"]", "[\"views\"]") }
|
||||
|
||||
project.build("assemble", options = options) {
|
||||
assertFailed()
|
||||
assertContains("Class 'User' is not abstract and does not implement abstract member public abstract fun writeToParcel")
|
||||
}
|
||||
|
||||
File(project.projectDir, "app/build.gradle").modify { it.replace("[\"views\"]", "[\"parcelize\", \"views\"]") }
|
||||
|
||||
project.build("assemble", options = options) {
|
||||
assertSuccessful()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMultiplatformAndroidCompile() = with(Project("multiplatformAndroidProject", gradleVersion)) {
|
||||
setupWorkingDir()
|
||||
|
||||
+1
@@ -36,6 +36,7 @@ android {
|
||||
|
||||
androidExtensions {
|
||||
experimental = true
|
||||
features = ["views", "parcelize"]
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
+5
@@ -4,6 +4,8 @@ import android.app.Activity
|
||||
import android.os.Bundle
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.layout_in_library.text_view
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
import android.os.Parcelable
|
||||
|
||||
class MainActivity : Activity() {
|
||||
override fun onCreate(savedInstanceState: Bundle) {
|
||||
@@ -13,3 +15,6 @@ class MainActivity : Activity() {
|
||||
text_view
|
||||
}
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
class User(val firstName: String, val lastName: String) : Parcelable
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "25.0.2"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.example.dagger.kotlin"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 23
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
}
|
||||
|
||||
androidExtensions {
|
||||
experimental = true
|
||||
features = ["parcelize"]
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.androidextensions">
|
||||
|
||||
<application android:label="app_name">
|
||||
<activity
|
||||
android:label="app_name"
|
||||
android:name="com.example.androidextensions.MyActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.example.androidextensions
|
||||
|
||||
import android.os.Bundle
|
||||
import android.app.Activity
|
||||
import kotlinx.android.synthetic.main.activity_main.textView
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
import android.os.Parcelable
|
||||
|
||||
class HomeActivity : Activity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
this.textView.setText("Hello, world!")
|
||||
}
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
class User(val firstName: String, val lastName: String) : Parcelable
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</RelativeLayout>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">kotlin</string>
|
||||
</resources>
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
maven { url 'https://maven.google.com' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "com.android.tools.build:gradle:$android_tools_version"
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
maven { url 'https://maven.google.com' }
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
org.gradle.jvmargs=-ea -XX:MaxPermSize=512m
|
||||
Reference in New Issue
Block a user