diff --git a/build.gradle b/build.gradle index efd39ba..6927694 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) + } + } + } + } } /**