Kapt3: Clear javac's boot classpath (KT-15001)
This commit is contained in:
committed by
Yan Zhulanow
parent
ada8bb63a4
commit
5f0d270e9e
+11
@@ -159,6 +159,17 @@ class Kapt3IT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testKt15001() {
|
||||
val project = Project("kt15001", GRADLE_VERSION, directoryPrefix = "kapt2")
|
||||
val options = androidBuildOptions()
|
||||
|
||||
project.build("compileReleaseSources", options = options) {
|
||||
assertSuccessful()
|
||||
assertKaptSuccessful()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDbFlow() {
|
||||
val project = Project("android-dbflow", GRADLE_VERSION, directoryPrefix = "kapt2")
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
apply plugin: 'android-sdk-manager'
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.1"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.example.kt15001"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 23
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
|
||||
compile 'com.google.dagger:dagger:2.8'
|
||||
kapt 'com.google.dagger:dagger-compiler:2.8'
|
||||
|
||||
compile 'com.android.support:appcompat-v7:23.3.0'
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /Users/bradcampbell/Library/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.kt15001">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.example.kt15001
|
||||
|
||||
import android.content.Context
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import javax.inject.Inject
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
@Inject lateinit var context: Context
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.example.kt15001
|
||||
|
||||
import dagger.Component
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
@Component(modules = arrayOf(MyModule::class))
|
||||
interface MyComponent {
|
||||
fun inject(activity: MainActivity)
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.example.kt15001
|
||||
|
||||
import android.content.Context
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
class MyModule(private val context: Context) {
|
||||
@Provides @Singleton fun provideContext() = context
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return super.hashCode()
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/activity_main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context="com.example.bradcampbell.kapt2daggerbug.MainActivity"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!"
|
||||
/>
|
||||
</RelativeLayout>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<resources>
|
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
</resources>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#3F51B5</color>
|
||||
<color name="colorPrimaryDark">#303F9F</color>
|
||||
<color name="colorAccent">#FF4081</color>
|
||||
</resources>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
</resources>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">Kapt2DaggerBug</string>
|
||||
</resources>
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = "0.1-SNAPSHOT"
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.5.+'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "com.jakewharton.sdkmanager:gradle-plugin:0.12.+"
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
kapt.verbose=true
|
||||
+1
@@ -0,0 +1 @@
|
||||
include ':app'
|
||||
@@ -37,10 +37,16 @@ fun KaptContext.doAnnotationProcessing(
|
||||
annotationProcessingClasspath: List<File>,
|
||||
sourcesOutputDir: File,
|
||||
classesOutputDir: File,
|
||||
additionalSources: JavacList<JCTree.JCCompilationUnit> = JavacList.nil()
|
||||
additionalSources: JavacList<JCTree.JCCompilationUnit> = JavacList.nil(),
|
||||
withJdk: Boolean = false
|
||||
) {
|
||||
with (options) {
|
||||
put(Option.PROC, "only") // Only process annotations
|
||||
|
||||
if (!withJdk) {
|
||||
put(Option.BOOTCLASSPATH, "") // No boot classpath
|
||||
}
|
||||
|
||||
put(Option.CLASSPATH, compileClasspath.joinToString(File.pathSeparator) { it.canonicalPath })
|
||||
put(Option.PROCESSORPATH, annotationProcessingClasspath.joinToString(File.pathSeparator) { it.canonicalPath })
|
||||
put(Option.S, sourcesOutputDir.canonicalPath)
|
||||
|
||||
+2
-1
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.util.trimTrailingWhitespacesAndAddNewlineAtEOF
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import javax.annotation.processing.Completion
|
||||
@@ -139,7 +140,7 @@ abstract class AbstractKotlinKapt3IntegrationTest : CodegenTestCase() {
|
||||
javaSourceRoots: List<File>,
|
||||
outputDir: File,
|
||||
options: Map<String, String>
|
||||
) : AbstractKapt3Extension(emptyList(), emptyList(), javaSourceRoots, outputDir, outputDir,
|
||||
) : AbstractKapt3Extension(PathUtil.getJdkClassesRoots(), emptyList(), javaSourceRoots, outputDir, outputDir,
|
||||
options, true, System.currentTimeMillis(), KaptLogger(true)
|
||||
) {
|
||||
internal var savedStubs: String? = null
|
||||
|
||||
@@ -102,7 +102,7 @@ abstract class AbstractKotlinKaptContextTest : AbstractKotlinKapt3Test() {
|
||||
kaptRunner.doAnnotationProcessing(emptyList(), listOf(JavaKaptContextTest.simpleProcessor()),
|
||||
compileClasspath = emptyList(), annotationProcessingClasspath = emptyList(),
|
||||
sourcesOutputDir = sourceOutputDir, classesOutputDir = sourceOutputDir,
|
||||
additionalSources = compilationUnits)
|
||||
additionalSources = compilationUnits, withJdk = true)
|
||||
|
||||
val javaFiles = sourceOutputDir.walkTopDown().filter { it.isFile && it.extension == "java" }
|
||||
val actualRaw = javaFiles.sortedBy { it.name }.joinToString(FILE_SEPARATOR) { it.name + ":\n\n" + it.readText() }
|
||||
|
||||
@@ -85,7 +85,8 @@ class JavaKaptContextTest {
|
||||
emptyList(), // compile classpath
|
||||
emptyList(), // annotation processing classpath
|
||||
outputDir,
|
||||
outputDir)
|
||||
outputDir,
|
||||
withJdk = true)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user