Merge remote-tracking branch 'origin/pr/292'
This commit is contained in:
+28
-25
@@ -1,29 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<root>
|
||||
<item name="org.gradle.api.NamedDomainObjectCollection T getByName(java.lang.String)">
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name="org.gradle.api.Plugin void apply(T)">
|
||||
<annotation name="jet.runtime.typeinfo.KotlinSignature">
|
||||
<val name="value" val=""fun apply(p0 : T) : Unit"" />
|
||||
</annotation>
|
||||
</item>
|
||||
<item name="org.gradle.api.Project org.gradle.api.file.ConfigurableFileCollection files(java.lang.Object...)">
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name="org.gradle.api.Project org.gradle.api.initialization.dsl.ScriptHandler getBuildscript()">
|
||||
<annotation name="jet.runtime.typeinfo.KotlinSignature">
|
||||
<val name="value" val=""fun getBuildscript() : ScriptHandler"" />
|
||||
</annotation>
|
||||
</item>
|
||||
<item name="org.gradle.api.Project org.gradle.api.logging.Logger getLogger()">
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name="org.gradle.api.Project org.gradle.api.plugins.Convention getConvention()">
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name="org.gradle.api.Project org.gradle.api.plugins.PluginContainer getPlugins()">
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name="org.gradle.api.NamedDomainObjectCollection T getByName(java.lang.String)">
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name="org.gradle.api.Plugin void apply(T)">
|
||||
<annotation name="jet.runtime.typeinfo.KotlinSignature">
|
||||
<val name="value" val=""fun apply(p0 : T) : Unit"" />
|
||||
</annotation>
|
||||
</item>
|
||||
<item name="org.gradle.api.Project org.gradle.api.file.ConfigurableFileCollection files(java.lang.Object...)">
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name="org.gradle.api.Project org.gradle.api.initialization.dsl.ScriptHandler getBuildscript()">
|
||||
<annotation name="jet.runtime.typeinfo.KotlinSignature">
|
||||
<val name="value" val=""fun getBuildscript() : ScriptHandler"" />
|
||||
</annotation>
|
||||
</item>
|
||||
<item name="org.gradle.api.Project org.gradle.api.logging.Logger getLogger()">
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name="org.gradle.api.Project org.gradle.api.plugins.Convention getConvention()">
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name='org.gradle.api.Project org.gradle.api.plugins.ExtensionContainer getExtensions()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name="org.gradle.api.Project org.gradle.api.plugins.PluginContainer getPlugins()">
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
</root>
|
||||
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<root>
|
||||
<item name='org.gradle.api.artifacts.Configuration org.gradle.api.artifacts.ResolvedConfiguration getResolvedConfiguration()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='org.gradle.api.artifacts.ConfigurationContainer org.gradle.api.artifacts.Configuration detachedConfiguration(org.gradle.api.artifacts.Dependency...)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
</root>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<root>
|
||||
<item name='org.gradle.api.artifacts.dsl.DependencyHandler org.gradle.api.artifacts.Dependency create(java.lang.Object)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
</root>
|
||||
+3
@@ -4,4 +4,7 @@
|
||||
<val name="value" val=""fun getConfigurations() : ConfigurationContainer""/>
|
||||
</annotation>
|
||||
</item>
|
||||
<item name='org.gradle.api.initialization.dsl.ScriptHandler org.gradle.api.artifacts.dsl.DependencyHandler getDependencies()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
</root>
|
||||
+29
@@ -33,6 +33,10 @@ import com.android.builder.model.BuildType
|
||||
import com.android.builder.BuilderConstants
|
||||
import com.android.build.gradle.api.TestVariant
|
||||
import org.gradle.api.plugins.JavaPlugin
|
||||
import org.gradle.api.artifacts.dsl.DependencyHandler
|
||||
import org.gradle.api.artifacts.ConfigurationContainer
|
||||
import org.gradle.api.artifacts.Dependency
|
||||
import java.util.HashSet
|
||||
|
||||
open class KotlinPlugin: Plugin<Project> {
|
||||
|
||||
@@ -44,6 +48,9 @@ open class KotlinPlugin: Plugin<Project> {
|
||||
|
||||
configureSourceSetDefaults(project as ProjectInternal, javaBasePlugin, javaPluginConvention)
|
||||
configureKDoc(project, javaPluginConvention)
|
||||
|
||||
val version = project.getProperties()!!.get("kotlin.gradle.plugin.version") as String
|
||||
project.getExtensions().add(KotlinCompile.DEFAULT_ANNOTATIONS, GradleUtils.resolveDependencies(project, "org.jetbrains.kotlin:kotlin-jdk-annotations:$version"))
|
||||
}
|
||||
|
||||
|
||||
@@ -159,6 +166,9 @@ open class KotlinAndroidPlugin: Plugin<Project> {
|
||||
}
|
||||
|
||||
})
|
||||
val version = project.getProperties()!!.get("kotlin.gradle.plugin.version") as String
|
||||
project.getExtensions().add(KotlinCompile.DEFAULT_ANNOTATIONS, GradleUtils.resolveDependencies(project, "org.jetbrains.kotlin:kotlin-jdk-annotations:$version",
|
||||
"org.jetbrains.kotlin:kotlin-android-sdk-annotations:$version"));
|
||||
}
|
||||
|
||||
private fun processVariants(variants: DefaultDomainObjectSet<out BaseVariant>, project: Project, androidExt: BaseExtension): Unit {
|
||||
@@ -258,3 +268,22 @@ open class KSpec<T: Any?>(val predicate: (T) -> Boolean): Spec<T> {
|
||||
return p0 != null && predicate(p0)
|
||||
}
|
||||
}
|
||||
|
||||
open class GradleUtils() {
|
||||
class object {
|
||||
public fun resolveDependencies(project: Project, vararg coordinates: String): Collection<File> {
|
||||
val dependencyHandler : DependencyHandler = project.getBuildscript().getDependencies()
|
||||
val configurationsContainer : ConfigurationContainer = project.getBuildscript().getConfigurations()
|
||||
|
||||
val deps = HashSet<Dependency>()
|
||||
for (coordinate in coordinates) {
|
||||
deps.add(dependencyHandler.create(coordinate))
|
||||
}
|
||||
val array : Array<Dependency?> = deps.toArray(Array<Dependency?>(deps.size(),{null}))
|
||||
val configuration = configurationsContainer.detachedConfiguration(*array)
|
||||
|
||||
return configuration.getResolvedConfiguration().getFiles(KSpec({ dep -> true }))!!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-12
@@ -27,6 +27,10 @@ import org.apache.commons.io.FileUtils
|
||||
|
||||
public open class KotlinCompile(): AbstractCompile() {
|
||||
|
||||
class object {
|
||||
val DEFAULT_ANNOTATIONS = "org.jebrains.kotlin.gradle.defaultAnnotations"
|
||||
}
|
||||
|
||||
val srcDirsRoots = HashSet<File>()
|
||||
val compiler = K2JVMCompiler()
|
||||
val logger = Logging.getLogger(getClass())
|
||||
@@ -105,7 +109,7 @@ public open class KotlinCompile(): AbstractCompile() {
|
||||
|
||||
val embeddedAnnotations = getAnnotations()
|
||||
val userAnnotations = (kotlinOptions.annotations ?: "").split(File.pathSeparatorChar).toList()
|
||||
val allAnnotations = if (kotlinOptions.noJdkAnnotations) userAnnotations else userAnnotations.plus(embeddedAnnotations.getPath())
|
||||
val allAnnotations = if (kotlinOptions.noJdkAnnotations) userAnnotations else userAnnotations.plus(embeddedAnnotations.map {it.getPath()})
|
||||
args.annotations = allAnnotations.makeString(File.pathSeparator)
|
||||
|
||||
args.noStdlib = true
|
||||
@@ -124,19 +128,14 @@ public open class KotlinCompile(): AbstractCompile() {
|
||||
FileUtils.copyDirectory(kotlinDestinationDir, getDestinationDir())
|
||||
}
|
||||
|
||||
fun getAnnotations(): File {
|
||||
val configuration = getProject()
|
||||
.getBuildscript()
|
||||
.getConfigurations()
|
||||
.getByName(ScriptHandler.CLASSPATH_CONFIGURATION)!!
|
||||
fun getAnnotations(): Collection<File> {
|
||||
val annotations = getProject().getExtensions().getByName(DEFAULT_ANNOTATIONS) as Collection<File>
|
||||
|
||||
val jdkAnnotationsFromClasspath = configuration.find { it.name.startsWith("kotlin-jdk-annotations") }
|
||||
|
||||
if (jdkAnnotationsFromClasspath != null) {
|
||||
logger.info("using jdk annontations from [${jdkAnnotationsFromClasspath.getAbsolutePath()}]")
|
||||
return jdkAnnotationsFromClasspath
|
||||
if (!annotations.isEmpty()) {
|
||||
logger.info("using default annontations from [${annotations.map {it.getPath()}}]")
|
||||
return annotations
|
||||
} else {
|
||||
throw GradleException("kotlin-jdk-annotations not found in Kotlin gradle plugin classpath")
|
||||
throw GradleException("Default annotations not found in Kotlin gradle plugin classpath")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -30,11 +30,12 @@ class BasicKotlinGradleIT {
|
||||
Test fun testSimpleCompile() {
|
||||
val projectDir = File(workingDir, "alfa")
|
||||
|
||||
val pathToKotlinPlugin = "-PpathToKotlinPlugin=" + File("local-repo").getAbsolutePath()
|
||||
val pathToKotlinPlugin = "-PpathToKotlinPlugin=${File("local-repo").getAbsolutePath()}"
|
||||
val version = "-Pkotlin.gradle.plugin.version=0.1-SNAPSHOT"
|
||||
val cmd = if (SystemInfo.isWindows)
|
||||
listOf("cmd", "/C", "gradlew.bat", "compileDeployKotlin", "build", pathToKotlinPlugin, "--no-daemon", "--debug")
|
||||
listOf("cmd", "/C", "gradlew.bat", "compileDeployKotlin", "build", pathToKotlinPlugin, version, "--no-daemon", "--debug")
|
||||
else
|
||||
listOf("/bin/bash", "./gradlew", "compileDeployKotlin", "build", pathToKotlinPlugin, "--no-daemon", "--debug")
|
||||
listOf("/bin/bash", "./gradlew", "compileDeployKotlin", "build", pathToKotlinPlugin, version, "--no-daemon", "--debug")
|
||||
|
||||
val builder = ProcessBuilder(cmd)
|
||||
builder.directory(projectDir)
|
||||
|
||||
Reference in New Issue
Block a user