mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-25 07:57:12 -07:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
c83d0b3710
9 changed files with 50 additions and 45 deletions
|
@ -1 +1 @@
|
|||
kobalt.version=1.0.21
|
||||
kobalt.version=1.0.23
|
|
@ -26,7 +26,7 @@ open class Project(
|
|||
@Directive open var url: String? = null,
|
||||
@Directive open var pom: Model? = null,
|
||||
@Directive open var dependsOn: ArrayList<Project> = arrayListOf<Project>(),
|
||||
@Directive open var testsDependOnProjects: ArrayList<Project> = arrayListOf<Project>(),
|
||||
@Directive open var testsDependOn: ArrayList<Project> = arrayListOf<Project>(),
|
||||
@Directive open var packageName: String? = group)
|
||||
: IBuildConfig, IDependencyHolder by DependencyHolder() {
|
||||
|
||||
|
@ -34,7 +34,7 @@ open class Project(
|
|||
this.project = this
|
||||
}
|
||||
|
||||
fun allProjectDependedOn() = project.dependsOn + project.testsDependOnProjects
|
||||
fun allProjectDependedOn() = project.dependsOn + project.testsDependOn
|
||||
|
||||
class ProjectExtra(project: Project) {
|
||||
var isDirty = false
|
||||
|
@ -99,7 +99,8 @@ open class Project(
|
|||
val testDependencies : ArrayList<IClasspathDependency> = arrayListOf()
|
||||
val testProvidedDependencies : ArrayList<IClasspathDependency> = arrayListOf()
|
||||
|
||||
fun testsDependOnProjects(vararg projects: Project) = testsDependOnProjects.addAll(projects)
|
||||
fun testsDependOn(vararg projects: Project) = testsDependOn.addAll(projects)
|
||||
fun dependsOn(vararg projects: Project) = dependsOn.addAll(projects)
|
||||
|
||||
/** Used to disambiguate various name properties */
|
||||
@Directive
|
||||
|
|
|
@ -238,7 +238,7 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors,
|
|||
}
|
||||
|
||||
if (isTest) {
|
||||
project.testsDependOnProjects.forEach { p ->
|
||||
project.testsDependOn.forEach { p ->
|
||||
val otherDependencies = calculateDependencies(p, context, dependencyFilter, scopes)
|
||||
result.addAll(otherDependencies)
|
||||
}
|
||||
|
|
|
@ -23,6 +23,10 @@ class PomGenerator @Inject constructor(@Assisted val project: Project) {
|
|||
* Generate the POM file and save it.
|
||||
*/
|
||||
fun generateAndSave() {
|
||||
requireNotNull(project.version, { "version is mandatory on project ${project.name}" })
|
||||
requireNotNull(project.group, { "group is mandatory on project ${project.name}" })
|
||||
requireNotNull(project.artifactId, { "artifactId is mandatory on project ${project.name}" })
|
||||
|
||||
val buildDir = KFiles.makeDir(project.directory, project.buildDirectory)
|
||||
val outputDir = KFiles.makeDir(buildDir.path, "libs")
|
||||
val NO_CLASSIFIER = null
|
||||
|
@ -38,10 +42,6 @@ class PomGenerator @Inject constructor(@Assisted val project: Project) {
|
|||
* @return the text content of the POM file.
|
||||
*/
|
||||
fun generate() : String {
|
||||
requireNotNull(project.version, { "version mandatory on project ${project.name}" })
|
||||
requireNotNull(project.group, { "group mandatory on project ${project.name}" })
|
||||
requireNotNull(project.artifactId, { "artifactId mandatory on project ${project.name}" })
|
||||
|
||||
val pom = (project.pom ?: Model()).apply {
|
||||
// Make sure the pom has reasonable default values
|
||||
if (name == null) name = project.name
|
||||
|
|
|
@ -50,9 +50,8 @@ open class NewRunCommand(val info: RunCommandInfo) {
|
|||
// val DEFAULT_SUCCESS_VERBOSE = { output: List<String> -> kobaltLog(2, "Success:\n " + output.joinToString
|
||||
// ("\n"))}
|
||||
// val defaultSuccess = DEFAULT_SUCCESS
|
||||
val DEFAULT_ERROR = {
|
||||
output: List<String> ->
|
||||
kotlin.error(output.joinToString("\n "))
|
||||
val DEFAULT_ERROR = { output: List<String> ->
|
||||
kobaltError(output.joinToString("\n "))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -125,6 +125,8 @@ class RemoteDependencyData @Inject constructor(val executors: KobaltExecutors, v
|
|||
.map { toDependencyData2("testCompile", it)}
|
||||
}
|
||||
|
||||
val projectRoot = File(buildFilePath).parentFile.parentFile.parentFile
|
||||
|
||||
val allTasks = hashSetOf<TaskData>()
|
||||
projectResult.projects.withIndex().forEach { wi ->
|
||||
val project = wi.value
|
||||
|
@ -136,7 +138,7 @@ class RemoteDependencyData @Inject constructor(val executors: KobaltExecutors, v
|
|||
|
||||
// Separate resource from source directories
|
||||
fun partition(project: Project, dirs: Collection<String>)
|
||||
= dirs.filter { File(project.directory, it).exists() }
|
||||
= dirs.filter { File(KFiles.joinDir(projectRoot.absolutePath, project.directory, it)).exists() }
|
||||
.partition { KFiles.isResource(it) }
|
||||
val sources = partition(project, project.sourceDirectories)
|
||||
val tests = partition(project, project.sourceDirectoriesTest)
|
||||
|
|
|
@ -93,7 +93,7 @@ class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler, val kobaltL
|
|||
return if (result) {
|
||||
TaskResult(true, "Compilation succeeded")
|
||||
} else {
|
||||
val message = "Compilation errors, command:\n$command" + errorMessage
|
||||
val message = "Compilation errors, command:\n$command\n" + errorMessage
|
||||
logk(1, message)
|
||||
TaskResult(false, message)
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
kobalt.version=1.0.21
|
||||
kobalt.version=1.0.23
|
||||
|
|
|
@ -2,16 +2,19 @@ package com.beust.kobalt
|
|||
|
||||
import com.beust.kobalt.misc.KFiles
|
||||
import com.beust.kobalt.misc.kobaltLog
|
||||
import org.testng.Assert
|
||||
import org.testng.annotations.Test
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.FileReader
|
||||
import java.io.InputStream
|
||||
import java.util.*
|
||||
import java.util.jar.JarEntry
|
||||
import java.util.jar.JarFile
|
||||
import java.util.jar.JarInputStream
|
||||
|
||||
/**
|
||||
* Make sure the distribution zip file contains all the right files and no bad files.
|
||||
*/
|
||||
class VerifyKobaltZipTest : KobaltTest() {
|
||||
@Test
|
||||
fun verifySourceJarFile() {
|
||||
|
@ -43,7 +46,7 @@ class VerifyKobaltZipTest : KobaltTest() {
|
|||
} else if (entry.name.endsWith("kobalt-wrapper.jar")) {
|
||||
val ins = zipFile.getInputStream(entry)
|
||||
foundWrapperJar = true
|
||||
assertExistsInJar(JarInputStream(ins), "kobalt.properties")
|
||||
assertExistence(ins, listOf("kobalt.properties"))
|
||||
}
|
||||
entry = stream.nextEntry
|
||||
}
|
||||
|
@ -72,29 +75,35 @@ class VerifyKobaltZipTest : KobaltTest() {
|
|||
}
|
||||
|
||||
private fun verifyMainJarFile(ins: InputStream) {
|
||||
JarInputStream(ins).let { jar ->
|
||||
assertExistsInJar(jar, "com/beust/kobalt/MainKt.class",
|
||||
assertExistence(ins,
|
||||
listOf("com/beust/kobalt/MainKt.class",
|
||||
"templates/kobaltPlugin/kobaltPlugin.jar", "com/beust/kobalt/Args.class",
|
||||
"com/beust/kobalt/wrapper/Main.class")
|
||||
assertDoesNotExistInJar(jar, "BuildKt.class")
|
||||
}
|
||||
"com/beust/kobalt/wrapper/Main.class"),
|
||||
listOf("BuildKt.class"))
|
||||
}
|
||||
|
||||
private fun assertExistsInJar(ins: JarInputStream, vararg fileNames: String)
|
||||
= assertExistence(ins, true, *fileNames)
|
||||
private fun assertExistence(ins: InputStream,
|
||||
included: List<String>,
|
||||
excluded: List<String> = emptyList(),
|
||||
toName: (JarEntry) -> String = JarEntry::toString) {
|
||||
val seq = toSequence(ins)
|
||||
val foundItems = hashSetOf<String>()
|
||||
seq.forEach { entry ->
|
||||
val entryName = toName(entry)
|
||||
|
||||
private fun assertDoesNotExistInJar(ins: JarInputStream, vararg fileNames: String)
|
||||
= assertExistence(ins, false, *fileNames)
|
||||
|
||||
private fun assertExistence(ins: JarInputStream, verifyExistence: Boolean, vararg fileNames: String) {
|
||||
with(jarContents(ins)) {
|
||||
fileNames.forEach { fileName ->
|
||||
if (verifyExistence) {
|
||||
Assert.assertTrue(contains(fileName), "Couldn't find $fileName")
|
||||
} else {
|
||||
Assert.assertFalse(contains(fileName), "Couldn't find $fileName")
|
||||
}
|
||||
if (included.contains(entryName)) {
|
||||
foundItems.add(entryName)
|
||||
}
|
||||
|
||||
if (excluded.any { entryName.contains(it) }) {
|
||||
throw AssertionError(entryName + " should not be in the jar file")
|
||||
}
|
||||
}
|
||||
|
||||
if (foundItems != included.toSet()) {
|
||||
val missing = arrayListOf<String>().apply { addAll(included) }
|
||||
missing.removeAll(foundItems)
|
||||
throw AssertionError("Didn't find a few items: " + missing)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,19 +111,13 @@ class VerifyKobaltZipTest : KobaltTest() {
|
|||
val sourceJarPath = KFiles.joinDir("kobaltBuild", "libs", jarName)
|
||||
val file = File(sourceJarPath)
|
||||
if (file.exists()) {
|
||||
assertExistsInJar(JarInputStream(FileInputStream(file)), *fileNames)
|
||||
assertExistence(FileInputStream(file), arrayListOf<String>().apply { addAll(fileNames) })
|
||||
} else {
|
||||
kobaltLog(1, "Couldn't find $file, skipping test")
|
||||
}
|
||||
}
|
||||
|
||||
private fun jarContents(stream: JarInputStream) : Set<String> {
|
||||
val result = hashSetOf<String>()
|
||||
var entry = stream.nextEntry
|
||||
while (entry != null) {
|
||||
result.add(entry.name)
|
||||
entry = stream.nextEntry
|
||||
}
|
||||
return result
|
||||
}
|
||||
fun JarInputStream.asSequence() = generateSequence { nextJarEntry }
|
||||
|
||||
private fun toSequence(ins: InputStream): Sequence<JarEntry> = JarInputStream(ins).asSequence()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue