diff --git a/src/main/kotlin/com/beust/kobalt/plugin/groovy/GroovyPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/groovy/GroovyPlugin.kt deleted file mode 100644 index 2d7122b6..00000000 --- a/src/main/kotlin/com/beust/kobalt/plugin/groovy/GroovyPlugin.kt +++ /dev/null @@ -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::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 - } -} diff --git a/src/main/resources/META-INF/kobalt-core-plugin.xml b/src/main/resources/META-INF/kobalt-core-plugin.xml index 4824d5cf..3186b3f5 100644 --- a/src/main/resources/META-INF/kobalt-core-plugin.xml +++ b/src/main/resources/META-INF/kobalt-core-plugin.xml @@ -13,7 +13,6 @@ com.beust.kobalt.plugin.publish.PublishPlugin com.beust.kobalt.plugin.apt.AptPlugin com.beust.kobalt.internal.JvmCompilerPlugin - com.beust.kobalt.plugin.groovy.GroovyPlugin com.beust.kobalt.app.Templates