build.gradle 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. buildscript {
  2. repositories {
  3. mavenLocal()
  4. mavenCentral()
  5. maven { url 'http://mvn.revoltsoft.ru/' }
  6. maven { url 'https://plugins.gradle.org/m2/' }
  7. }
  8. dependencies {
  9. classpath 'gradle.plugin.com.dorongold.plugins:task-tree:1.5'
  10. }
  11. }
  12. repositories {
  13. mavenLocal()
  14. mavenCentral()
  15. maven { url 'http://mvn.revoltsoft.ru/' }
  16. }
  17. group = 'pro.doczilla'
  18. version = '1.0'
  19. def distDir = "${projectDir}/dist"
  20. buildDir = "${projectDir}/target"
  21. def srcDir = "src"
  22. ext.srcMainDir = "${srcDir}"
  23. ext.resolveGroups = ['pro.doczilla']
  24. def windows = org.apache.tools.ant.taskdefs.condition.Os.isFamily(org.apache.tools.ant.taskdefs.condition.Os.FAMILY_WINDOWS)
  25. ext.npmCmd = windows ? 'npm.cmd' : 'npm'
  26. ext.nodeCmd = windows ? 'node.exe' : 'node'
  27. apply plugin: 'eclipse'
  28. apply plugin: 'maven-publish'
  29. apply plugin: 'distribution'
  30. apply plugin: 'com.dorongold.task-tree'
  31. task copySources {
  32. copy {
  33. from file("${projectDir}/package.json")
  34. into file(buildDir)
  35. }
  36. copy {
  37. from file("${distDir}")
  38. into file("${buildDir}/build/")
  39. }
  40. }
  41. task npmInstall(type: Exec) {
  42. workingDir projectDir
  43. commandLine npmCmd, 'install'
  44. }
  45. task npmInstallProduction(type: Exec) {
  46. dependsOn copySources
  47. workingDir buildDir
  48. commandLine npmCmd, 'install', '--production=true'
  49. }
  50. task buildJs(type: Exec) {
  51. workingDir projectDir
  52. executable npmCmd
  53. args = ['run', 'buildProd']
  54. }
  55. task run(type: Exec) {
  56. dependsOn assemble
  57. workingDir "${buildDir}/build"
  58. commandLine nodeCmd, 'index.js'
  59. }
  60. static def today() {
  61. return new Date().format('yyyyMMddHHmm')
  62. }
  63. distZip {
  64. archiveClassifier = today()
  65. }
  66. project.tasks.distZip.dependsOn project.tasks.npmInstallProduction
  67. distributions {
  68. main {
  69. contents {
  70. from(buildDir) {
  71. include 'node_modules/**'
  72. }
  73. from("${buildDir}/build")
  74. }
  75. }
  76. }
  77. apply from: 'docker.gradle'