gradle: add task deploy
This commit is contained in:
40
build.gradle
40
build.gradle
@@ -1,3 +1,6 @@
|
|||||||
|
import java.nio.file.Files
|
||||||
|
import java.nio.file.Paths
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
maven { url "https://plugins.gradle.org/m2/" }
|
maven { url "https://plugins.gradle.org/m2/" }
|
||||||
@@ -84,6 +87,43 @@ subprojects {
|
|||||||
task cleanDep(type: Delete) {
|
task cleanDep(type: Delete) {
|
||||||
delete 'libs'
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user