Code Monkey home page Code Monkey logo

wttech / gradle-common-plugin Goto Github PK

View Code? Open in Web Editor NEW
4.0 10.0 2.0 533 KB

Provides generic purpose Gradle utilities like: file transfer (upload/download) via SMB/SFTP/HTTP, file watcher, asynchronous progress logger, GUI notification service

License: Apache License 2.0

Kotlin 87.16% Shell 2.14% Java 10.70%
gradle gradle-plugin http-client sftp-client smb-client gui-notification-service file-upload file-download async-process progress-indicator

gradle-common-plugin's Introduction

WTT logo

Gradle Status Apache License, Version 2.0, January 2004

Gradle Common Plugin

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 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.

Usage

Use common extension to implement any custom Gradle task with improved UX:

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:

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")

gradle-common-plugin's People

Contributors

github-actions[bot] avatar jaroslaw-pietraszek-wttech avatar jean-khechfe-wttech avatar krystian-panek-wttech avatar pun-ky avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

tchigher sodevel

gradle-common-plugin's Issues

Downloader time left improvement

right now, estimated time left is calculated basing on the total already downloaded bytes and remaining bytes.

Instead, it should be estimated basing on download speed in some recent time window

Values are not read from environment variables when using PropertyParser starting with Version 1.1.8

Dear Developers,

starting with version 1.1.8 we cannot use the library anymore when using the PropertyParser to read environment variables. The same code, that works with version 1.1.7, returns a null value starting with version 1.1.8.

Example code:
val mavenUrl = common.prop.string("GSMavenUrl")

After looking through the commits, I found that this behavior was introduced in the commit
3953857
which uses ToUpperSnakeCase() to reformat the name of the property.

In our company, we have a different CaseStyle for our environment variables and it is not feasible for us to rename all our environment variables.

Is it possible to suppress this new behavior via a configuration value or a parameter?

Kind Regards,

Compile avoidance fix

Cannot use Kotlin build script compile avoidance with /root/.gradle/caches/jars-8/7b0d7c336733c3794e6ea657090dc896/common-plugin-1.0.3.jar: class com/cognifide/gradle/common/tasks/TaskFacade: inline fun get(): compile avoidance is not supported with public inline functions

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.