1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Remove GroovyPlugin.

This commit is contained in:
Cedric Beust 2016-06-24 01:59:20 -08:00
parent d56196a42f
commit e9cbe04317
2 changed files with 0 additions and 59 deletions

View file

@ -1,58 +0,0 @@
package com.beust.kobalt.plugin.groovy
import com.beust.kobalt.TaskResult
import com.beust.kobalt.api.*
import com.beust.kobalt.maven.DependencyManager
import com.beust.kobalt.misc.KFiles
import com.beust.kobalt.misc.Strings
import com.beust.kobalt.misc.log
import com.google.inject.Inject
import com.google.inject.Singleton
import java.io.File
import java.net.URLClassLoader
@Singleton
class GroovyPlugin @Inject constructor(val groovyCompiler: GroovyCompiler) : ICompilerContributor {
override fun affinity(project: Project, context: KobaltContext) =
if (hasSourceFiles(project)) 1 else 0
// ICompilerContributor
val compiler = CompilerDescription(GroovyCompiler.SUFFIXES, "groovy", groovyCompiler)
override fun compilersFor(project: Project, context: KobaltContext) = listOf(compiler)
private fun hasSourceFiles(project: Project)
= KFiles.findSourceFiles(project.directory, project.sourceDirectories, GroovyCompiler.SUFFIXES).size > 0
}
class GroovyCompiler @Inject constructor(dependencyManager: DependencyManager) : ICompiler {
companion object {
val SUFFIXES = listOf("groovy")
}
private val groovyCompilerClass: Class<*> by lazy {
val jarFile = dependencyManager.create("org.codehaus.groovy:groovy:2.4.7").jarFile.get()
val classLoader = URLClassLoader(arrayOf(jarFile.toURI().toURL()))
classLoader.loadClass("org.codehaus.groovy.tools.FileSystemCompiler")
}
private fun invokeGroovyCompiler(info: CompilerActionInfo) : TaskResult {
val cls = groovyCompilerClass
val main = cls.getMethod("commandLineCompile", Array<String>::class.java)
val classpath = info.dependencies.map { it.jarFile.get() }.joinToString(File.pathSeparator)
try {
main.invoke(null, arrayOf("-classpath", classpath, "-d", info.outputDir.path,
*info.sourceFiles.toTypedArray()))
return TaskResult()
} catch(ex: Exception) {
return TaskResult(success = false, errorMessage = ex.cause.toString())
}
}
override fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo): TaskResult {
val size = info.sourceFiles.size
log(1, "Groovy compiling " + size + " " + Strings.pluralize(size, "file"))
val result = invokeGroovyCompiler(info)
return result
}
}

View file

@ -13,7 +13,6 @@
<class-name>com.beust.kobalt.plugin.publish.PublishPlugin</class-name>
<class-name>com.beust.kobalt.plugin.apt.AptPlugin</class-name>
<class-name>com.beust.kobalt.internal.JvmCompilerPlugin</class-name>
<class-name>com.beust.kobalt.plugin.groovy.GroovyPlugin</class-name>
<!-- These classes manage -init for Java and Kotlin -->
<class-name>com.beust.kobalt.app.Templates</class-name>