Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wttech/gradle-common-plugin
Provides generic purpose Gradle utilities like: file transfer (upload/download) via SMB/SFTP/HTTP, file watcher, asynchronous progress logger, GUI notification service
https://github.com/wttech/gradle-common-plugin
async-process file-download file-upload gradle gradle-plugin gui-notification-service http-client progress-indicator sftp-client smb-client
Last synced: 2 months ago
JSON representation
Provides generic purpose Gradle utilities like: file transfer (upload/download) via SMB/SFTP/HTTP, file watcher, asynchronous progress logger, GUI notification service
- Host: GitHub
- URL: https://github.com/wttech/gradle-common-plugin
- Owner: wttech
- License: apache-2.0
- Created: 2020-01-30T09:49:53.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-07-05T16:37:41.000Z (over 1 year ago)
- Last Synced: 2023-09-30T13:25:28.597Z (over 1 year ago)
- Topics: async-process, file-download, file-upload, gradle, gradle-plugin, gui-notification-service, http-client, progress-indicator, sftp-client, smb-client
- Language: Kotlin
- Homepage:
- Size: 521 KB
- Stars: 4
- Watchers: 10
- Forks: 2
- Open Issues: 11
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
[![WTT logo](docs/wtt-logo.png)](https://www.wundermanthompson.com)
[![Gradle Status](https://gradleupdate.appspot.com/wttech/gradle-common-plugin/status.svg)](https://gradleupdate.appspot.com/wtt/gradle-common-plugin/status)
[![Apache License, Version 2.0, January 2004](docs/apache-license-badge.svg)](http://www.apache.org/licenses/)# Gradle Common Plugin
* [About](#about)
* [Setup](#setup)
* [Usage](#usage)
* [Configuration](#configuration)
* [License](#license)## About
Provides generic purpose Gradle utilities like:
* File transfer (upload/download) via SMB/SFTP/HTTP,
* File watcher,
* Asynchronous progress logger,
* GUI notification service,
* Health checking service,
* Java toolchains service.All above exposed as `common` [extension](src/main/kotlin/com/cognifide/gradle/common/CommonExtension.kt) to your build scripts to be consumed by your own Gradle tasks.
## Setup
As of plugin is published at official Gradle Plugin Portal, see instructions from [there](https://plugins.gradle.org/plugin/com.cognifide.common).
## Usage
Use common extension to implement any custom Gradle task with improved UX:
```kotlin
tasks {
register("transferFile") {
doLast {
common {
// download file using unified file resolver with interactive progress logger
val mavenFile = resolveFile("some-group:some-package:1.0.0@zip") // Maven coordinates / Gradle dependency notation
val urlFile = resolveFile("sftp://my-file-storage.com/some/path/my-file.zip") // some HTTP/SMB/SFTP URL
// upload file using interactive progress logger
fileTransfer.upload("smb://other-file-storage/other/path", mavenFile)
fileTransfer.upload("sftp://yet-another-file-storage.com/other/path", urlFile)
notifier.info("Files transferred successfully!")
}
}
}register("calculateNums") {
doLast {
common {
// user input service is not available in public Gradle API however plugin is exposing it
if (userInput.askYesNoQuestion("Calc in parallel?")) {
val nums = listOf(1, 2, 3)
// do tasks in parallel using coroutines with interactive, async progress logger
progress(nums.size) {
parallel.each(nums) { num ->
increment("Calculating for '$num'")
waitFor(5000) // heavy calculation here
}
}
}
}
// this will freeze task a little bit but with showing nice countdown timer
progressCountdown(3_000)
notifier.info("Calculated successfully!")
}
}
}
}
```## Configuration
Illustrative example:
```kotlin
common {
fileTransfer {// default values for all protocols
user.set(prop.string("fileTransfer.user"))
password.set(prop.string("fileTransfer.password"))
domain.set(prop.string("fileTransfer.domain"))// protocol specific credentials
sftp {
user.set(prop.string("fileTransfer.sftp.user"))
password.set(prop.string("fileTransfer.sftp.password"))
}
smb {
user.set(prop.string("fileTransfer.smb.user"))
password.set(prop.string("fileTransfer.smb.password"))
domain.set(prop.string("fileTransfer.smb.domain"))
}
http {
client {
basicUser.set(prop.string("fileTransfer.http.user"))
basicPassword.set(prop.string("fileTransfer.http.password"))
}
}
}
notifier {
enabled.set(prop.boolean("notifier.enabled"))
}
}
```## License
**Gradle Common Plugin** is licensed under the [Apache License, Version 2.0 (the "License")](https://www.apache.org/licenses/LICENSE-2.0.txt)