mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-27 00:38:11 -07:00
Delete tmp directory.
This commit is contained in:
parent
5556009e44
commit
943c662a40
7 changed files with 0 additions and 645 deletions
190
tmp/Build.kt
190
tmp/Build.kt
|
@ -1,190 +0,0 @@
|
||||||
|
|
||||||
import com.beust.kobalt.TaskResult
|
|
||||||
import com.beust.kobalt.api.License
|
|
||||||
import com.beust.kobalt.api.Project
|
|
||||||
import com.beust.kobalt.api.Scm
|
|
||||||
import com.beust.kobalt.api.annotation.Task
|
|
||||||
import com.beust.kobalt.homeDir
|
|
||||||
import com.beust.kobalt.plugin.application.application
|
|
||||||
import com.beust.kobalt.plugin.java.javaCompiler
|
|
||||||
import com.beust.kobalt.plugin.java.javaProject
|
|
||||||
import com.beust.kobalt.plugin.kotlin.kotlinCompiler
|
|
||||||
import com.beust.kobalt.plugin.kotlin.kotlinProject
|
|
||||||
import com.beust.kobalt.plugin.packaging.assemble
|
|
||||||
import com.beust.kobalt.plugin.publish.github
|
|
||||||
import com.beust.kobalt.plugin.publish.bintray
|
|
||||||
import com.beust.kobalt.repos
|
|
||||||
import com.beust.kobalt.test
|
|
||||||
import java.io.File
|
|
||||||
import java.nio.file.Files
|
|
||||||
import java.nio.file.Paths
|
|
||||||
import java.nio.file.StandardCopyOption
|
|
||||||
|
|
||||||
val r = repos("http://dl.bintray.com/kotlin/kotlinx.dom")
|
|
||||||
|
|
||||||
val wrapper = javaProject {
|
|
||||||
name = "kobalt-wrapper"
|
|
||||||
version = readVersion()
|
|
||||||
directory = "modules/wrapper"
|
|
||||||
|
|
||||||
javaCompiler {
|
|
||||||
args("-source", "1.7", "-target", "1.7")
|
|
||||||
}
|
|
||||||
|
|
||||||
assemble {
|
|
||||||
jar {
|
|
||||||
name = projectName + ".jar"
|
|
||||||
manifest {
|
|
||||||
attributes("Main-Class", "com.beust.kobalt.wrapper.Main")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
application {
|
|
||||||
mainClass = "com.beust.kobalt.wrapper.Main"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
val kobaltPluginApi = kotlinProject {
|
|
||||||
name = "kobalt-plugin-api"
|
|
||||||
group = "com.beust"
|
|
||||||
artifactId = name
|
|
||||||
version = readVersion()
|
|
||||||
directory = "modules/kobalt-plugin-api"
|
|
||||||
description = "A build system in Kotlin"
|
|
||||||
url = "http://beust.com/kobalt"
|
|
||||||
licenses = arrayListOf(License("Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0"))
|
|
||||||
scm = Scm(url = "http://github.com/cbeust/kobalt",
|
|
||||||
connection = "https://github.com/cbeust/kobalt.git",
|
|
||||||
developerConnection = "git@github.com:cbeust/kobalt.git")
|
|
||||||
|
|
||||||
dependenciesTest {
|
|
||||||
compile("org.testng:testng:6.9.9")
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compile("org.jetbrains.kotlinx:kotlinx.dom:0.0.4",
|
|
||||||
|
|
||||||
"com.squareup.okhttp:okhttp:2.5.0",
|
|
||||||
"com.squareup.okio:okio:1.6.0",
|
|
||||||
"com.google.inject:guice:4.0",
|
|
||||||
"com.google.inject.extensions:guice-assistedinject:4.0",
|
|
||||||
"javax.inject:javax.inject:1",
|
|
||||||
"com.google.guava:guava:19.0-rc2",
|
|
||||||
"org.apache.maven:maven-model:3.3.3",
|
|
||||||
"io.reactivex:rxjava:1.0.16",
|
|
||||||
"com.google.code.gson:gson:2.4",
|
|
||||||
"com.squareup.retrofit:retrofit:1.9.0",
|
|
||||||
"com.beust:jcommander:1.48"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
assemble {
|
|
||||||
mavenJars {
|
|
||||||
fatJar = true
|
|
||||||
manifest {
|
|
||||||
attributes("Main-Class", "com.beust.kobalt.MainKt")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// install {
|
|
||||||
// libDir = "lib-test"
|
|
||||||
// }
|
|
||||||
|
|
||||||
test {
|
|
||||||
args("-log", "1", "src/test/resources/testng.xml")
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlinCompiler {
|
|
||||||
args("-nowarn")
|
|
||||||
}
|
|
||||||
|
|
||||||
bintray {
|
|
||||||
publish = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val kobaltApp = kotlinProject(kobaltPluginApi, wrapper) {
|
|
||||||
name = "kobalt"
|
|
||||||
group = "com.beust"
|
|
||||||
artifactId = name
|
|
||||||
version = readVersion()
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
// Used by the plugins
|
|
||||||
compile("com.android.tools.build:builder:2.0.0-alpha3",
|
|
||||||
"org.jetbrains.kotlin:kotlin-compiler-embeddable:1.0.0-beta-3595",
|
|
||||||
"org.jetbrains.dokka:dokka-fatjar:0.9.3")
|
|
||||||
|
|
||||||
// Used by the main app
|
|
||||||
compile("com.github.spullara.mustache.java:compiler:0.9.1",
|
|
||||||
"com.squareup.okhttp:okhttp:2.5.0",
|
|
||||||
"javax.inject:javax.inject:1",
|
|
||||||
"com.google.inject:guice:4.0",
|
|
||||||
"com.google.inject.extensions:guice-assistedinject:4.0",
|
|
||||||
"com.beust:jcommander:1.48",
|
|
||||||
"com.squareup.retrofit:retrofit:1.9.0",
|
|
||||||
"org.apache.maven:maven-model:3.3.3",
|
|
||||||
"org.codehaus.plexus:plexus-utils:3.0.22")
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
dependenciesTest {
|
|
||||||
compile("org.testng:testng:6.9.9")
|
|
||||||
}
|
|
||||||
|
|
||||||
assemble {
|
|
||||||
mavenJars {
|
|
||||||
fatJar = true
|
|
||||||
manifest {
|
|
||||||
attributes("Main-Class", "com.beust.kobalt.MainKt")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
zip {
|
|
||||||
include("kobaltw")
|
|
||||||
include(from("$buildDirectory/libs"), to("kobalt/wrapper"),
|
|
||||||
"$projectName-$version.jar")
|
|
||||||
include(from("modules/wrapper/$buildDirectory/libs"), to("kobalt/wrapper"),
|
|
||||||
"$projectName-wrapper.jar")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlinCompiler {
|
|
||||||
args("-nowarn")
|
|
||||||
}
|
|
||||||
|
|
||||||
bintray {
|
|
||||||
publish = true
|
|
||||||
}
|
|
||||||
|
|
||||||
github {
|
|
||||||
file("$buildDirectory/libs/$name-$version.zip", "$name/$version/$name-$version.zip")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun readVersion() : String {
|
|
||||||
val p = java.util.Properties()
|
|
||||||
var localFile = java.io.File("src/main/resources/kobalt.properties")
|
|
||||||
if (! localFile.exists()) {
|
|
||||||
localFile = File(homeDir("kotlin", "kobalt", "src/main/resources/kobalt.properties"))
|
|
||||||
}
|
|
||||||
p.load(java.io.FileReader(localFile))
|
|
||||||
return p.getProperty("kobalt.version")
|
|
||||||
}
|
|
||||||
|
|
||||||
@Task(name = "copyVersionForWrapper", runBefore = arrayOf("assemble"), runAfter = arrayOf("compile"), description = "")
|
|
||||||
fun taskCopyVersionForWrapper(project: Project) : TaskResult {
|
|
||||||
if (project.name == "kobalt-wrapper") {
|
|
||||||
val toString = "modules/wrapper/kobaltBuild/classes"
|
|
||||||
File(toString).mkdirs()
|
|
||||||
val from = Paths.get("src/main/resources/kobalt.properties")
|
|
||||||
val to = Paths.get("$toString/kobalt.properties")
|
|
||||||
Files.copy(from,
|
|
||||||
to,
|
|
||||||
StandardCopyOption.REPLACE_EXISTING)
|
|
||||||
}
|
|
||||||
return TaskResult()
|
|
||||||
}
|
|
|
@ -1,58 +0,0 @@
|
||||||
package com.beust.kobalt.maven
|
|
||||||
|
|
||||||
import com.beust.kobalt.KobaltException
|
|
||||||
import com.beust.kobalt.api.IClasspathDependency
|
|
||||||
import com.beust.kobalt.api.Kobalt
|
|
||||||
import com.beust.kobalt.maven.dependency.FileDependency
|
|
||||||
import com.beust.kobalt.maven.dependency.MavenDependency
|
|
||||||
import com.beust.kobalt.misc.DependencyExecutor
|
|
||||||
import com.beust.kobalt.misc.KobaltExecutors
|
|
||||||
import com.google.inject.Key
|
|
||||||
import java.util.concurrent.ExecutorService
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
public class DepFactory @Inject constructor(val localRepo: LocalRepo,
|
|
||||||
val remoteRepo: RepoFinder,
|
|
||||||
val executors: KobaltExecutors,
|
|
||||||
val downloadManager: DownloadManager,
|
|
||||||
val pomFactory: Pom.IFactory) {
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
val defExecutor : ExecutorService by lazy {
|
|
||||||
Kobalt.INJECTOR.getInstance(Key.get(ExecutorService::class.java, DependencyExecutor::class.java))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse the id and return the correct IClasspathDependency
|
|
||||||
*/
|
|
||||||
public fun create(id: String, executor: ExecutorService = defExecutor, localFirst : Boolean = true)
|
|
||||||
: IClasspathDependency {
|
|
||||||
if (id.startsWith(FileDependency.PREFIX_FILE)) {
|
|
||||||
return FileDependency(id.substring(FileDependency.PREFIX_FILE.length))
|
|
||||||
} else {
|
|
||||||
val mavenId = MavenId.create(id)
|
|
||||||
var version = mavenId.version
|
|
||||||
var packaging = mavenId.packaging
|
|
||||||
var repoResult: RepoFinder.RepoResult?
|
|
||||||
|
|
||||||
if (version == null || MavenId.isRangedVersion(version)) {
|
|
||||||
var localVersion: String? = version
|
|
||||||
if (localFirst) localVersion = localRepo.findLocalVersion(mavenId.groupId, mavenId.artifactId, mavenId.packaging)
|
|
||||||
if (localFirst && localVersion != null) {
|
|
||||||
version = localVersion
|
|
||||||
} else {
|
|
||||||
repoResult = remoteRepo.findCorrectRepo(id)
|
|
||||||
if (!repoResult.found) {
|
|
||||||
throw KobaltException("Couldn't resolve $id")
|
|
||||||
} else {
|
|
||||||
version = repoResult.version?.version
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return MavenDependency(MavenId.create(mavenId.groupId, mavenId.artifactId, packaging, version),
|
|
||||||
executor, localRepo, remoteRepo, pomFactory, downloadManager)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
300
tmp/KFiles.kt
300
tmp/KFiles.kt
|
@ -1,300 +0,0 @@
|
||||||
package com.beust.kobalt.misc
|
|
||||||
|
|
||||||
import com.beust.kobalt.IFileSpec
|
|
||||||
import com.beust.kobalt.SystemProperties
|
|
||||||
import com.beust.kobalt.Variant
|
|
||||||
import com.beust.kobalt.api.Kobalt
|
|
||||||
import com.beust.kobalt.api.Project
|
|
||||||
import com.beust.kobalt.homeDir
|
|
||||||
import com.beust.kobalt.internal.build.BuildFile
|
|
||||||
import java.io.File
|
|
||||||
import java.io.IOException
|
|
||||||
import java.nio.file.*
|
|
||||||
import kotlin.io.FileAlreadyExistsException
|
|
||||||
import kotlin.io.FileSystemException
|
|
||||||
import kotlin.io.NoSuchFileException
|
|
||||||
|
|
||||||
class KFiles {
|
|
||||||
/**
|
|
||||||
* This actually returns a list of strings because in development mode, we are not pointing to a single
|
|
||||||
* jar file but to a set of /classes directories.
|
|
||||||
*/
|
|
||||||
val kobaltJar : List<String>
|
|
||||||
get() {
|
|
||||||
val envJar = System.getenv("KOBALT_JAR")
|
|
||||||
if (envJar != null) {
|
|
||||||
debug("Using kobalt jar $envJar")
|
|
||||||
return listOf(File(envJar).absolutePath)
|
|
||||||
} else {
|
|
||||||
val jar = joinDir(distributionsDir, Kobalt.version, "kobalt/wrapper/kobalt-" + Kobalt.version + ".jar")
|
|
||||||
val jarFile = File(jar)
|
|
||||||
if (jarFile.exists()) {
|
|
||||||
return listOf(jarFile.absolutePath)
|
|
||||||
} else {
|
|
||||||
// Will only happen when building kobalt itself: the jar file might not be in the dist/ directory
|
|
||||||
// yet since we're currently building it. Instead, use the classes directly
|
|
||||||
debug("Couldn't find ${jarFile.absolutePath}, using build/classes/main")
|
|
||||||
val result = listOf("kobalt", "kobalt-plugin-api", "kobalt-wrapper").map {
|
|
||||||
File(homeDir(KFiles.joinDir("kotlin", "kobalt", "out", "production", it))).absolutePath
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
|
||||||
File(KOBALT_DOT_DIR).mkdirs()
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private const val KOBALT_DOT_DIR : String = ".kobalt"
|
|
||||||
const val KOBALT_DIR : String = "kobalt"
|
|
||||||
const val KOBALT_BUILD_DIR = "kobaltBuild"
|
|
||||||
|
|
||||||
// Directories under ~/.kobalt
|
|
||||||
val localRepo = homeDir(KOBALT_DOT_DIR, "repository")
|
|
||||||
|
|
||||||
/** Where all the .zip files are extracted */
|
|
||||||
val distributionsDir = homeDir(KOBALT_DOT_DIR, "wrapper", "dist")
|
|
||||||
|
|
||||||
// Directories under ./.kobalt
|
|
||||||
val SCRIPT_BUILD_DIR : String = "build"
|
|
||||||
val CLASSES_DIR : String = "classes"
|
|
||||||
|
|
||||||
/** Where build file and support source files go, under KOBALT_DIR */
|
|
||||||
private val SRC = "src"
|
|
||||||
|
|
||||||
val TEST_CLASSES_DIR : String = "test-classes"
|
|
||||||
|
|
||||||
private fun generatedDir(project: Project, variant: Variant)
|
|
||||||
= KFiles.joinDir(project.directory, project.buildDirectory, "generated", variant.toIntermediateDir())
|
|
||||||
|
|
||||||
fun generatedSourceDir(project: Project, variant: Variant, name: String) =
|
|
||||||
KFiles.joinDir(project.directory, project.buildDirectory, "generated", "source", name,
|
|
||||||
variant.toIntermediateDir())
|
|
||||||
|
|
||||||
fun buildDir(project: Project) = KFiles.makeDir(project.directory, project.buildDirectory)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Join the paths elements with the file separator.
|
|
||||||
*/
|
|
||||||
fun joinDir(paths: List<String>): String = paths.joinToString(File.separator)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Join the paths elements with the file separator.
|
|
||||||
*/
|
|
||||||
fun joinDir(vararg ts: String): String = ts.toArrayList().joinToString(File.separator)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The paths elements are expected to be a directory. Make that directory and join the
|
|
||||||
* elements with the file separator.
|
|
||||||
*/
|
|
||||||
fun joinAndMakeDir(paths: List<String>) = joinDir(paths).apply { File(this).mkdirs() }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The paths elements are expected to be a directory. Make that directory and join the
|
|
||||||
* elements with the file separator.
|
|
||||||
*/
|
|
||||||
fun joinAndMakeDir(vararg ts: String) = joinAndMakeDir(ts.toList())
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The paths elements are expected to be a file. Make that parent directory of that file and join the
|
|
||||||
* elements with the file separator.
|
|
||||||
*/
|
|
||||||
fun joinFileAndMakeDir(vararg ts: String) = joinDir(joinAndMakeDir(ts.slice(0..ts.size - 2)), ts[ts.size - 1])
|
|
||||||
|
|
||||||
fun makeDir(dir: String, s: String? = null) =
|
|
||||||
(if (s != null) File(dir, s) else File(dir)).apply { mkdirs() }
|
|
||||||
|
|
||||||
fun findRecursively(rootDir: File) : List<String> =
|
|
||||||
findRecursively(rootDir, arrayListOf(), { s -> true })
|
|
||||||
|
|
||||||
fun findRecursively(rootDir: File, directories: List<File>,
|
|
||||||
function: Function1<String, Boolean>): List<String> {
|
|
||||||
var result = arrayListOf<String>()
|
|
||||||
|
|
||||||
val allDirs = arrayListOf<File>()
|
|
||||||
if (directories.isEmpty()) {
|
|
||||||
allDirs.add(rootDir)
|
|
||||||
} else {
|
|
||||||
allDirs.addAll(directories.map { File(rootDir, it.path) })
|
|
||||||
}
|
|
||||||
|
|
||||||
val seen = hashSetOf<java.nio.file.Path>()
|
|
||||||
allDirs.forEach { dir ->
|
|
||||||
if (! dir.exists()) {
|
|
||||||
log(2, "Couldn't find directory $dir")
|
|
||||||
} else {
|
|
||||||
val files = findRecursively(dir, function)
|
|
||||||
files.map { Paths.get(it) }.forEach {
|
|
||||||
val rel = Paths.get(dir.path).relativize(it)
|
|
||||||
if (! seen.contains(rel)) {
|
|
||||||
result.add(File(dir, rel.toFile().path).path)
|
|
||||||
seen.add(rel)
|
|
||||||
} else {
|
|
||||||
log(2, "Skipped file already seen in previous flavor: $rel")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Return files relative to rootDir
|
|
||||||
val r = result.map { it.substring(rootDir.path.length + 1)}
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
fun findRecursively(directory: File, function: Function1<String, Boolean>): List<String> {
|
|
||||||
var result = arrayListOf<String>()
|
|
||||||
directory.listFiles().forEach {
|
|
||||||
if (it.isFile && function(it.path)) {
|
|
||||||
result.add(it.path)
|
|
||||||
} else if (it.isDirectory) {
|
|
||||||
result.addAll(findRecursively(it, function))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
fun copyRecursively(from: File, to: File, replaceExisting: Boolean = true, deleteFirst: Boolean = false,
|
|
||||||
onError: (File, IOException) -> OnErrorAction = { file, exception -> throw exception }) {
|
|
||||||
// Need to wait until copyRecursively supports an overwrite: Boolean = false parameter
|
|
||||||
// Until then, wipe everything first
|
|
||||||
if (deleteFirst) to.deleteRecursively()
|
|
||||||
// to.mkdirs()
|
|
||||||
hackCopyRecursively(from, to, replaceExisting, onError)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Private exception class, used to terminate recursive copying */
|
|
||||||
private class TerminateException(file: File) : FileSystemException(file) {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy/pasted from kotlin/io/Utils.kt to add support for overwriting.
|
|
||||||
*/
|
|
||||||
private fun hackCopyRecursively(from: File, dst: File,
|
|
||||||
replaceExisting: Boolean,
|
|
||||||
onError: (File, IOException) -> OnErrorAction =
|
|
||||||
{ file, exception -> throw exception }
|
|
||||||
): Boolean {
|
|
||||||
if (!from.exists()) {
|
|
||||||
return onError(from, NoSuchFileException(file = from, reason = "The source file doesn't exist")) !=
|
|
||||||
OnErrorAction.TERMINATE
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
// We cannot break for loop from inside a lambda, so we have to use an exception here
|
|
||||||
for (src in from.walkTopDown().fail { f, e -> if (onError(f, e) == OnErrorAction.TERMINATE) throw TerminateException(f) }) {
|
|
||||||
if (!src.exists()) {
|
|
||||||
if (onError(src, NoSuchFileException(file = src, reason = "The source file doesn't exist")) ==
|
|
||||||
OnErrorAction.TERMINATE)
|
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
val relPath = src.relativeTo(from)
|
|
||||||
val dstFile = File(dst, relPath)
|
|
||||||
if (dstFile.exists() && !replaceExisting && !(src.isDirectory() && dstFile.isDirectory())) {
|
|
||||||
if (onError(dstFile, FileAlreadyExistsException(file = src,
|
|
||||||
other = dstFile,
|
|
||||||
reason = "The destination file already exists")) == OnErrorAction.TERMINATE)
|
|
||||||
return false
|
|
||||||
} else if (src.isDirectory()) {
|
|
||||||
dstFile.mkdirs()
|
|
||||||
} else {
|
|
||||||
if (src.copyTo(dstFile, true) != src.length()) {
|
|
||||||
if (onError(src, IOException("src.length() != dst.length()")) == OnErrorAction.TERMINATE)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
} catch (e: TerminateException) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun findDotDir(startDir: File) : File {
|
|
||||||
var result = startDir
|
|
||||||
while (result != null && ! File(result, KOBALT_DOT_DIR).exists()) {
|
|
||||||
result = result.parentFile
|
|
||||||
}
|
|
||||||
if (result == null) {
|
|
||||||
throw IllegalArgumentException("Couldn't locate $KOBALT_DOT_DIR in $startDir")
|
|
||||||
}
|
|
||||||
return File(result, KOBALT_DOT_DIR)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The build location for build scripts is .kobalt/build
|
|
||||||
*/
|
|
||||||
fun findBuildScriptLocation(buildFile: BuildFile, jarFile: String) : String {
|
|
||||||
val result = joinDir(findDotDir(buildFile.directory).absolutePath, KFiles.SCRIPT_BUILD_DIR, jarFile)
|
|
||||||
log(2, "Script jar file: $result")
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
fun saveFile(file: File, text: String) {
|
|
||||||
file.absoluteFile.parentFile.mkdirs()
|
|
||||||
file.writeText(text)
|
|
||||||
log(2, "Wrote $file")
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun isWindows() = System.getProperty("os.name").contains("Windows");
|
|
||||||
|
|
||||||
fun copy(from: Path?, to: Path?, option: StandardCopyOption = StandardCopyOption.REPLACE_EXISTING) {
|
|
||||||
if (isWindows() && to!!.toFile().exists()) {
|
|
||||||
log(2, "Windows detected, not overwriting ${to}")
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
log(2, "Copy from $from to ${to!!}")
|
|
||||||
Files.copy(from, to, option)
|
|
||||||
} catch(ex: IOException) {
|
|
||||||
// Windows is anal about this
|
|
||||||
log(1, "Couldn't copy $from to $to: ${ex.message}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun createTempFile(suffix : String = "", deleteOnExit: Boolean = false) : File =
|
|
||||||
File.createTempFile("kobalt", suffix, File(SystemProperties.tmpDir)).let {
|
|
||||||
if (deleteOnExit) it.deleteOnExit()
|
|
||||||
return it
|
|
||||||
}
|
|
||||||
|
|
||||||
fun src(filePath: String): String = KFiles.joinDir(KOBALT_DIR, SRC, filePath)
|
|
||||||
|
|
||||||
fun makeDir(project: Project, suffix: String) : File {
|
|
||||||
return File(project.directory, project.buildDirectory + File.separator + suffix).apply { mkdirs() }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun makeOutputDir(project: Project) : File = makeDir(project, KFiles.CLASSES_DIR)
|
|
||||||
|
|
||||||
fun makeOutputTestDir(project: Project) : File = makeDir(project, KFiles.TEST_CLASSES_DIR)
|
|
||||||
|
|
||||||
fun isExcluded(file: File, excludes: List<IFileSpec.Glob>) = isExcluded(file.path, excludes)
|
|
||||||
|
|
||||||
fun isExcluded(file: String, excludes: List<IFileSpec.Glob>) : Boolean {
|
|
||||||
if (excludes.isEmpty()) {
|
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
val ex = arrayListOf<PathMatcher>()
|
|
||||||
excludes.forEach {
|
|
||||||
ex.add(FileSystems.getDefault().getPathMatcher("glob:${it.spec}"))
|
|
||||||
}
|
|
||||||
ex.forEach {
|
|
||||||
if (it.matches(Paths.get(file))) {
|
|
||||||
log(3, "Excluding $file")
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fun findRecursively(directory: File, function: Function1<String, Boolean>): List<String> {
|
|
||||||
return KFiles.findRecursively(directory, function)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun findRecursively(rootDir: File, directories: List<File>,
|
|
||||||
function: Function1<String, Boolean>): List<String> {
|
|
||||||
return KFiles.findRecursively(rootDir, directories, function)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
rm -rf modules/kobalt-plugin-api
|
|
||||||
|
|
||||||
mkdir -p modules/kobalt-plugin-api/src
|
|
||||||
|
|
||||||
mkdir -p modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt
|
|
||||||
for i in api internal kotlin maven misc
|
|
||||||
do
|
|
||||||
mv src/main/kotlin/com/beust/kobalt/$i modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt
|
|
||||||
done
|
|
||||||
mv src/main/kotlin/com/beust/kobalt/*kt modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt
|
|
||||||
|
|
||||||
for i in Main.kt
|
|
||||||
do
|
|
||||||
mv modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/$i src/main/kotlin/com/beust/kobalt
|
|
||||||
done
|
|
||||||
|
|
||||||
#mv modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/app src/main/kotlin/com/beust/kobalt
|
|
||||||
|
|
||||||
|
|
||||||
cp /Users/beust/t/kobalt-plugin-api.iml modules/kobalt-plugin-api
|
|
||||||
|
|
||||||
cp tmp/Build.kt kobalt/src
|
|
||||||
|
|
||||||
# return File(homeDir("kotlin", "kobalt", "classes", "production", "kobalt-plugin-api")).absolutePath
|
|
|
@ -1,11 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module version="4">
|
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
<orderEntry type="library" name="kobalt (Compile)" level="project" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
|
@ -1,46 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="kobalt (Compile)">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/android/tools/sdklib/25.0.0-alpha3/sdklib-25.0.0-alpha3.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/org/bouncycastle/bcprov-jdk15on/1.48/bcprov-jdk15on-1.48.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/android/tools/jack/jack-api/0.9.0/jack-api-0.9.0.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/org/apache/httpcomponents/httpmime/4.1/httpmime-4.1.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/org/bouncycastle/bcpkix-jdk15on/1.48/bcpkix-jdk15on-1.48.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/android/tools/build/transform-api/2.0.0-alpha3/transform-api-2.0.0-alpha3.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/android/tools/layoutlib/layoutlib-api/25.0.0-alpha3/layoutlib-api-25.0.0-alpha3.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/squareup/javawriter/2.5.0/javawriter-2.5.0.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/intellij/annotations/12.0/annotations-12.0.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/android/tools/build/builder-model/2.0.0-alpha3/builder-model-2.0.0-alpha3.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/github/spullara/mustache/java/compiler/0.9.1/compiler-0.9.1.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/android/tools/ddms/ddmlib/25.0.0-alpha3/ddmlib-25.0.0-alpha3.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/org/ow2/asm/asm-tree/5.0.3/asm-tree-5.0.3.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/android/tools/common/25.0.0-alpha3/common-25.0.0-alpha3.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/org/apache/httpcomponents/httpclient/4.1.1/httpclient-4.1.1.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/android/tools/sdk-common/25.0.0-alpha3/sdk-common-25.0.0-alpha3.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/android/tools/build/builder/2.0.0-alpha3/builder-2.0.0-alpha3.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/android/tools/jill/jill-api/0.9.0/jill-api-0.9.0.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/android/tools/dvlib/25.0.0-alpha3/dvlib-25.0.0-alpha3.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/android/tools/build/builder-test-api/2.0.0-alpha3/builder-test-api-2.0.0-alpha3.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/android/tools/build/manifest-merger/25.0.0-alpha3/manifest-merger-25.0.0-alpha3.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/net/sf/kxml/kxml2/2.3.0/kxml2-2.3.0.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/android/tools/repository/25.0.0-alpha3/repository-25.0.0-alpha3.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/android/tools/annotations/25.0.0-alpha3/annotations-25.0.0-alpha3.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/org/jetbrains/dokka/dokka-fatjar/0.9.3/dokka-fatjar-0.9.3.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.0.0-beta-3595/kotlin-compiler-embeddable-1.0.0-beta-3595.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/google/guava/guava/17.0/guava-17.0.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/org/ow2/asm/asm/5.0.4/asm-5.0.4.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/beust/jcommander/1.48/jcommander-1.48.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/org/apache/maven/maven-model/3.3.3/maven-model-3.3.3.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/google/inject/extensions/guice-assistedinject/4.0/guice-assistedinject-4.0.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/squareup/retrofit/retrofit/1.9.0/retrofit-1.9.0.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/squareup/okhttp/okhttp/2.5.0/okhttp-2.5.0.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/org/jetbrains/kotlinx/kotlinx.dom/0.0.4/kotlinx.dom-0.0.4.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/com/squareup/okio/okio/1.6.0/okio-1.6.0.jar!/" />
|
|
||||||
<root url="jar://$USER_HOME$/.kobalt/repository/io/reactivex/rxjava/1.1.0/rxjava-1.1.0.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
|
@ -1,16 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="org.testng:testng:6.9.10" type="repository">
|
|
||||||
<properties maven-id="org.testng:testng:6.9.10" />
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/testng/testng/6.9.10/testng-6.9.10.jar!/" />
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/beanshell/bsh/2.0b4/bsh-2.0b4.jar!/" />
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/com/beust/jcommander/1.48/jcommander-1.48.jar!/" />
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/inject/guice/4.0/guice-4.0-no_aop.jar!/" />
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/javax/inject/javax.inject/1/javax.inject-1.jar!/" />
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/aopalliance/aopalliance/1.0/aopalliance-1.0.jar!/" />
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/16.0.1/guava-16.0.1.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
Loading…
Add table
Add a link
Reference in a new issue