mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Move classes to the app package.
This commit is contained in:
parent
fac616c235
commit
259d4a3cba
10 changed files with 18 additions and 179 deletions
|
@ -5,6 +5,9 @@ import com.beust.kobalt.api.IClasspathDependency
|
||||||
import com.beust.kobalt.api.Kobalt
|
import com.beust.kobalt.api.Kobalt
|
||||||
import com.beust.kobalt.api.PluginTask
|
import com.beust.kobalt.api.PluginTask
|
||||||
import com.beust.kobalt.api.Project
|
import com.beust.kobalt.api.Project
|
||||||
|
import com.beust.kobalt.Args
|
||||||
|
import com.beust.kobalt.app.ProjectGenerator
|
||||||
|
import com.beust.kobalt.app.UpdateKobalt
|
||||||
import com.beust.kobalt.internal.PluginInfo
|
import com.beust.kobalt.internal.PluginInfo
|
||||||
import com.beust.kobalt.internal.TaskManager
|
import com.beust.kobalt.internal.TaskManager
|
||||||
import com.beust.kobalt.internal.build.BuildFile
|
import com.beust.kobalt.internal.build.BuildFile
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.beust.kobalt.wrapper
|
package com.beust.kobalt.app
|
||||||
|
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.net.URLClassLoader
|
import java.net.URLClassLoader
|
||||||
|
@ -15,7 +15,7 @@ public class ParentLastClassLoader(val classpath: List<URL>)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val urls : Array<URL> = classpath.toTypedArray()
|
val urls : Array<URL> = classpath.toTypedArray()
|
||||||
childClassLoader = ChildURLClassLoader(urls, FindClassClassLoader(this.parent) )
|
childClassLoader = ChildURLClassLoader(urls, FindClassClassLoader(this.parent))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -1,5 +1,6 @@
|
||||||
package com.beust.kobalt
|
package com.beust.kobalt.app
|
||||||
|
|
||||||
|
import com.beust.kobalt.Args
|
||||||
import com.beust.kobalt.internal.ActorUtils
|
import com.beust.kobalt.internal.ActorUtils
|
||||||
import com.beust.kobalt.internal.PluginInfo
|
import com.beust.kobalt.internal.PluginInfo
|
||||||
import com.beust.kobalt.misc.log
|
import com.beust.kobalt.misc.log
|
|
@ -1,5 +1,8 @@
|
||||||
package com.beust.kobalt.misc
|
package com.beust.kobalt.app
|
||||||
|
|
||||||
|
import com.beust.kobalt.misc.GithubApi
|
||||||
|
import com.beust.kobalt.misc.KobaltWrapperProperties
|
||||||
|
import com.beust.kobalt.wrapper.Main
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,13 +12,13 @@ public class UpdateKobalt @Inject constructor(val github: GithubApi, val wrapper
|
||||||
fun updateKobalt() {
|
fun updateKobalt() {
|
||||||
val newVersion = github.latestKobaltVersion
|
val newVersion = github.latestKobaltVersion
|
||||||
wrapperProperties.create(newVersion.get())
|
wrapperProperties.create(newVersion.get())
|
||||||
com.beust.kobalt.wrapper.Main.main(arrayOf())
|
Main.main(arrayOf())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download from the URL found in the kobalt-wrapper.properties regardless of what the latest version is
|
* Download from the URL found in the kobalt-wrapper.properties regardless of what the latest version is
|
||||||
*/
|
*/
|
||||||
fun downloadKobalt() {
|
fun downloadKobalt() {
|
||||||
com.beust.kobalt.wrapper.Main.main(arrayOf("--download", "--no-launch"))
|
Main.main(arrayOf("--download", "--no-launch"))
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package com.beust.kobalt.internal
|
package com.beust.kobalt.internal
|
||||||
|
|
||||||
import com.beust.kobalt.ProjectGenerator
|
import com.beust.kobalt.app.ProjectGenerator
|
||||||
import com.beust.kobalt.api.IInitContributor
|
import com.beust.kobalt.api.IInitContributor
|
||||||
import com.beust.kobalt.maven.Pom
|
import com.beust.kobalt.maven.Pom
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.KFiles
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.beust.kobalt.api.IPlugin
|
||||||
import com.beust.kobalt.api.PluginTask
|
import com.beust.kobalt.api.PluginTask
|
||||||
import com.beust.kobalt.api.Project
|
import com.beust.kobalt.api.Project
|
||||||
import com.beust.kobalt.api.annotation.Task
|
import com.beust.kobalt.api.annotation.Task
|
||||||
|
import com.beust.kobalt.Args
|
||||||
import com.beust.kobalt.misc.log
|
import com.beust.kobalt.misc.log
|
||||||
import com.google.common.collect.ArrayListMultimap
|
import com.google.common.collect.ArrayListMultimap
|
||||||
import com.google.common.collect.Multimap
|
import com.google.common.collect.Multimap
|
||||||
|
|
|
@ -11,7 +11,7 @@ import com.beust.kobalt.maven.dependency.FileDependency
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.KFiles
|
||||||
import com.beust.kobalt.misc.KobaltExecutors
|
import com.beust.kobalt.misc.KobaltExecutors
|
||||||
import com.beust.kobalt.misc.log
|
import com.beust.kobalt.misc.log
|
||||||
import com.beust.kobalt.wrapper.ParentLastClassLoader
|
import com.beust.kobalt.app.ParentLastClassLoader
|
||||||
import org.jetbrains.kotlin.cli.common.CLICompiler
|
import org.jetbrains.kotlin.cli.common.CLICompiler
|
||||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||||
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
|
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
|
||||||
|
|
|
@ -1,170 +0,0 @@
|
||||||
package com.beust.kobalt.wrapper
|
|
||||||
|
|
||||||
//public fun main(argv: Array<String>) {
|
|
||||||
// Kobalt.INJECTOR.getInstance(Wrapper::class.java).installAndLaunchMain(argv)
|
|
||||||
//}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Download and install a new wrapper if requested.
|
|
||||||
*/
|
|
||||||
//public class Wrapper @Inject constructor(val wrapperProperties: KobaltWrapperProperties){
|
|
||||||
// // kobalt.properties
|
|
||||||
// private val KOBALT_PROPERTIES = "kobalt.properties"
|
|
||||||
// private val KOBALTW = "kobaltw"
|
|
||||||
//
|
|
||||||
// val FILE_NAME = "kobalt"
|
|
||||||
//
|
|
||||||
// private val properties = Properties()
|
|
||||||
//
|
|
||||||
// public fun installAndLaunchMain(argv: Array<String>) {
|
|
||||||
// val kobaltJarFile = install()
|
|
||||||
// launchMain(kobaltJarFile, argv)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private fun readProperties(properties: Properties, ins: InputStream) {
|
|
||||||
// properties.load(ins)
|
|
||||||
// ins.close()
|
|
||||||
// properties.forEach { es -> System.setProperty(es.key.toString(), es.value.toString()) }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Attemps to read kobalt.properties (which should always exist).
|
|
||||||
// */
|
|
||||||
// private fun maybeCreateKobaltProperties() : Properties {
|
|
||||||
// val result = Properties()
|
|
||||||
//
|
|
||||||
// // kobalt.properties is internal to Kobalt
|
|
||||||
// val url = javaClass.classLoader.getResource(KOBALT_PROPERTIES)
|
|
||||||
// if (url != null) {
|
|
||||||
// readProperties(result, url.openConnection().inputStream)
|
|
||||||
// } else {
|
|
||||||
// throw IllegalArgumentException("Couldn't find $KOBALT_PROPERTIES")
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return result
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//// private fun initWrapperFile(version: String) {
|
|
||||||
//// val config = wrapperProperties.file
|
|
||||||
//// if (! config.exists()) {
|
|
||||||
//// wrapperProperties.create(version)
|
|
||||||
//// }
|
|
||||||
//// properties.load(FileReader(config))
|
|
||||||
//// }
|
|
||||||
////
|
|
||||||
//// private val wrapperVersion : String
|
|
||||||
//// get() {
|
|
||||||
//// return properties.getProperty(PROPERTY_VERSION)
|
|
||||||
//// }
|
|
||||||
////
|
|
||||||
//// private val wrapperDownloadUrl : String
|
|
||||||
//// get() {
|
|
||||||
//// return properties.getProperty(PROPERTY_DOWNLOAD_URL)
|
|
||||||
//// }
|
|
||||||
////
|
|
||||||
//// fun urlFor(version: String) : String {
|
|
||||||
//// // val URL = "https://dl.bintray.com/cbeust/generic/"
|
|
||||||
//// // return "https://dl.bintray.com/cbeust/generic/$fileName-$version.zip"
|
|
||||||
//// return wrapperDownloadUrl ?: defaultUrlFor(version)
|
|
||||||
//// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Install a new version if requested in .kobalt/wrapper/kobalt-wrapper.properties
|
|
||||||
// *
|
|
||||||
// * @return the path to the Kobalt jar file
|
|
||||||
// */
|
|
||||||
// public fun install() : Path {
|
|
||||||
// val properties = maybeCreateKobaltProperties()
|
|
||||||
// val version = properties.getProperty("kobalt.version")
|
|
||||||
// wrapperProperties.maybeCreate(version)
|
|
||||||
// log(2, "Wrapper version: ${wrapperProperties.version}")
|
|
||||||
//
|
|
||||||
// val wrapperVersion = wrapperProperties.version
|
|
||||||
// val fileName = "$FILE_NAME-$wrapperVersion.zip"
|
|
||||||
// File(KFiles.distributionsDir).mkdirs()
|
|
||||||
// val localZipFile = Paths.get(KFiles.distributionsDir, fileName)
|
|
||||||
// val zipOutputDir = KFiles.distributionsDir + "/" + wrapperVersion
|
|
||||||
// val kobaltJarFile = Paths.get(zipOutputDir, "kobalt/wrapper/$FILE_NAME-$wrapperVersion.jar")
|
|
||||||
// if (!Files.exists(localZipFile) || !Files.exists(kobaltJarFile)) {
|
|
||||||
// log(1, "Downloading $fileName")
|
|
||||||
// val fullUrl = wrapperProperties.downloadUrl
|
|
||||||
// val body = Http().get(fullUrl)
|
|
||||||
// if (body.code == 200) {
|
|
||||||
// if (!Files.exists(localZipFile)) {
|
|
||||||
// val target = localZipFile.toAbsolutePath()
|
|
||||||
// val ins = body.getAsStream()
|
|
||||||
// benchmark("Download .zip file") {
|
|
||||||
// // This takes about eight seconds for a 21M file because of the extra copying, not good.
|
|
||||||
// // Should use Okio.sink(file) to create a Sink and then call readAll(fileSink) on
|
|
||||||
// // the BufferedSource returned in the ResponseBody
|
|
||||||
// Files.copy(ins, target)
|
|
||||||
// }
|
|
||||||
// log(2, "$localZipFile downloaded, extracting it")
|
|
||||||
// } else {
|
|
||||||
// log(2, "$localZipFile already exists, extracting it")
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //
|
|
||||||
// // Extract all the zip files
|
|
||||||
// //
|
|
||||||
// val zipFile = ZipFile(localZipFile.toFile())
|
|
||||||
// val entries = zipFile.entries()
|
|
||||||
// val outputDirectory = File(KFiles.distributionsDir)
|
|
||||||
// outputDirectory.mkdirs()
|
|
||||||
// while (entries.hasMoreElements()) {
|
|
||||||
// val entry = entries.nextElement()
|
|
||||||
// val entryFile = File(entry.name)
|
|
||||||
// if (entry.isDirectory) {
|
|
||||||
// entryFile.mkdirs()
|
|
||||||
// } else {
|
|
||||||
// val dest = Paths.get(zipOutputDir, entryFile.path)
|
|
||||||
// log(2, " Writing ${entry.name} to $dest")
|
|
||||||
// Files.createDirectories(dest.parent)
|
|
||||||
// Files.copy(zipFile.getInputStream(entry),
|
|
||||||
// dest,
|
|
||||||
// java.nio.file.StandardCopyOption.REPLACE_EXISTING)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// log(2, "$localZipFile extracted")
|
|
||||||
// } else {
|
|
||||||
// error("Couldn't download $fullUrl")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //
|
|
||||||
// // Copy the wrapper files in the current kobalt/wrapper directory
|
|
||||||
// //
|
|
||||||
// log(2, "Copying the wrapper files...")
|
|
||||||
// arrayListOf(KOBALTW, "kobalt/wrapper/$FILE_NAME-wrapper.jar").forEach {
|
|
||||||
// val from = Paths.get(zipOutputDir, it)
|
|
||||||
// val to = Paths.get(File(".").absolutePath, it)
|
|
||||||
// KFiles.copy(from, to, java.nio.file.StandardCopyOption.REPLACE_EXISTING)
|
|
||||||
// }
|
|
||||||
// File(KOBALTW).setExecutable(true)
|
|
||||||
//
|
|
||||||
// return kobaltJarFile
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Launch kobalt-xxx.jar
|
|
||||||
// *
|
|
||||||
// * Note: currently launching it in a separate VM because both this jar file and the wrapper contain
|
|
||||||
// * the same classes, so the old classes will be run. Once wrapper.jar contains only the
|
|
||||||
// * wrapper class and nothing else from the Kobalt distribution, we can just invoke main from the same JVM here,
|
|
||||||
// * which will speed up the start up
|
|
||||||
// */
|
|
||||||
// private fun launchMain(kobaltJarFile: Path, argv: Array<String>) {
|
|
||||||
// val jvm = JavaInfo.create(File(SystemProperties.javaBase))
|
|
||||||
// val java = jvm.javaExecutable
|
|
||||||
//
|
|
||||||
// val args = arrayListOf(
|
|
||||||
// java!!.absolutePath,
|
|
||||||
// "-jar", kobaltJarFile.toFile().absolutePath)
|
|
||||||
// args.addAll(argv)
|
|
||||||
// val pb = ProcessBuilder(args)
|
|
||||||
// pb.inheritIO()
|
|
||||||
// log(2, "Launching\n ${args.joinToString(" ")}")
|
|
||||||
// val process = pb.start()
|
|
||||||
// process.waitFor()
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.beust.kobalt
|
package com.beust.kobalt
|
||||||
|
|
||||||
|
import com.beust.kobalt.Args
|
||||||
import com.beust.kobalt.maven.LocalRepo
|
import com.beust.kobalt.maven.LocalRepo
|
||||||
import com.beust.kobalt.misc.MainModule
|
import com.beust.kobalt.misc.MainModule
|
||||||
import com.google.inject.Scopes
|
import com.google.inject.Scopes
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.beust.kobalt.maven
|
||||||
|
|
||||||
import com.beust.kobalt.Args
|
import com.beust.kobalt.Args
|
||||||
import com.beust.kobalt.KobaltTest
|
import com.beust.kobalt.KobaltTest
|
||||||
import com.beust.kobalt.ProjectGenerator
|
import com.beust.kobalt.app.ProjectGenerator
|
||||||
import com.beust.kobalt.internal.PluginInfo
|
import com.beust.kobalt.internal.PluginInfo
|
||||||
import com.google.inject.Inject
|
import com.google.inject.Inject
|
||||||
import org.testng.Assert
|
import org.testng.Assert
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue