buildscript { repositories { mavenLocal() mavenCentral() maven { url 'http://mvn.revoltsoft.ru/' } maven { url 'https://plugins.gradle.org/m2/' } } dependencies { classpath 'gradle.plugin.com.dorongold.plugins:task-tree:1.5' } } repositories { mavenLocal() mavenCentral() maven { url 'http://mvn.revoltsoft.ru/' } } group = 'pro.doczilla' version = '1.0' buildDir = "${projectDir}/target" def srcDir = "src" ext.srcMainDir = "${srcDir}" ext.resolveGroups = ['pro.doczilla'] def windows = org.apache.tools.ant.taskdefs.condition.Os.isFamily(org.apache.tools.ant.taskdefs.condition.Os.FAMILY_WINDOWS) ext.npmCmd = windows ? 'npm.cmd' : 'npm' ext.nodeCmd = windows ? 'node.exe' : 'node' def gitDefaults = [ outerProtocol: 'http', adminPassword: '', gitHost: '', // excluding protocol commentsRepoUrl: '', // part after gitHost gitUsername: '', gitEmail: '', gitPassword: '' ].each { if (!project.hasProperty(it.key)) ext[it.key] = it.value } apply plugin: 'eclipse' apply plugin: 'maven-publish' apply plugin: 'distribution' apply plugin: 'com.dorongold.task-tree' task copySources { copy { from file("${projectDir}/package.json") into file(buildDir) } copy { from file("${projectDir}/tsconfig.json") into file(buildDir) } copy { from file("${projectDir}/config.json") into file(buildDir) expand(outerProtocol: outerProtocol, commentsRepoUrl: commentsRepoUrl, adminPassword: adminPassword, gitHost: gitHost) } copy { from file(projectDir) include "*.tmpl" into file(buildDir) rename { fileName -> fileName.replace('.tmpl', '') } expand(outerProtocol: outerProtocol, commentsRepoUrl: commentsRepoUrl, gitUsername: gitUsername, gitEmail: gitEmail, gitPassword: gitPassword, gitHost: gitHost) } copy { from file("${projectDir}/src") into file("${buildDir}/src") } copy { from file("${projectDir}/node_scripts") into file("${buildDir}/node_scripts") } copy { from file("${projectDir}/static") into file("${buildDir}/static") } } task npmInstall(type: Exec) { dependsOn copySources workingDir buildDir commandLine npmCmd, 'install' } task buildTs(type: Exec) { dependsOn npmInstall workingDir buildDir executable npmCmd args = ['run', 'buildProd'] } task run(type: Exec) { dependsOn assemble workingDir "${buildDir}/build" commandLine nodeCmd, 'index.js' } static def today() { return new Date().format('yyyyMMddHHmm') } distZip { archiveClassifier = today() } project.tasks.assemble.dependsOn project.tasks.buildTs project.tasks.distZip.dependsOn project.tasks.buildTs project.tasks.distTar.dependsOn project.tasks.buildTs project.tasks.installDist.dependsOn project.tasks.buildTs distributions { main { contents { from(buildDir) { include 'node_modules/**' } from("${buildDir}/build") } } } apply from: 'docker.gradle'