build.gradle 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. buildDir = "${projectDir}/target"
  20. def srcDir = "src"
  21. ext.srcMainDir = "${srcDir}"
  22. ext.resolveGroups = ['pro.doczilla']
  23. def windows = org.apache.tools.ant.taskdefs.condition.Os.isFamily(org.apache.tools.ant.taskdefs.condition.Os.FAMILY_WINDOWS)
  24. ext.npmCmd = windows ? 'npm.cmd' : 'npm'
  25. ext.nodeCmd = windows ? 'node.exe' : 'node'
  26. def gitDefaults = [
  27. adminPassword: '',
  28. gitHost: '', // excluding protocol
  29. commentsRepoUrl: '', // part after gitHost
  30. gitUsername: '',
  31. gitEmail: '',
  32. gitPassword: ''
  33. ].each {
  34. if (!project.hasProperty(it.key))
  35. ext[it.key] = it.value
  36. }
  37. apply plugin: 'eclipse'
  38. apply plugin: 'maven-publish'
  39. apply plugin: 'distribution'
  40. apply plugin: 'com.dorongold.task-tree'
  41. task copySources {
  42. copy {
  43. from file("${projectDir}/package.json")
  44. into file(buildDir)
  45. }
  46. copy {
  47. from file("${projectDir}/tsconfig.json")
  48. into file(buildDir)
  49. }
  50. copy {
  51. from file("${projectDir}/config.json")
  52. into file(buildDir)
  53. expand(commentsRepoUrl: commentsRepoUrl, adminPassword: adminPassword, gitHost: gitHost)
  54. }
  55. copy {
  56. from file(projectDir)
  57. include "*.tmpl"
  58. into file(buildDir)
  59. rename { fileName -> fileName.replace('.tmpl', '') }
  60. expand(commentsRepoUrl: commentsRepoUrl, gitUsername: gitUsername, gitEmail: gitEmail, gitPassword: gitPassword, gitHost: gitHost)
  61. }
  62. copy {
  63. from file("${projectDir}/src")
  64. into file("${buildDir}/src")
  65. }
  66. copy {
  67. from file("${projectDir}/node_scripts")
  68. into file("${buildDir}/node_scripts")
  69. }
  70. copy {
  71. from file("${projectDir}/static")
  72. into file("${buildDir}/static")
  73. }
  74. }
  75. task npmInstall(type: Exec) {
  76. dependsOn copySources
  77. workingDir buildDir
  78. commandLine npmCmd, 'install'
  79. }
  80. task buildTs(type: Exec) {
  81. dependsOn npmInstall
  82. workingDir buildDir
  83. executable npmCmd
  84. args = ['run', 'buildProd']
  85. }
  86. task run(type: Exec) {
  87. dependsOn assemble
  88. workingDir "${buildDir}/build"
  89. commandLine nodeCmd, 'index.js'
  90. }
  91. static def today() {
  92. return new Date().format('yyyyMMddHHmm')
  93. }
  94. distZip {
  95. archiveClassifier = today()
  96. }
  97. project.tasks.assemble.dependsOn project.tasks.buildTs
  98. project.tasks.distZip.dependsOn project.tasks.buildTs
  99. project.tasks.distTar.dependsOn project.tasks.buildTs
  100. project.tasks.installDist.dependsOn project.tasks.buildTs
  101. distributions {
  102. main {
  103. contents {
  104. from(buildDir) {
  105. include 'node_modules/**'
  106. }
  107. from("${buildDir}/build")
  108. }
  109. }
  110. }
  111. apply from: 'docker.gradle'