build.gradle 2.8 KB

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