Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
287d8ebb
Commit
287d8ebb
authored
Nov 18, 2018
by
fengshuonan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新
parent
f4974216
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
6 deletions
+40
-6
src/main/java/cn/stylefeng/guns/MavenDeployLocalFile.java
+40
-6
No files found.
src/main/java/cn/stylefeng/guns/MavenDeployLocalFile.java
View file @
287d8ebb
package
cn
.
stylefeng
.
guns
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -12,12 +13,12 @@ public class MavenDeployLocalFile {
/**
* 当前工作目录
*/
private
String
CURRENT_PATH
=
"/Users/stylefeng/
tmp
/"
;
private
String
CURRENT_PATH
=
"/Users/stylefeng/
work/repository
/"
;
/**
* 仓库的地址
*/
private
String
REPO_PATH
=
"/Users/stylefeng/
tmp/share
"
;
private
String
REPO_PATH
=
"/Users/stylefeng/
work/repository
"
;
/**
* maven的settings文件配置路径
...
...
@@ -34,6 +35,8 @@ public class MavenDeployLocalFile {
*/
private
String
REPOSITORY_URL
=
"http://172.23.2.3:8081/repository/maven-host-sedinBJ/"
;
private
List
<
String
>
finalCommands
=
new
ArrayList
<>();
/**
* 递归获取一个目录下的所有文件目录路径
*
...
...
@@ -167,6 +170,9 @@ public class MavenDeployLocalFile {
doOnlyPom
(
directory
);
}
}
//输出文件
writeToFile
(
"/Users/stylefeng/tmp/bash.sh"
,
finalCommands
);
}
/**
...
...
@@ -177,15 +183,43 @@ public class MavenDeployLocalFile {
*/
private
void
executeCommand
(
String
command
)
{
try
{
Process
exec
=
Runtime
.
getRuntime
().
exec
(
command
);
int
i
=
exec
.
waitFor
();
System
.
out
.
println
(
"执行结果:"
+
i
);
}
catch
(
IOException
|
InterruptedException
e
)
{
System
.
out
.
println
(
command
);
finalCommands
.
add
(
command
);
//Process exec = Runtime.getRuntime().exec(command);
//int i = exec.waitFor();
//System.out.println("执行结果:" + i);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
/**
* 写出到文件
*
* @author fengshuonan
* @Date 2018/11/18 1:04 PM
*/
private
void
writeToFile
(
String
path
,
List
<
String
>
lists
)
{
File
file
=
new
File
(
path
);
FileWriter
fileWriter
=
null
;
try
{
fileWriter
=
new
FileWriter
(
file
);
for
(
String
list
:
lists
)
{
fileWriter
.
write
(
list
+
"\n"
);
}
fileWriter
.
flush
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
fileWriter
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
/**
* 构造command命令
*
* @author fengshuonan
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment