mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Better toString().
This commit is contained in:
parent
fded2800b6
commit
26d8da1114
8 changed files with 20 additions and 26 deletions
|
@ -1,7 +1,7 @@
|
||||||
package com.beust.kobalt.api
|
package com.beust.kobalt.api
|
||||||
|
|
||||||
import com.beust.kobalt.internal.TaskResult2
|
import com.beust.kobalt.internal.TaskResult2
|
||||||
import com.beust.kobalt.misc.ToString
|
import com.beust.kobalt.misc.toString
|
||||||
import java.util.concurrent.Callable
|
import java.util.concurrent.Callable
|
||||||
|
|
||||||
abstract public class PluginTask : Callable<TaskResult2<PluginTask>> {
|
abstract public class PluginTask : Callable<TaskResult2<PluginTask>> {
|
||||||
|
@ -11,6 +11,6 @@ abstract public class PluginTask : Callable<TaskResult2<PluginTask>> {
|
||||||
abstract val project: Project
|
abstract val project: Project
|
||||||
|
|
||||||
override public fun toString() : String {
|
override public fun toString() : String {
|
||||||
return ToString("PluginTask", "id", project.name + ":" + name).s
|
return toString("PluginTask", "id", project.name + ":" + name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.beust.kobalt.api
|
package com.beust.kobalt.api
|
||||||
|
|
||||||
import com.beust.kobalt.misc.ToString
|
import com.beust.kobalt.misc.toString
|
||||||
|
|
||||||
data public class Task(val pluginName: String, val taskName: String) {
|
data public class Task(val pluginName: String, val taskName: String) {
|
||||||
override public fun toString() : String {
|
override public fun toString() : String {
|
||||||
return ToString("Task", pluginName, taskName).s
|
return toString("Task", pluginName, taskName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,11 +1,13 @@
|
||||||
package com.beust.kobalt.internal
|
package com.beust.kobalt.internal
|
||||||
|
|
||||||
|
import com.beust.kobalt.misc.NamedThreadFactory
|
||||||
|
import com.beust.kobalt.misc.log
|
||||||
import com.beust.kobalt.misc.*
|
import com.beust.kobalt.misc.*
|
||||||
import com.google.common.collect.HashMultimap
|
import com.google.common.collect.HashMultimap
|
||||||
import java.util.concurrent.*
|
import java.util.concurrent.*
|
||||||
|
|
||||||
open class TaskResult2<T>(success: Boolean, val value: T) : TaskResult(success) {
|
open class TaskResult2<T>(success: Boolean, val value: T) : TaskResult(success) {
|
||||||
override fun toString() = ToString("TaskResult", "success", success, "value", value).s
|
override fun toString() = toString("TaskResult", "success", success, "value", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IWorker<T> : Callable<TaskResult2<T>> {
|
public interface IWorker<T> : Callable<TaskResult2<T>> {
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package com.beust.kobalt.maven
|
package com.beust.kobalt.maven
|
||||||
|
|
||||||
import com.beust.kobalt.misc.ToString
|
import com.beust.kobalt.misc.toString
|
||||||
import com.beust.kobalt.misc.log
|
import com.beust.kobalt.misc.log
|
||||||
import com.google.inject.assistedinject.Assisted
|
import com.google.inject.assistedinject.Assisted
|
||||||
|
import org.jetbrains.kotlin.codegen.intrinsics.ToString
|
||||||
import org.w3c.dom.Element
|
import org.w3c.dom.Element
|
||||||
import org.w3c.dom.NodeList
|
import org.w3c.dom.NodeList
|
||||||
import org.xml.sax.InputSource
|
import org.xml.sax.InputSource
|
||||||
|
@ -103,5 +104,5 @@ public class Pom @javax.inject.Inject constructor(@Assisted val id: String,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override public fun toString() = ToString("Pom", id, "id").s
|
override public fun toString() = toString("Pom", id, "id")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
package com.beust.kobalt.misc
|
package com.beust.kobalt.misc
|
||||||
|
|
||||||
public class ToString<T>(val name: String, vararg o: T) {
|
fun toString<T>(name: String, vararg o: T) : String {
|
||||||
val sb = StringBuffer()
|
val sb = StringBuffer()
|
||||||
|
|
||||||
init {
|
for (i in 0..o.size - 1 step 2) {
|
||||||
for (i in 0..o.size - 1 step 2) {
|
if (i > 0) sb.append(", ")
|
||||||
if (i > 0) sb.append(", ")
|
sb.append(o.get(i).toString() + ":" + o.get(i + 1))
|
||||||
sb.append(o.get(i).toString() + ":" + o.get(i + 1))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return "{$name $sb}"
|
||||||
val s : String get() = "{${name} ${sb}}"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,7 @@ package com.beust.kobalt.plugin.java
|
||||||
import com.beust.kobalt.api.Dependencies
|
import com.beust.kobalt.api.Dependencies
|
||||||
import com.beust.kobalt.api.Project
|
import com.beust.kobalt.api.Project
|
||||||
import com.beust.kobalt.api.annotation.Directive
|
import com.beust.kobalt.api.annotation.Directive
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.toString
|
||||||
import com.beust.kobalt.misc.ToString
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
public class JavaProject(
|
public class JavaProject(
|
||||||
@Directive
|
@Directive
|
||||||
|
@ -29,6 +27,6 @@ public class JavaProject(
|
||||||
: Project(name, version, directory, buildDirectory, group, artifactId, packaging, dependencies,
|
: Project(name, version, directory, buildDirectory, group, artifactId, packaging, dependencies,
|
||||||
".java", JavaCompilerInfo()) {
|
".java", JavaCompilerInfo()) {
|
||||||
|
|
||||||
override public fun toString() = ToString("JavaProject", "name", name!!).s
|
override public fun toString() = toString("JavaProject", "name", name!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
package com.beust.kobalt.plugin.kotlin
|
package com.beust.kobalt.plugin.kotlin
|
||||||
|
|
||||||
import com.beust.kobalt.api.Dependencies
|
import com.beust.kobalt.api.Dependencies
|
||||||
import com.beust.kobalt.api.ICompilerInfo
|
|
||||||
import com.beust.kobalt.api.Project
|
import com.beust.kobalt.api.Project
|
||||||
import com.beust.kobalt.api.annotation.Directive
|
import com.beust.kobalt.api.annotation.Directive
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.toString
|
||||||
import com.beust.kobalt.misc.ToString
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
public class KotlinProject(
|
public class KotlinProject(
|
||||||
@Directive
|
@Directive
|
||||||
|
@ -30,5 +27,5 @@ public class KotlinProject(
|
||||||
: Project(name, version, directory, buildDirectory, group, artifactId, packaging, dependencies, ".kt",
|
: Project(name, version, directory, buildDirectory, group, artifactId, packaging, dependencies, ".kt",
|
||||||
KotlinCompilerInfo()) {
|
KotlinCompilerInfo()) {
|
||||||
|
|
||||||
override public fun toString() = ToString("KotlinProject", "name", name!!).s
|
override public fun toString() = toString("KotlinProject", "name", name!!)
|
||||||
}
|
}
|
||||||
|
|
|
@ -358,11 +358,10 @@ class IncludedFile(val fromOriginal: From, val toOriginal: To, val specs: List<I
|
||||||
constructor(specs: List<IFileSpec>) : this(From(""), To(""), specs)
|
constructor(specs: List<IFileSpec>) : this(From(""), To(""), specs)
|
||||||
public val from: String get() = fromOriginal.path.replace("\\", "/")
|
public val from: String get() = fromOriginal.path.replace("\\", "/")
|
||||||
public val to: String get() = toOriginal.path.replace("\\", "/")
|
public val to: String get() = toOriginal.path.replace("\\", "/")
|
||||||
override public fun toString() = ToString("IncludedFile",
|
override public fun toString() = toString("IncludedFile",
|
||||||
"files", specs.map { it.toString() }.joinToString(", "),
|
"files", specs.map { it.toString() }.joinToString(", "),
|
||||||
"from", from,
|
"from", from,
|
||||||
"to", to)
|
"to", to)
|
||||||
.s
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AttributeHolder {
|
interface AttributeHolder {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue