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' def distDir = "${projectDir}/dist" 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' 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("${distDir}") into file("${buildDir}/build/") } } task npmInstall(type: Exec) { workingDir projectDir commandLine npmCmd, 'install' } task npmInstallProduction(type: Exec) { dependsOn copySources workingDir buildDir commandLine npmCmd, 'install', '--production=true' } task buildJs(type: Exec) { workingDir projectDir 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.distZip.dependsOn project.tasks.npmInstallProduction distributions { main { contents { from(buildDir) { include 'node_modules/**' } from("${buildDir}/build") } } } apply from: 'docker.gradle'