-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathgulpfile.js
92 lines (74 loc) · 2.66 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
var gulp = require('gulp');
var zip = require('gulp-zip');
var process = require('child_process');
var fs = require('fs');
const PACKAGE_NAME = "sany-app";
const PACKAGE_WAR_NAME = `${PACKAGE_NAME}.war`;
// maven 配置信息
const publishConfig = {
command: "mvn",
repositoryId: "iUAP-Snapshots",
repositoryURL: "http://172.16.51.12:8081/nexus/content/repositories/iUAP-Snapshots",
artifactId: PACKAGE_NAME,
groupId: "com.yonyou.sany",
version: "1.0.1-SNAPSHOT"
};
/**
* 打包为war
* @param {[type]} "package" [description]
* @param {[type]} function( [description]
* @return {[type]} [description]
*/
gulp.task("package", function(){
return gulp.src('./dist/**')
.pipe(zip(PACKAGE_WAR_NAME))
.pipe(gulp.dest('./'));
});
/**
* install 到本地
* @param {[type]} "install" [description]
* @param {[type]} function( [description]
* @return {[type]} [description]
*/
gulp.task("install", ["package"], function(){
var targetPath = fs.realpathSync('.');
const { command, repositoryId, groupId, artifactId, version, repositoryURL } = publishConfig;
// 安装命令
var installCommandStr = `${command} install:install-file -Dfile=${targetPath}/${PACKAGE_WAR_NAME} -DgroupId=${groupId} -DartifactId=${artifactId} -Dversion=${version} -Dpackaging=war`;
var installWarProcess = process.exec(installCommandStr, function(err,stdout,stderr){
if(err) {
console.log('install war error:'+stderr);
}
});
installWarProcess.stdout.on('data',function(data){
console.info(data);
});
installWarProcess.on('exit',function(data){
console.info('install war success');
})
});
/**
* 发布到maven仓库中
* @param {[type]} "deploy" [description]
* @param {[type]} ["package"] [description]
* @param {[type]} function( [description]
* @return {[type]} [description]
*/
gulp.task("deploy", ["install"], function(){
var targetPath = fs.realpathSync('.');
const { command, repositoryId, groupId, artifactId, version, repositoryURL } = publishConfig;
var publishCommandStr = `${command} deploy:deploy-file -Dfile=${targetPath}/${PACKAGE_WAR_NAME} -DgroupId=${groupId} -DartifactId=${artifactId} -Dversion=${version} -Dpackaging=war -DrepositoryId=${repositoryId} -Durl=${repositoryURL}`;
console.info(publishCommandStr);
var publishWarProcess = process.exec(publishCommandStr, function(err,stdout,stderr){
if(err) {
console.log('publish war error:'+stderr);
}
});
publishWarProcess.stdout.on('data',function(data){
console.info(data);
});
publishWarProcess.on('exit',function(data){
console.info('publish war success');
});
})
gulp.task('default', [ 'deploy']);