Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
a2ea25e0
提交
a2ea25e0
authored
14 年前
作者:
christian.peter.io
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Automatic database upgrade from non page store is now possible
上级
a1af0259
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
18 行增加
和
22 行删除
+18
-22
UpgradeCreator.java
h2/src/tools/org/h2/build/upgrade/UpgradeCreator.java
+18
-22
没有找到文件。
h2/src/tools/org/h2/build/upgrade/UpgradeCreator.java
浏览文件 @
a2ea25e0
...
...
@@ -20,6 +20,8 @@ public class UpgradeCreator {
*
* @param args the command line parameters
*/
private
static
String
[]
TEXTFILE_EXTENSIONS
=
{
".java"
,
".xml"
,
".bat"
,
".sh"
,
".txt"
,
".html"
,
".csv"
};
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
args
.
length
!=
2
)
{
System
.
out
.
println
(
"Usage: java -cp . org.h2.build.upgrade.UpgradeCreator <srcDir> <destDir>"
);
...
...
@@ -58,41 +60,35 @@ public class UpgradeCreator {
}
else
{
byte
[]
content
=
BuildBase
.
readFile
(
file
);
String
contentString
=
new
String
(
content
);
if
(
file
.
getName
().
endsWith
(
".java"
))
{
contentString
=
replaceInJavaFile
(
file
,
contentString
);
}
if
(
file
.
getName
().
equals
(
"build.sh"
)
||
file
.
getName
().
equals
(
"build.bat"
)
||
file
.
getName
().
equals
(
"build.xml"
))
{
contentString
=
contentString
.
replaceAll
(
"org\\.h2\\.build"
,
"org.h2.upgrade.v1_1.build"
);
contentString
=
contentString
.
replaceAll
(
"org/h2/"
,
"org/h2/upgrade/v1_1/"
);
if
(
isTextFile
(
file
))
{
contentString
=
replace
(
file
,
contentString
);
}
content
=
contentString
.
getBytes
();
BuildBase
.
writeFile
(
fileInDestDir
,
content
);
}
}
private
static
String
replaceInJavaFile
(
File
file
,
String
content
)
{
content
=
content
.
replaceAll
(
"import org\\.h2"
,
"import org.h2.upgrade.v1_1"
);
content
=
content
.
replaceAll
(
"import static org\\.h2"
,
"import static org.h2.upgrade.v1_1"
);
content
=
content
.
replaceAll
(
"package org\\.h2"
,
"package org.h2.upgrade.v1_1"
);
content
=
content
.
replaceAll
(
"org\\.h2\\.samples"
,
"org.h2.upgrade.v1_1.samples"
);
content
=
content
.
replaceAll
(
"org\\.h2\\.tools"
,
"org.h2.upgrade.v1_1.tools"
);
content
=
content
.
replaceAll
(
"org\\.h2\\.mode"
,
"org.h2.upgrade.v1_1.mode"
);
content
=
content
.
replaceAll
(
"org\\.h2\\.Driver\\.load\\(\\)"
,
"org.h2.upgrade.v1_1.Driver.load()"
);
content
=
content
.
replaceAll
(
"org\\.h2\\.Driver\\.unload\\(\\)"
,
"org.h2.upgrade.v1_1.Driver.unload()"
);
private
static
String
replace
(
File
file
,
String
content
)
{
content
=
content
.
replaceAll
(
"org\\.h2"
,
"org.h2.upgrade.v1_1"
);
content
=
content
.
replaceAll
(
"org/h2/"
,
"org/h2/upgrade/v1_1/"
);
content
=
content
.
replaceAll
(
"jdbc:h2:"
,
"jdbc:h2v1_1:"
);
if
(
file
.
getName
().
equals
(
"ConnectionInfo.java"
))
{
content
=
content
.
replaceAll
(
"boolean isPersistent\\(\\) \\{"
,
"public boolean isPersistent() {"
);
content
=
content
.
replaceAll
(
"String getName\\(\\) throws SQLException \\{"
,
"public String getName() throws SQLException {"
);
}
if
(
file
.
getName
().
equals
(
"Constants.java"
))
{
content
=
content
.
replaceAll
(
"public static final String START_URL = \"jdbc:h2:\";"
,
"public static final String START_URL = \"jdbc:h2v1_1:\";"
);
}
if
(
file
.
getName
().
equals
(
"SessionRemote.java"
))
{
content
=
content
.
replaceAll
(
"org\\.h2\\.engine\\.SessionFactoryEmbedded"
,
"org.h2.upgrade.v1_1.engine.SessionFactoryEmbedded"
);
}
return
content
;
}
private
static
boolean
isTextFile
(
File
file
)
{
for
(
String
extension
:
TEXTFILE_EXTENSIONS
)
{
if
(
file
.
getName
().
toLowerCase
().
endsWith
(
extension
))
{
return
true
;
}
}
return
false
;
}
}
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论