Use Gradle properties to pass plugin-related arguments
This commit is contained in:
+2
-5
@@ -47,9 +47,6 @@ 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
|
||||||
|
|
||||||
var compilerPluginClasspaths: Array<String> = array()
|
|
||||||
var compilerPluginArguments: Array<String> = array()
|
|
||||||
|
|
||||||
[TaskAction]
|
[TaskAction]
|
||||||
override fun compile() {
|
override fun compile() {
|
||||||
getLogger().debug("Starting ${javaClass} task")
|
getLogger().debug("Starting ${javaClass} task")
|
||||||
@@ -104,8 +101,8 @@ 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.pluginClasspaths = compilerPluginClasspaths
|
args.pluginClasspaths = property("compilerPluginClasspaths") as? Array<String>
|
||||||
args.pluginOptions = compilerPluginArguments
|
args.pluginOptions = property("compilerPluginArguments") as? Array<String>
|
||||||
|
|
||||||
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() })
|
||||||
|
|||||||
+6
-11
@@ -451,30 +451,25 @@ private class SubpluginEnvironment(
|
|||||||
val subplugins: List<KotlinGradleSubplugin>
|
val subplugins: List<KotlinGradleSubplugin>
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private fun AbstractCompile.setKotlinTaskProperty(methodName: String, value: Array<String>) {
|
|
||||||
val function = javaClass.getMethod(methodName, javaClass<Array<String>>())
|
|
||||||
function.invoke(this, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun addSubpluginArguments(project: Project, compileTask: AbstractCompile) {
|
fun addSubpluginArguments(project: Project, compileTask: AbstractCompile) {
|
||||||
val realPluginClasspaths = arrayListOf<String>()
|
val realPluginClasspaths = arrayListOf<String>()
|
||||||
val pluginArguments = arrayListOf<String>()
|
val pluginArguments = arrayListOf<String>()
|
||||||
|
fun getPluginOptionString(pluginId: String, key: String, value: String) = "plugin:$pluginId:$key=$value"
|
||||||
|
|
||||||
subplugins.forEach { subplugin ->
|
subplugins.forEach { subplugin ->
|
||||||
val args = subplugin.getExtraArguments(project, compileTask)
|
val args = subplugin.getExtraArguments(project, compileTask)
|
||||||
if (args != null) {
|
val subpluginClasspath = subpluginClasspaths[subplugin]
|
||||||
realPluginClasspaths.addAll(subpluginClasspaths[subplugin])
|
if (args != null && subpluginClasspath != null) {
|
||||||
|
realPluginClasspaths.addAll(subpluginClasspath)
|
||||||
for (arg in args) {
|
for (arg in args) {
|
||||||
//TODO: fix (getPluginOptionString is in plugin-api)
|
|
||||||
fun getPluginOptionString(pluginId: String, key: String, value: String) = "plugin:$pluginId:$key=$value"
|
|
||||||
val option = getPluginOptionString(subplugin.getPluginName(), arg.key, arg.value)
|
val option = getPluginOptionString(subplugin.getPluginName(), arg.key, arg.value)
|
||||||
pluginArguments.add(option)
|
pluginArguments.add(option)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
compileTask.setKotlinTaskProperty("setCompilerPluginClasspaths", realPluginClasspaths.copyToArray())
|
compileTask.setProperty("compilerPluginClasspaths", realPluginClasspaths.copyToArray())
|
||||||
compileTask.setKotlinTaskProperty("setCompilerPluginArguments", pluginArguments.copyToArray())
|
compileTask.setProperty("compilerPluginArguments", pluginArguments.copyToArray())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user