Load Gradle subplugin artifacts from the root project buildscript classpath as well (KT-11885)
(cherry picked from commit b54b0da)
This commit is contained in:
+9
-2
@@ -495,8 +495,15 @@ private fun loadSubplugins(project: Project): SubpluginEnvironment {
|
||||
try {
|
||||
val subplugins = ServiceLoader.load(KotlinGradleSubplugin::class.java, project.buildscript.classLoader).toList()
|
||||
|
||||
val classpath = project.buildscript.configurations.getByName("classpath")
|
||||
val resolvedClasspathArtifacts = classpath.resolvedConfiguration.resolvedArtifacts.toList()
|
||||
fun Project.getResolvedArtifacts() = buildscript.configurations.getByName("classpath")
|
||||
.resolvedConfiguration.resolvedArtifacts
|
||||
|
||||
val resolvedClasspathArtifacts = project.getResolvedArtifacts().toMutableList()
|
||||
val rootProject = project.rootProject
|
||||
if (rootProject != project) {
|
||||
resolvedClasspathArtifacts += rootProject.getResolvedArtifacts()
|
||||
}
|
||||
|
||||
val subpluginClasspaths = hashMapOf<KotlinGradleSubplugin, List<File>>()
|
||||
|
||||
for (subplugin in subplugins) {
|
||||
|
||||
+10
@@ -151,4 +151,14 @@ fun getSomething() = 10
|
||||
assertCompiledKotlinSources(project.relativizeToSubproject("app", file))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAndroidExtensions() {
|
||||
val project = Project("AndroidExtensionsProject", gradleVersion)
|
||||
val options = defaultBuildOptions().copy(incremental = false)
|
||||
|
||||
project.build("assembleDebug", options = options) {
|
||||
assertSuccessful()
|
||||
}
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
apply plugin: 'android-sdk-manager'
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.1"
|
||||
|
||||
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 'com.android.support:appcompat-v7:23.1.1'
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
}
|
||||
+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>
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
class HomeActivity : Activity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
this.textView.setText("Hello, world!")
|
||||
}
|
||||
}
|
||||
+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>
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.1-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
maven { url 'file://' + pathToKotlinPlugin }
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "com.android.tools.build:gradle:$androidToolsVersion"
|
||||
classpath "com.jakewharton.sdkmanager:gradle-plugin:0.12.+"
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
maven { url 'file://' + pathToKotlinPlugin }
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
org.gradle.jvmargs=-ea -XX:MaxPermSize=512m
|
||||
+1
@@ -0,0 +1 @@
|
||||
include ':app'
|
||||
Reference in New Issue
Block a user