Giter Club home page Giter Club logo

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

Watchers

 avatar

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.