app.softwork.kobol.gradle.UploadTask.kt Maven / Gradle / Ivy
package app.softwork.kobol.gradle
import org.gradle.api.file.*
import org.gradle.api.provider.*
import org.gradle.api.tasks.*
import org.gradle.api.tasks.PathSensitivity.*
import org.gradle.work.*
@CacheableTask
public abstract class UploadTask : SshTask() {
@get:Incremental
@get:PathSensitive(RELATIVE)
@get:InputFiles
public abstract val files: ConfigurableFileCollection
@get:Optional
@get:Input
public abstract val encoding: Property
init {
encoding.convention("ibm-1047")
}
@get:Optional
@get:Input
public abstract val mvsFolder: Property
@get:Optional
@get:Input
public abstract val keepUTF8: Property
init {
keepUTF8.convention(false)
}
@get:Optional
@get:PathSensitive(RELATIVE)
@get:InputFiles
public abstract val mvsFiles: ConfigurableFileCollection
@get:OutputDirectory
public abstract val uploaded: DirectoryProperty
init {
uploaded.convention(project.layout.buildDirectory.dir("kobol/uploaded"))
}
@get:Input
@get:Optional
public abstract val notTagged: ListProperty
init {
notTagged.convention(listOf("jar", "class"))
}
@TaskAction
internal fun execute(inputChanges: InputChanges) {
val queue = workerExecutor.classLoaderIsolation {
classpath.setFrom(sshClasspath)
}
for (change in inputChanges.getFileChanges(files)) {
if (change.fileType == FileType.DIRECTORY) continue
val changeType: ChangeType = change.changeType
when (changeType) {
ChangeType.ADDED, ChangeType.MODIFIED -> {
queue.submit(UploadAction::class.java) {
user.set([email protected])
host.set([email protected])
folder.set([email protected])
file.set(change.file)
encoding.set([email protected])
mvsFolder.set([email protected])
keepUTF8.set([email protected])
mvsFiles.from([email protected])
uploaded.set([email protected])
notTagged.set([email protected])
}
}
ChangeType.REMOVED -> {
queue.submit(DeleteAction::class.java) {
user.set([email protected])
host.set([email protected])
folder.set([email protected])
file.set(change.file)
}
}
}
}
}
}