mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Move JarUtils to misc.
This commit is contained in:
parent
8fef0a5700
commit
fac616c235
5 changed files with 17 additions and 20 deletions
|
@ -9,8 +9,7 @@ import com.beust.kobalt.maven.LocalRepo
|
|||
import com.beust.kobalt.misc.KFiles
|
||||
import com.beust.kobalt.misc.KobaltExecutors
|
||||
import com.beust.kobalt.misc.log
|
||||
import com.beust.kobalt.plugin.KobaltPlugin
|
||||
import com.beust.kobalt.plugin.packaging.JarUtils
|
||||
import com.beust.kobalt.misc.JarUtils
|
||||
import com.google.inject.Provider
|
||||
import java.lang.reflect.Method
|
||||
import java.lang.reflect.Modifier
|
||||
|
@ -44,8 +43,6 @@ public class Plugins @Inject constructor (val taskManagerProvider : Provider<Tas
|
|||
internal val dynamicPlugins : ArrayList<IClasspathDependency> = arrayListOf()
|
||||
fun addDynamicPlugin(plugin: IClasspathDependency) = dynamicPlugins.add(plugin)
|
||||
|
||||
val defaultPlugin : IPlugin get() = findPlugin(KobaltPlugin.PLUGIN_NAME)!!
|
||||
|
||||
fun findPlugin(name: String) : IPlugin? = pluginMap[name]
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.beust.kobalt.internal.build
|
|||
|
||||
import com.beust.kobalt.KobaltException
|
||||
import com.beust.kobalt.Plugins
|
||||
import com.beust.kobalt.api.IPlugin
|
||||
import com.beust.kobalt.api.KobaltContext
|
||||
import com.beust.kobalt.api.Project
|
||||
import com.beust.kobalt.api.annotation.Task
|
||||
|
@ -9,6 +10,7 @@ import com.beust.kobalt.internal.TaskManager
|
|||
import com.beust.kobalt.misc.KFiles
|
||||
import com.beust.kobalt.misc.Topological
|
||||
import com.beust.kobalt.misc.log
|
||||
import com.beust.kobalt.plugin.KobaltPlugin
|
||||
import com.google.inject.Inject
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
|
@ -23,6 +25,8 @@ class BuildScriptUtil @Inject constructor(val plugins: Plugins, val files: KFile
|
|||
val taskManager: TaskManager) {
|
||||
val projects = arrayListOf<Project>()
|
||||
|
||||
val defaultPlugin : IPlugin get() = Plugins.findPlugin(KobaltPlugin.PLUGIN_NAME)!!
|
||||
|
||||
/**
|
||||
* Run the given preBuildScript (or buildScript) jar file, using a classloader made of the passed URL's.
|
||||
* This list is empty when we run preBuildScript.jar but for buildScript.jar, it contains the list of
|
||||
|
@ -82,8 +86,7 @@ class BuildScriptUtil @Inject constructor(val plugins: Plugins, val files: KFile
|
|||
} else {
|
||||
val taskAnnotation = method.getAnnotation(Task::class.java)
|
||||
if (taskAnnotation != null) {
|
||||
taskManager.staticTasks.add(TaskManager.StaticTask(Plugins.defaultPlugin,
|
||||
method, taskAnnotation))
|
||||
taskManager.staticTasks.add(TaskManager.StaticTask(defaultPlugin, method, taskAnnotation))
|
||||
}
|
||||
|
||||
}}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.beust.kobalt.plugin.packaging
|
||||
package com.beust.kobalt.misc
|
||||
|
||||
import com.beust.kobalt.IFileSpec
|
||||
import com.beust.kobalt.misc.KFiles
|
||||
import com.beust.kobalt.misc.log
|
||||
import com.beust.kobalt.plugin.packaging.Direction
|
||||
import com.beust.kobalt.plugin.packaging.IncludedFile
|
||||
import com.google.common.io.CharStreams
|
||||
import java.io.*
|
||||
import java.util.jar.JarEntry
|
||||
|
@ -119,11 +119,11 @@ public class JarUtils {
|
|||
}
|
||||
|
||||
fun extractJarFile(jarFile: File, destDir: File) {
|
||||
val jar = java.util.jar.JarFile(jarFile)
|
||||
val jar = JarFile(jarFile)
|
||||
val enumEntries = jar.entries()
|
||||
while (enumEntries.hasMoreElements()) {
|
||||
val file = enumEntries.nextElement()
|
||||
val f = File(destDir.path + java.io.File.separator + file.name)
|
||||
val f = File(destDir.path + File.separator + file.name)
|
||||
if (file.isDirectory) {
|
||||
f.mkdir()
|
||||
continue
|
||||
|
@ -141,3 +141,7 @@ public class JarUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
class From(override val p: String) : Direction(p)
|
||||
|
||||
class To(override val p: String) : Direction(p)
|
|
@ -10,7 +10,7 @@ import com.beust.kobalt.maven.dependency.FileDependency
|
|||
import com.beust.kobalt.maven.dependency.MavenDependency
|
||||
import com.beust.kobalt.misc.*
|
||||
import com.beust.kobalt.plugin.java.JavaCompiler
|
||||
import com.beust.kobalt.plugin.packaging.JarUtils
|
||||
import com.beust.kobalt.misc.JarUtils
|
||||
import com.google.common.collect.HashMultimap
|
||||
import com.google.inject.Inject
|
||||
import com.google.inject.Singleton
|
||||
|
|
|
@ -12,10 +12,7 @@ import com.beust.kobalt.glob
|
|||
import com.beust.kobalt.internal.JvmCompilerPlugin
|
||||
import com.beust.kobalt.maven.DependencyManager
|
||||
import com.beust.kobalt.maven.LocalRepo
|
||||
import com.beust.kobalt.misc.KFiles
|
||||
import com.beust.kobalt.misc.KobaltExecutors
|
||||
import com.beust.kobalt.misc.log
|
||||
import com.beust.kobalt.misc.toString
|
||||
import com.beust.kobalt.misc.*
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.OutputStream
|
||||
|
@ -418,10 +415,6 @@ open class Direction(open val p: String) {
|
|||
public val path: String get() = if (p.isEmpty() or p.endsWith("/")) p else p + "/"
|
||||
}
|
||||
|
||||
class From(override val p: String) : Direction(p)
|
||||
|
||||
class To(override val p: String) : Direction(p)
|
||||
|
||||
class IncludedFile(val fromOriginal: From, val toOriginal: To, val specs: List<IFileSpec>) {
|
||||
constructor(specs: List<IFileSpec>) : this(From(""), To(""), specs)
|
||||
public val from: String get() = fromOriginal.path.replace("\\", "/")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue