Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3f80639b
Unverified
提交
3f80639b
authored
5月 01, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
5月 01, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1108 from katzyn/SwitchSource
Get rid of SwitchSource
上级
8097e478
51722307
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
433 行增加
和
630 行删除
+433
-630
build.html
h2/src/docsrc/html/build.html
+0
-9
changelog.html
h2/src/docsrc/html/changelog.html
+6
-0
SysProperties.java
h2/src/main/org/h2/engine/SysProperties.java
+3
-10
Console.java
h2/src/main/org/h2/tools/Console.java
+19
-421
GUIConsole.java
h2/src/main/org/h2/tools/GUIConsole.java
+403
-0
TestTools.java
h2/src/test/org/h2/test/unit/TestTools.java
+2
-1
Build.java
h2/src/tools/org/h2/build/Build.java
+0
-25
SwitchSource.java
h2/src/tools/org/h2/build/code/SwitchSource.java
+0
-164
没有找到文件。
h2/src/docsrc/html/build.html
浏览文件 @
3f80639b
...
@@ -95,15 +95,6 @@ To run the build tool in shell mode, use the command line option <code>-</code>:
...
@@ -95,15 +95,6 @@ To run the build tool in shell mode, use the command line option <code>-</code>:
./build.sh -
./build.sh -
</pre>
</pre>
<h3>
Switching the Source Code
</h3>
<p>
The source code uses Java 7 features.
To switch the source code to the installed version of Java, run:
</p>
<pre>
build switchSource
</pre>
<h2
id=
"build_targets"
>
Build Targets
</h2>
<h2
id=
"build_targets"
>
Build Targets
</h2>
<p>
<p>
The build system can generate smaller jar files as well. The following targets are currently supported:
The build system can generate smaller jar files as well. The following targets are currently supported:
...
...
h2/src/docsrc/html/changelog.html
浏览文件 @
3f80639b
...
@@ -21,6 +21,10 @@ Change Log
...
@@ -21,6 +21,10 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul>
<ul>
<li>
Issue #1106: Get rid of SwitchSource
</li>
<li>
PR #1105: Assorted minor changes
</li>
<li>
Issue #1102: CREATE SYNONYM rejects valid definition
<li>
Issue #1102: CREATE SYNONYM rejects valid definition
</li>
</li>
<li>
Issue #1048: 1.4.197 regression. org.h2.jdbc.JdbcSQLException: Timeout trying to lock table "SYS"
<li>
Issue #1048: 1.4.197 regression. org.h2.jdbc.JdbcSQLException: Timeout trying to lock table "SYS"
...
@@ -35,6 +39,8 @@ Change Log
...
@@ -35,6 +39,8 @@ Change Log
</li>
</li>
<li>
Issue #230: Renaming a column does not update foreign key constraint
<li>
Issue #230: Renaming a column does not update foreign key constraint
</li>
</li>
<li>
Issue #1091 Get rid if the New class
</li>
<li>
PR #1087: improve performance of planning large queries
<li>
PR #1087: improve performance of planning large queries
</li>
</li>
<li>
Issue #394: Recover tool places COLLATION and BINARY_COLLATION after temporary tables
<li>
Issue #394: Recover tool places COLLATION and BINARY_COLLATION after temporary tables
...
...
h2/src/main/org/h2/engine/SysProperties.java
浏览文件 @
3f80639b
...
@@ -93,26 +93,19 @@ public class SysProperties {
...
@@ -93,26 +93,19 @@ public class SysProperties {
Utils
.
getProperty
(
"h2.bindAddress"
,
null
);
Utils
.
getProperty
(
"h2.bindAddress"
,
null
);
/**
/**
* System property <code>h2.check</code> (default: true).<br />
* System property <code>h2.check</code>
* (default: true for JDK/JRE, false for Android).<br />
* Assertions in the database engine.
* Assertions in the database engine.
*/
*/
//## CHECK ##
public
static
final
boolean
CHECK
=
public
static
final
boolean
CHECK
=
Utils
.
getProperty
(
"h2.check"
,
true
);
Utils
.
getProperty
(
"h2.check"
,
!
"0.9"
.
equals
(
Utils
.
getProperty
(
"java.specification.version"
,
null
)));
/*/
public static final boolean CHECK = false;
//*/
/**
/**
* System property <code>h2.check2</code> (default: false).<br />
* System property <code>h2.check2</code> (default: false).<br />
* Additional assertions in the database engine.
* Additional assertions in the database engine.
*/
*/
//## CHECK ##
public
static
final
boolean
CHECK2
=
public
static
final
boolean
CHECK2
=
Utils
.
getProperty
(
"h2.check2"
,
false
);
Utils
.
getProperty
(
"h2.check2"
,
false
);
/*/
public static final boolean CHECK2 = false;
//*/
/**
/**
* System property <code>h2.clientTraceDirectory</code> (default:
* System property <code>h2.clientTraceDirectory</code> (default:
...
...
h2/src/main/org/h2/tools/Console.java
浏览文件 @
3f80639b
差异被折叠。
点击展开。
h2/src/main/org/h2/tools/GUIConsole.java
0 → 100644
浏览文件 @
3f80639b
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestTools.java
浏览文件 @
3f80639b
...
@@ -50,6 +50,7 @@ import org.h2.tools.ChangeFileEncryption;
...
@@ -50,6 +50,7 @@ import org.h2.tools.ChangeFileEncryption;
import
org.h2.tools.Console
;
import
org.h2.tools.Console
;
import
org.h2.tools.ConvertTraceFile
;
import
org.h2.tools.ConvertTraceFile
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.tools.GUIConsole
;
import
org.h2.tools.Recover
;
import
org.h2.tools.Recover
;
import
org.h2.tools.Restore
;
import
org.h2.tools.Restore
;
import
org.h2.tools.RunScript
;
import
org.h2.tools.RunScript
;
...
@@ -127,7 +128,7 @@ public class TestTools extends TestBase {
...
@@ -127,7 +128,7 @@ public class TestTools extends TestBase {
private
void
testConsole
()
throws
Exception
{
private
void
testConsole
()
throws
Exception
{
String
old
=
System
.
getProperty
(
SysProperties
.
H2_BROWSER
);
String
old
=
System
.
getProperty
(
SysProperties
.
H2_BROWSER
);
Console
c
=
new
Console
();
GUIConsole
c
=
new
GUI
Console
();
c
.
setOut
(
new
PrintStream
(
new
ByteArrayOutputStream
()));
c
.
setOut
(
new
PrintStream
(
new
ByteArrayOutputStream
()));
try
{
try
{
...
...
h2/src/tools/org/h2/build/Build.java
浏览文件 @
3f80639b
...
@@ -23,7 +23,6 @@ import java.util.concurrent.TimeUnit;
...
@@ -23,7 +23,6 @@ import java.util.concurrent.TimeUnit;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipFile
;
import
java.util.zip.ZipFile
;
import
org.h2.build.code.SwitchSource
;
import
org.h2.build.doc.XMLParser
;
import
org.h2.build.doc.XMLParser
;
/**
/**
...
@@ -231,34 +230,11 @@ public class Build extends BuildBase {
...
@@ -231,34 +230,11 @@ public class Build extends BuildBase {
m
.
invoke
(
d
,
new
File
(
"coverage/report/index.html"
));
m
.
invoke
(
d
,
new
File
(
"coverage/report/index.html"
));
}
}
/**
* Switch the source code to the current JDK.
*/
@Description
(
summary
=
"Switch the source code to match the current JDK."
)
public
void
switchSource
()
{
switchSource
(
true
);
}
private
static
String
getTargetJavaVersion
()
{
private
static
String
getTargetJavaVersion
()
{
return
System
.
getProperty
(
"version"
);
return
System
.
getProperty
(
"version"
);
}
}
private
static
void
switchSource
(
boolean
enableCheck
)
{
try
{
String
version
=
getTargetJavaVersion
();
String
check
=
enableCheck
?
"+CHECK"
:
"-CHECK"
;
if
(
version
==
null
)
{
SwitchSource
.
main
(
"-dir"
,
"src"
,
"-auto"
,
check
);
}
else
{
SwitchSource
.
main
(
"-dir"
,
"src"
,
"-version"
,
version
,
check
);
}
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
private
void
compileMVStore
(
boolean
debugInfo
)
{
private
void
compileMVStore
(
boolean
debugInfo
)
{
switchSource
(
debugInfo
);
clean
();
clean
();
mkdir
(
"temp"
);
mkdir
(
"temp"
);
String
classpath
=
"temp"
;
String
classpath
=
"temp"
;
...
@@ -282,7 +258,6 @@ public class Build extends BuildBase {
...
@@ -282,7 +258,6 @@ public class Build extends BuildBase {
private
void
compile
(
boolean
debugInfo
,
boolean
clientOnly
,
private
void
compile
(
boolean
debugInfo
,
boolean
clientOnly
,
boolean
basicResourcesOnly
)
{
boolean
basicResourcesOnly
)
{
switchSource
(
debugInfo
);
clean
();
clean
();
mkdir
(
"temp"
);
mkdir
(
"temp"
);
download
();
download
();
...
...
h2/src/tools/org/h2/build/code/SwitchSource.java
deleted
100644 → 0
浏览文件 @
8097e478
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
build
.
code
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.RandomAccessFile
;
import
java.util.ArrayList
;
/**
* Switched source code to a specific Java version, automatically to the current
* version, or enable / disable other blocks of source code in Java files.
*/
public
class
SwitchSource
{
private
final
ArrayList
<
String
>
enable
=
new
ArrayList
<>();
private
final
ArrayList
<
String
>
disable
=
new
ArrayList
<>();
/**
* This method is called when executing this application from the command
* line.
*
* @param args the command line parameters
*/
public
static
void
main
(
String
...
args
)
throws
IOException
{
new
SwitchSource
().
run
(
args
);
}
private
void
run
(
String
...
args
)
throws
IOException
{
String
dir
=
null
;
String
version
=
null
;
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
String
a
=
args
[
i
];
if
(
"-dir"
.
equals
(
a
))
{
dir
=
args
[++
i
];
}
else
if
(
"-auto"
.
equals
(
a
))
{
enable
.
add
(
"AWT"
);
version
=
System
.
getProperty
(
"java.specification.version"
);
}
else
if
(
"-version"
.
equals
(
a
))
{
version
=
args
[++
i
];
}
else
if
(
a
.
startsWith
(
"-"
))
{
String
x
=
a
.
substring
(
1
);
disable
.
add
(
x
);
enable
.
remove
(
x
);
}
else
if
(
a
.
startsWith
(
"+"
))
{
String
x
=
a
.
substring
(
1
);
enable
.
add
(
x
);
disable
.
remove
(
x
);
}
else
{
showUsage
();
return
;
}
}
if
(
version
==
null
)
{
// ok
}
else
if
(
"1.5"
.
equals
(
version
))
{
disable
.
add
(
"Java 1.6"
);
disable
.
add
(
"Java 1.7"
);
}
else
if
(
"1.6"
.
equals
(
version
))
{
enable
.
add
(
"Java 1.6"
);
disable
.
add
(
"Java 1.7"
);
}
else
if
(
version
.
compareTo
(
"1.7"
)
>=
0
)
{
enable
.
add
(
"Java 1.6"
);
enable
.
add
(
"Java 1.7"
);
}
else
{
throw
new
IllegalArgumentException
(
"version: "
+
version
);
}
if
(
dir
==
null
)
{
showUsage
();
}
else
{
process
(
new
File
(
dir
));
}
}
private
void
showUsage
()
{
System
.
out
.
println
(
"Switched source code to a specific Java version."
);
System
.
out
.
println
(
"java "
+
getClass
().
getName
()
+
"\n"
+
" -dir <dir> The target directory\n"
+
" [-version] Use the specified Java version (1.4 or newer)\n"
+
" [-auto] Auto-detect Java version (1.4 or newer)\n"
+
" [+MODE] Enable code labeled MODE\n"
+
" [-MODE] Disable code labeled MODE"
);
}
private
void
process
(
File
f
)
throws
IOException
{
String
name
=
f
.
getName
();
if
(
name
.
startsWith
(
".svn"
))
{
return
;
}
else
if
(
name
.
endsWith
(
".java"
))
{
processFile
(
f
);
}
else
if
(
f
.
isDirectory
())
{
for
(
File
file
:
f
.
listFiles
())
{
process
(
file
);
}
}
}
private
void
processFile
(
File
f
)
throws
IOException
{
byte
[]
buffer
;
try
(
RandomAccessFile
read
=
new
RandomAccessFile
(
f
,
"r"
))
{
long
len
=
read
.
length
();
if
(
len
>=
Integer
.
MAX_VALUE
)
{
throw
new
IOException
(
"Files bigger than Integer.MAX_VALUE are not supported"
);
}
buffer
=
new
byte
[(
int
)
len
];
read
.
readFully
(
buffer
);
}
boolean
found
=
false
;
// check for ## without creating a string
for
(
int
i
=
0
;
i
<
buffer
.
length
-
1
;
i
++)
{
if
(
buffer
[
i
]
==
'#'
&&
buffer
[
i
+
1
]
==
'#'
)
{
found
=
true
;
break
;
}
}
if
(!
found
)
{
return
;
}
String
source
=
new
String
(
buffer
);
String
target
=
source
;
for
(
String
x
:
enable
)
{
target
=
replaceAll
(
target
,
"/*## "
+
x
+
" ##"
,
"//## "
+
x
+
" ##"
);
}
for
(
String
x
:
disable
)
{
target
=
replaceAll
(
target
,
"//## "
+
x
+
" ##"
,
"/*## "
+
x
+
" ##"
);
}
if
(!
source
.
equals
(
target
))
{
String
name
=
f
.
getPath
();
File
fileNew
=
new
File
(
name
+
".new"
);
FileWriter
write
=
new
FileWriter
(
fileNew
);
write
.
write
(
target
);
write
.
close
();
File
fileBack
=
new
File
(
name
+
".bak"
);
fileBack
.
delete
();
f
.
renameTo
(
fileBack
);
File
fileCopy
=
new
File
(
name
);
if
(!
fileNew
.
renameTo
(
fileCopy
))
{
throw
new
IOException
(
"Could not rename "
+
fileNew
.
getAbsolutePath
()
+
" to "
+
name
);
}
if
(!
fileBack
.
delete
())
{
throw
new
IOException
(
"Could not delete "
+
fileBack
.
getAbsolutePath
());
}
// System.out.println(name);
}
}
private
static
String
replaceAll
(
String
s
,
String
before
,
String
after
)
{
int
index
=
0
;
while
(
true
)
{
int
next
=
s
.
indexOf
(
before
,
index
);
if
(
next
<
0
)
{
return
s
;
}
s
=
s
.
substring
(
0
,
next
)
+
after
+
s
.
substring
(
next
+
before
.
length
());
index
=
next
+
after
.
length
();
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论