From 77808aa67b9becc7c95e2d2c7ca0e881376c7b4b Mon Sep 17 00:00:00 2001 From: DmitriyMX Date: Thu, 10 Jan 2019 18:13:45 +0300 Subject: [PATCH] gradle: add task deploy --- build.gradle | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/build.gradle b/build.gradle index ccd332c..afccda9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,6 @@ +import java.nio.file.Files +import java.nio.file.Paths + buildscript { repositories { maven { url "https://plugins.gradle.org/m2/" } @@ -84,6 +87,43 @@ subprojects { task cleanDep(type: Delete) { delete 'libs' } + + /** + * Сборка + */ + task deploy() { + dependsOn { jar } + + doLast { + def deployDir = System.getProperty("deploy") + if (deployDir == null) { + println "Need param -Ddeploy=path/to/deploy" + throw new Exception("Need param -Ddir=path/to/deploy") + } + + def target = Paths.get(deployDir, jar.archivePath.getName()) + if (Files.notExists(target)) { + println jar.archivePath + Files.copy(jar.archivePath.toPath(), target) + } + + + + def libsDir = System.getProperty("libs", deployDir+File.separator+"libs") + if (Files.notExists(Paths.get(libsDir))) { + (new File(libsDir)).mkdirs() + } + + def libsCollection = configurations.compile + configurations.runtime - configurations.compile_excludeCopy + libsCollection.each{ libFile -> + target = Paths.get(libsDir, libFile.getName()) + if (Files.notExists(target)) { + println libFile + Files.copy(libFile.toPath(), target) + } + } + } + } } /**