Skip to content

Commit

Permalink
优化构建日志打印
Browse files Browse the repository at this point in the history
  • Loading branch information
b7woreo committed Dec 23, 2023
1 parent 5a8075a commit a9d75c2
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion gradle-plugin/src/main/java/tracex/TraceTransformTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ abstract class TraceTransformTask : DefaultTask() {

@TaskAction
fun transform(inputChanges: InputChanges) {
val incremental = inputChanges.isIncremental
if (!incremental) {
println("Full build mode")
} else {
println("Incremental build mode")
}

val workQueue = workerExecutor.noIsolation()
val intermediate = intermediate.get().asFile

Expand Down Expand Up @@ -113,6 +120,7 @@ abstract class TraceTransformTask : DefaultTask() {
it.source.set(changedJar.file)
it.changeType.set(ChangeType.MODIFIED)
it.intermediate.set(intermediate)
it.loggable.set(inputChanges.isIncremental)
}
}
}
Expand All @@ -125,6 +133,7 @@ abstract class TraceTransformTask : DefaultTask() {
it.source.set(changedClass.file)
it.changeType.set(changedClass.changeType)
it.intermediate.set(intermediate)
it.loggable.set(inputChanges.isIncremental)
}
}
}
Expand Down Expand Up @@ -161,12 +170,17 @@ abstract class TraceTransformTask : DefaultTask() {
protected val intermediate: File
get() = parameters.intermediate.get().asFile

protected val loggable: Boolean
get() = parameters.loggable.get()

protected abstract val destination: File

protected abstract fun transform()

final override fun execute() {
println("[$changeType] $source -> $destination")
if (loggable) {
println("[$changeType] $source -> $destination")
}

when (changeType) {
ChangeType.ADDED -> {
Expand Down Expand Up @@ -220,6 +234,7 @@ abstract class TraceTransformTask : DefaultTask() {
val source: RegularFileProperty
val changeType: Property<ChangeType>
val intermediate: DirectoryProperty
val loggable: Property<Boolean>
}
}

Expand Down

0 comments on commit a9d75c2

Please sign in to comment.