add kotlin gradle plugin integration
This commit is contained in:
+1
-1
@@ -103,7 +103,7 @@ abstract class AndroidUIXmlProcessor(val project: Project) {
|
|||||||
|
|
||||||
private fun writeImports(kw: KotlinStringWriter): KotlinWriter {
|
private fun writeImports(kw: KotlinStringWriter): KotlinWriter {
|
||||||
kw.writePackage(androidAppPackage)
|
kw.writePackage(androidAppPackage)
|
||||||
if (ApplicationManager.getApplication()?.isUnitTestMode() ?: false) return kw
|
// if (ApplicationManager.getApplication()?.isUnitTestMode() ?: false) return kw
|
||||||
for (elem in androidImports)
|
for (elem in androidImports)
|
||||||
kw.writeImport(elem)
|
kw.writeImport(elem)
|
||||||
kw.writeEmptyLine()
|
kw.writeEmptyLine()
|
||||||
|
|||||||
+38
-1
@@ -46,6 +46,41 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractCo
|
|||||||
private val logger = Logging.getLogger(this.javaClass)
|
private val logger = Logging.getLogger(this.javaClass)
|
||||||
override fun getLogger() = logger
|
override fun getLogger() = logger
|
||||||
|
|
||||||
|
public var resPath: String = ""
|
||||||
|
public var manifestPath: String = ""
|
||||||
|
|
||||||
|
// override setSource to track source directory sets
|
||||||
|
override fun setSource(source: Any?) {
|
||||||
|
srcDirsSources.clear()
|
||||||
|
if (source is SourceDirectorySet) {
|
||||||
|
srcDirsSources.add(source)
|
||||||
|
}
|
||||||
|
super.setSource(source)
|
||||||
|
}
|
||||||
|
|
||||||
|
// override source to track source directory sets
|
||||||
|
override fun source(vararg sources: Any?): SourceTask? {
|
||||||
|
for (source in sources) {
|
||||||
|
if (source is SourceDirectorySet) {
|
||||||
|
srcDirsSources.add(source)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.source(sources)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun findSrcDirRoot(file: File): File? {
|
||||||
|
val absPath = file.getAbsolutePath()
|
||||||
|
for (source in srcDirsSources) {
|
||||||
|
for (root in source.getSrcDirs()) {
|
||||||
|
val rootAbsPath = root.getAbsolutePath()
|
||||||
|
if (FilenameUtils.directoryContains(rootAbsPath, absPath)) {
|
||||||
|
return root
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
[TaskAction]
|
[TaskAction]
|
||||||
override fun compile() {
|
override fun compile() {
|
||||||
getLogger().debug("Starting ${javaClass} task")
|
getLogger().debug("Starting ${javaClass} task")
|
||||||
@@ -75,7 +110,6 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractCo
|
|||||||
args.noInline = kotlinOptions.noInline
|
args.noInline = kotlinOptions.noInline
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun callCompiler(args: T) {
|
private fun callCompiler(args: T) {
|
||||||
val messageCollector = GradleMessageCollector(getLogger())
|
val messageCollector = GradleMessageCollector(getLogger())
|
||||||
getLogger().debug("Calling compiler")
|
getLogger().debug("Calling compiler")
|
||||||
@@ -97,6 +131,9 @@ public open class KotlinCompile() : AbstractKotlinCompile<K2JVMCompilerArguments
|
|||||||
val srcDirsSources = HashSet<SourceDirectorySet>()
|
val srcDirsSources = HashSet<SourceDirectorySet>()
|
||||||
|
|
||||||
override fun populateTargetSpecificArgs(args: K2JVMCompilerArguments) {
|
override fun populateTargetSpecificArgs(args: K2JVMCompilerArguments) {
|
||||||
|
args.androidRes = resPath
|
||||||
|
args.androidManifest = manifestPath
|
||||||
|
|
||||||
if (StringUtils.isEmpty(kotlinOptions.classpath)) {
|
if (StringUtils.isEmpty(kotlinOptions.classpath)) {
|
||||||
val existingClasspathEntries = getClasspath().filter({ it != null && it.exists() })
|
val existingClasspathEntries = getClasspath().filter({ it != null && it.exists() })
|
||||||
val effectiveClassPath = (getJavaSourceRoots() + existingClasspathEntries).makeString(File.pathSeparator)
|
val effectiveClassPath = (getJavaSourceRoots() + existingClasspathEntries).makeString(File.pathSeparator)
|
||||||
|
|||||||
+3
@@ -338,6 +338,9 @@ open class KotlinAndroidPlugin [Inject] (val scriptHandler: ScriptHandler, val t
|
|||||||
kotlinTask.setClasspath(javaTask.getClasspath())
|
kotlinTask.setClasspath(javaTask.getClasspath())
|
||||||
kotlinTask.setDependsOn(javaTask.getDependsOn())
|
kotlinTask.setDependsOn(javaTask.getDependsOn())
|
||||||
|
|
||||||
|
kotlinTask.resPath = File(variant.getMergeResources()?.getOutputDir()!!.canonicalPath + "/layout").canonicalPath
|
||||||
|
kotlinTask.manifestPath = variant.getProcessResources().getManifestFile()!!.canonicalPath
|
||||||
|
|
||||||
val javaSourceList = ArrayList<Any?>()
|
val javaSourceList = ArrayList<Any?>()
|
||||||
|
|
||||||
fun processSourceSet(javaSourceSet: AndroidSourceSet) {
|
fun processSourceSet(javaSourceSet: AndroidSourceSet) {
|
||||||
|
|||||||
Reference in New Issue
Block a user