Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mysql-generator
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙长纪
mysql-generator
Commits
84d69d03
Commit
84d69d03
authored
Apr 01, 2019
by
孙长纪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改module的根路径获取
parent
ddb69831
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
28 deletions
+22
-28
build.gradle
build.gradle
+1
-1
PathUtils.java
...in/java/cn/com/duiba/mysql/generator/utils/PathUtils.java
+21
-27
No files found.
build.gradle
View file @
84d69d03
...
@@ -18,7 +18,7 @@ apply plugin: "idea"
...
@@ -18,7 +18,7 @@ apply plugin: "idea"
apply
plugin:
"eclipse"
apply
plugin:
"eclipse"
group
=
"cn.com.duiba"
group
=
"cn.com.duiba"
version
=
"0.0.
1
"
version
=
"0.0.
2
"
sourceCompatibility
=
1.8
sourceCompatibility
=
1.8
targetCompatibility
=
1.8
targetCompatibility
=
1.8
...
...
src/main/java/cn/com/duiba/mysql/generator/utils/PathUtils.java
View file @
84d69d03
...
@@ -5,35 +5,29 @@ import cn.com.duiba.mysql.generator.exceptions.DuibaGeneratorException;
...
@@ -5,35 +5,29 @@ import cn.com.duiba.mysql.generator.exceptions.DuibaGeneratorException;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
java.io.File
;
import
java.io.File
;
import
java.net.URL
;
public
class
PathUtils
{
public
class
PathUtils
{
private
PathUtils
()
{
private
PathUtils
()
{
//X Y
//X Y
}
}
private
static
String
getProjectHome
(){
private
static
String
getProjectHome
()
{
ClassLoader
loader
=
PathUtils
.
class
.
getClassLoader
();
return
System
.
getProperty
(
"user.dir"
);
URL
url
=
loader
.
getResource
(
""
);
String
file
=
url
.
getFile
();
File
testPath
=
new
File
(
file
);
return
testPath
.
getParentFile
().
getParent
();
}
}
/**
/**
* 根据包名找到包的实际路径
* 根据包名找到包的实际路径
*
* @param packageName 包名,例如:cn.com.duiba.shark.gitlab.dao
* @param packageName 包名,例如:cn.com.duiba.shark.gitlab.dao
* @return 包的文件路径
* @return 包的文件路径
*/
*/
public
static
String
getPathByPackage
(
String
packageName
,
GeneratorConfig
config
)
{
public
static
String
getPathByPackage
(
String
packageName
,
GeneratorConfig
config
)
{
if
(
StringUtils
.
isEmpty
(
packageName
))
{
if
(
StringUtils
.
isEmpty
(
packageName
))
{
throw
new
DuibaGeneratorException
(
"包名不能为空"
);
throw
new
DuibaGeneratorException
(
"包名不能为空"
);
}
}
if
(
StringUtils
.
isEmpty
(
config
.
getModuleName
()))
{
if
(
StringUtils
.
isEmpty
(
config
.
getModuleName
()))
{
return
"src/main/java/"
+
StringUtils
.
replace
(
packageName
,
"."
,
"/"
);
return
"src/main/java/"
+
StringUtils
.
replace
(
packageName
,
"."
,
"/"
);
}
else
{
return
config
.
getModuleName
()
+
File
.
separator
+
"src/main/java/"
+
StringUtils
.
replace
(
packageName
,
"."
,
"/"
);
}
}
return
getProjectHome
()+
File
.
separator
+
config
.
getModuleName
()
+
File
.
separator
+
"src/main/java/"
+
StringUtils
.
replace
(
packageName
,
"."
,
"/"
);
}
}
}
}
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