configurations {
    sshAntTask
}

dependencies {
    sshAntTask 'org.apache.ant:ant-jsch:1.9.2'
}

# Task Tạo file jar
jar {
    baseName 'xxx' # Tên file

    doFirst {
        zip64 = true # Zip type
    }

    exclude 'META-INF/*.RSA', 'META-INF/*SF', 'META-INF/*.DSA'

    # Main class
    manifest {
        attributes 'Main-Class' : xxx 
    }

    # Tập hợp các dependency phụ thuộc
    from configuration.compile.collect {
        it.isDirectory() ? it : zipTree(it)
    }
}

ant.taskdef {
    name: 'scp'
    classname: 'org.apache.tools.ant.taskdefs.optional.ssh.Scp',
    classpath: configurations.sshAntTask.asPath
}

# Task copy file jar tới server test
# Bằng cách sử dụng ssh scp
task scpJar() {
    doLast {
        file: file("xxx"), # Path file cần copy
        trust: true, 
        todir: 'user@server_ip:/home/'  # <user name>@<Server IP>:/Path thư mục đích
        password: 'xxx' # Mật khẩu
    }
}

Sliding Sidebar

About Me

About Me

Hello, my name is Dũng (Johnny). Welcome to my blog.

As I’m a developer, I write about topics related to the field of programming, mainly from a technical point of view. On this blog you’ll find posts which encourage discussion, information about development trends, case studies, reviews, tutorials, tips on how to improve your effectiveness, and anything else that might be fascinating to people from the IT industry.
I love PHP, NodeJS, Java,... and Fullstack.