Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
30cdd029
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dbeaver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
30cdd029
编写于
10月 08, 2015
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Maven model
上级
c2d608e9
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
182 addition
and
39 deletion
+182
-39
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenArtifact.java
...s/dbeaver/registry/driver/DriverLibraryMavenArtifact.java
+30
-11
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenDependency.java
...dbeaver/registry/driver/DriverLibraryMavenDependency.java
+82
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
...e/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
+7
-8
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactVersion.java
...rg/jkiss/dbeaver/registry/maven/MavenArtifactVersion.java
+33
-9
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
...src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
+2
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/driver/DriverDownloadAutoPage.java
...iss/dbeaver/ui/dialogs/driver/DriverDownloadAutoPage.java
+27
-9
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBPDriverLibrary.java
...r.model/src/org/jkiss/dbeaver/model/DBPDriverLibrary.java
+1
-1
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenArtifact.java
浏览文件 @
30cdd029
...
...
@@ -27,10 +27,13 @@ import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.registry.maven.*
;
import
org.jkiss.dbeaver.ui.UIIcon
;
import
org.jkiss.utils.CommonUtils
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
/**
* DriverLibraryDescriptor
...
...
@@ -41,6 +44,8 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
public
static
final
String
PATH_PREFIX
=
"maven:/"
;
private
List
<
DriverLibraryMavenDependency
>
dependencies
;
public
DriverLibraryMavenArtifact
(
DriverDescriptor
driver
,
FileType
type
,
String
path
)
{
super
(
driver
,
type
,
path
);
}
...
...
@@ -123,19 +128,33 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
@Nullable
@Override
public
Collection
<
DBPDriverLibrary
>
getDependencies
(
DBRProgressMonitor
monitor
)
throws
IOException
{
MavenLocalVersion
localVersion
=
resolveLocalVersion
(
monitor
,
false
);
if
(
localVersion
==
null
)
{
return
null
;
public
Collection
<?
extends
DBPDriverLibrary
>
getDependencies
(
DBRProgressMonitor
monitor
)
throws
IOException
{
if
(
dependencies
==
null
)
{
dependencies
=
new
ArrayList
<>();
MavenLocalVersion
localVersion
=
resolveLocalVersion
(
monitor
,
false
);
if
(
localVersion
!=
null
)
{
collectDependencies
(
monitor
,
localVersion
);
}
}
return
dependencies
;
}
private
void
collectDependencies
(
DBRProgressMonitor
monitor
,
MavenLocalVersion
localVersion
)
throws
IOException
{
MavenArtifactVersion
metaData
=
localVersion
.
getMetaData
(
monitor
);
if
(
metaData
==
null
)
{
return
null
;
}
for
(
MavenArtifactDependency
dependency
:
metaData
.
getDependencies
())
{
System
.
out
.
println
(
dependency
);
if
(
metaData
!=
null
)
{
List
<
MavenArtifactDependency
>
dependencies
=
metaData
.
getDependencies
();
if
(!
CommonUtils
.
isEmpty
(
dependencies
))
{
for
(
MavenArtifactDependency
dependency
:
dependencies
)
{
MavenArtifact
depArtifact
=
MavenRegistry
.
getInstance
().
findArtifact
(
dependency
.
getArtifactReference
());
if
(
depArtifact
!=
null
)
{
MavenLocalVersion
depLocalVersion
=
depArtifact
.
resolveVersion
(
monitor
,
dependency
.
getArtifactReference
().
getVersion
());
if
(
depLocalVersion
!=
null
)
{
this
.
dependencies
.
add
(
new
DriverLibraryMavenDependency
(
this
.
getDriver
(),
depLocalVersion
));
}
}
}
}
}
return
null
;
}
@NotNull
...
...
@@ -165,7 +184,7 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
super
.
downloadLibraryFile
(
monitor
,
forceUpdate
);
}
pr
ivate
MavenLocalVersion
resolveLocalVersion
(
DBRProgressMonitor
monitor
,
boolean
forceUpdate
)
throws
IOException
{
pr
otected
MavenLocalVersion
resolveLocalVersion
(
DBRProgressMonitor
monitor
,
boolean
forceUpdate
)
throws
IOException
{
MavenArtifactReference
artifactInfo
=
new
MavenArtifactReference
(
path
);
if
(
forceUpdate
)
{
MavenRegistry
.
getInstance
().
resetArtifactInfo
(
artifactInfo
);
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenDependency.java
0 → 100644
浏览文件 @
30cdd029
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package
org.jkiss.dbeaver.registry.driver
;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.DBIcon
;
import
org.jkiss.dbeaver.model.DBPDriverLibrary
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.registry.maven.*
;
import
org.jkiss.dbeaver.ui.UIIcon
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
/**
* DriverLibraryDescriptor
*/
public
class
DriverLibraryMavenDependency
extends
DriverLibraryMavenArtifact
{
private
MavenLocalVersion
localVersion
;
public
DriverLibraryMavenDependency
(
DriverDescriptor
driverDescriptor
,
MavenLocalVersion
localVersion
)
{
super
(
driverDescriptor
,
FileType
.
jar
,
localVersion
.
getArtifact
().
toString
());
this
.
localVersion
=
localVersion
;
}
@Override
public
boolean
isResolved
()
{
return
true
;
}
@Nullable
private
MavenArtifact
getMavenArtifact
()
{
return
localVersion
.
getArtifact
();
}
@Nullable
@Override
public
String
getExternalURL
()
{
return
localVersion
.
getExternalURL
(
MavenArtifact
.
FILE_JAR
);
}
@Nullable
@Override
public
File
getLocalFile
()
{
return
localVersion
.
getCacheFile
();
}
@NotNull
public
String
getDisplayName
()
{
return
localVersion
.
getArtifact
().
getGroupId
()
+
":"
+
localVersion
.
getArtifact
().
getArtifactId
()
+
":"
+
localVersion
.
getVersion
();
}
protected
MavenLocalVersion
resolveLocalVersion
(
DBRProgressMonitor
monitor
,
boolean
forceUpdate
)
throws
IOException
{
return
localVersion
;
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
浏览文件 @
30cdd029
...
...
@@ -63,13 +63,15 @@ public class MavenArtifact
this
.
artifactId
=
artifactId
;
}
public
void
loadMetadata
()
throws
IOException
{
public
void
loadMetadata
(
DBRProgressMonitor
monitor
)
throws
IOException
{
latestVersion
=
null
;
releaseVersion
=
null
;
versions
.
clear
();
lastUpdate
=
null
;
String
metadataPath
=
getArtifactDir
()
+
MAVEN_METADATA_XML
;
monitor
.
subTask
(
"Load artifact metadata ["
+
metadataPath
+
"]"
);
System
.
out
.
println
(
"Load metadata "
+
this
);
try
(
InputStream
mdStream
=
RuntimeUtils
.
openConnectionStream
(
metadataPath
))
{
SAXReader
reader
=
new
SAXReader
(
mdStream
);
reader
.
parse
(
new
SAXListener
()
{
...
...
@@ -185,7 +187,7 @@ public class MavenArtifact
return
null
;
}
p
ublic
MavenLocalVersion
makeLocalVersion
(
DBRProgressMonitor
monitor
,
String
versionStr
,
boolean
setActive
)
throws
IllegalArgumentException
{
p
rivate
MavenLocalVersion
makeLocalVersion
(
DBRProgressMonitor
monitor
,
String
versionStr
,
boolean
setActive
)
throws
IllegalArgumentException
{
MavenLocalVersion
version
=
getLocalVersion
(
versionStr
);
if
(
version
==
null
)
{
if
(!
versions
.
contains
(
versionStr
))
{
...
...
@@ -214,7 +216,9 @@ public class MavenArtifact
monitor
.
beginTask
(
"Download Maven artifact '"
+
this
+
"'"
,
3
);
try
{
monitor
.
subTask
(
"Download metadata from "
+
repository
.
getUrl
());
loadMetadata
();
if
(
versions
.
isEmpty
())
{
loadMetadata
(
monitor
);
}
monitor
.
worked
(
1
);
String
versionInfo
=
versionRef
;
...
...
@@ -253,11 +257,6 @@ public class MavenArtifact
}
monitor
.
subTask
(
"Download binaries for version "
+
versionInfo
);
MavenLocalVersion
localVersion
=
getActiveLocalVersion
();
if
(
localVersion
!=
null
&&
!
localVersion
.
getCacheFile
().
exists
())
{
log
.
debug
(
"Drop previous local version '"
+
localVersion
+
"' - jar seems to be dropped"
);
removeLocalVersion
(
localVersion
);
localVersion
=
null
;
}
if
(
localVersion
==
null
)
{
localVersion
=
makeLocalVersion
(
monitor
,
versionInfo
,
true
);
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactVersion.java
浏览文件 @
30cdd029
...
...
@@ -60,11 +60,10 @@ public class MavenArtifactVersion {
public
String
get
(
String
name
)
{
String
value
=
properties
.
get
(
name
);
if
(
value
==
null
)
{
if
(
parent
!=
null
)
{
return
parent
.
getMetaData
(
VoidProgressMonitor
.
INSTANCE
).
variableResolver
.
get
(
name
);
}
if
(
name
.
equals
(
PROP_PROJECT_VERSION
))
{
value
=
version
;
}
else
if
(
parent
!=
null
)
{
return
parent
.
getMetaData
(
VoidProgressMonitor
.
INSTANCE
).
variableResolver
.
get
(
name
);
}
}
return
value
;
...
...
@@ -133,6 +132,8 @@ public class MavenArtifactVersion {
private
void
loadPOM
(
DBRProgressMonitor
monitor
)
throws
IOException
{
String
pomURL
=
localVersion
.
getArtifact
().
getFileURL
(
localVersion
.
getVersion
(),
MavenArtifact
.
FILE_POM
);
monitor
.
subTask
(
"Load POM ["
+
pomURL
+
"]"
);
System
.
out
.
println
(
"Load POM "
+
localVersion
.
getArtifact
().
toString
()
+
":"
+
version
);
Document
pomDocument
;
try
(
InputStream
mdStream
=
RuntimeUtils
.
openConnectionStream
(
pomURL
))
{
pomDocument
=
XMLUtils
.
parseDocument
(
mdStream
);
...
...
@@ -190,21 +191,31 @@ public class MavenArtifactVersion {
// Dependencies
Element
dmElement
=
XMLUtils
.
getChildElement
(
root
,
"dependencyManagement"
);
if
(
dmElement
!=
null
)
{
dependencyManagement
=
parseDependencies
(
dmElement
);
dependencyManagement
=
parseDependencies
(
monitor
,
dmElement
);
}
dependencies
=
parseDependencies
(
root
);
dependencies
=
parseDependencies
(
monitor
,
root
);
}
}
private
List
<
MavenArtifactDependency
>
parseDependencies
(
Element
element
)
{
private
List
<
MavenArtifactDependency
>
parseDependencies
(
DBRProgressMonitor
monitor
,
Element
element
)
{
List
<
MavenArtifactDependency
>
result
=
new
ArrayList
<>();
Element
dependenciesElement
=
XMLUtils
.
getChildElement
(
element
,
"dependencies"
);
if
(
dependenciesElement
!=
null
)
{
for
(
Element
dep
:
XMLUtils
.
getChildElementList
(
dependenciesElement
,
"dependency"
))
{
String
groupId
=
XMLUtils
.
getChildElementBody
(
dep
,
"groupId"
);
String
artifactId
=
XMLUtils
.
getChildElementBody
(
dep
,
"artifactId"
);
String
version
=
XMLUtils
.
getChildElementBody
(
dep
,
"version"
);
if
(
CommonUtils
.
isEmpty
(
version
))
{
version
=
findDependencyVersion
(
monitor
,
groupId
,
artifactId
);
}
if
(
version
==
null
)
{
log
.
error
(
"Can't resolve artifact ["
+
groupId
+
":"
+
artifactId
+
"] version. Skip."
);
continue
;
}
MavenArtifactReference
depRef
=
new
MavenArtifactReference
(
XMLUtils
.
getChildElementBody
(
dep
,
"groupId"
)
,
XMLUtils
.
getChildElementBody
(
dep
,
"artifactId"
)
,
evaluateString
(
XMLUtils
.
getChildElementBody
(
dep
,
"version"
)
)
groupId
,
artifactId
,
evaluateString
(
version
)
);
result
.
add
(
new
MavenArtifactDependency
(
depRef
,
...
...
@@ -216,6 +227,19 @@ public class MavenArtifactVersion {
return
result
;
}
private
String
findDependencyVersion
(
DBRProgressMonitor
monitor
,
String
groupId
,
String
artifactId
)
{
if
(
dependencyManagement
!=
null
)
{
for
(
MavenArtifactDependency
dmArtifact
:
dependencyManagement
)
{
if
(
dmArtifact
.
getArtifactReference
().
getGroupId
().
equals
(
groupId
)
&&
dmArtifact
.
getArtifactReference
().
getArtifactId
().
equals
(
artifactId
))
{
return
dmArtifact
.
getArtifactReference
().
getVersion
();
}
}
}
return
parent
==
null
?
null
:
parent
.
getMetaData
(
monitor
).
findDependencyVersion
(
monitor
,
groupId
,
artifactId
);
}
private
String
evaluateString
(
String
value
)
{
return
GeneralUtils
.
replaceVariables
(
value
,
variableResolver
);
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
浏览文件 @
30cdd029
...
...
@@ -22,6 +22,7 @@ import org.jkiss.code.NotNull;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.core.DBeaverActivator
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.registry.RegistryConstants
;
import
org.jkiss.utils.CommonUtils
;
import
org.jkiss.utils.IOUtils
;
...
...
@@ -123,7 +124,7 @@ public class MavenRepository
// Not cached - look in remote repository
MavenArtifact
artifact
=
new
MavenArtifact
(
this
,
groupId
,
artifactId
);
try
{
artifact
.
loadMetadata
();
artifact
.
loadMetadata
(
VoidProgressMonitor
.
INSTANCE
);
}
catch
(
IOException
e
)
{
log
.
debug
(
"Artifact ["
+
artifact
+
"] not found in repository ["
+
getUrl
()
+
"]"
);
return
null
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/driver/DriverDownloadAutoPage.java
浏览文件 @
30cdd029
...
...
@@ -29,6 +29,7 @@ import org.jkiss.dbeaver.model.DBPDriverLibrary;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRRunnableContext
;
import
org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.registry.driver.DriverDescriptor
;
import
org.jkiss.dbeaver.runtime.RunnableContextDelegate
;
import
org.jkiss.dbeaver.ui.DBeaverIcons
;
...
...
@@ -42,6 +43,8 @@ import java.util.List;
class
DriverDownloadAutoPage
extends
DriverDownloadPage
{
private
Tree
filesTree
;
DriverDownloadAutoPage
()
{
super
(
"Automatic download"
,
"Download driver files"
,
null
);
setPageComplete
(
false
);
...
...
@@ -67,18 +70,11 @@ class DriverDownloadAutoPage extends DriverDownloadPage {
{
Group
filesGroup
=
UIUtils
.
createControlGroup
(
composite
,
"Files required by driver"
,
1
,
-
1
,
-
1
);
filesGroup
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_HORIZONTAL
));
Tree
filesTree
=
new
Tree
(
filesGroup
,
SWT
.
BORDER
|
SWT
.
FULL_SELECTION
);
filesTree
=
new
Tree
(
filesGroup
,
SWT
.
BORDER
|
SWT
.
FULL_SELECTION
);
filesTree
.
setHeaderVisible
(
true
);
filesTree
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_HORIZONTAL
));
UIUtils
.
createTreeColumn
(
filesTree
,
SWT
.
LEFT
,
"File"
);
UIUtils
.
createTreeColumn
(
filesTree
,
SWT
.
LEFT
,
"Version"
);
for
(
DBPDriverLibrary
file
:
wizard
.
getFiles
())
{
TreeItem
item
=
new
TreeItem
(
filesTree
,
SWT
.
NONE
);
item
.
setImage
(
DBeaverIcons
.
getImage
(
file
.
getIcon
()));
item
.
setText
(
0
,
file
.
getDisplayName
());
item
.
setText
(
1
,
""
);
}
UIUtils
.
packColumns
(
filesTree
);
}
if
(!
wizard
.
isForceDownload
())
{
...
...
@@ -112,10 +108,18 @@ class DriverDownloadAutoPage extends DriverDownloadPage {
}
catch
(
InvocationTargetException
e
)
{
UIUtils
.
showErrorDialog
(
null
,
"Resolve libraries"
,
"Error resolving driver libraries"
,
e
.
getTargetException
());
}
for
(
DBPDriverLibrary
file
:
getWizard
().
getFiles
())
{
TreeItem
item
=
new
TreeItem
(
filesTree
,
SWT
.
NONE
);
item
.
setImage
(
DBeaverIcons
.
getImage
(
file
.
getIcon
()));
item
.
setText
(
0
,
file
.
getDisplayName
());
item
.
setText
(
1
,
""
);
}
UIUtils
.
packColumns
(
filesTree
);
}
private
void
resolveDependencies
(
DBRProgressMonitor
monitor
,
DBPDriverLibrary
library
)
throws
IOException
{
Collection
<
DBPDriverLibrary
>
dependencies
=
library
.
getDependencies
(
monitor
);
Collection
<
?
extends
DBPDriverLibrary
>
dependencies
=
library
.
getDependencies
(
monitor
);
if
(
dependencies
!=
null
&&
!
dependencies
.
isEmpty
())
{
for
(
DBPDriverLibrary
dep
:
dependencies
)
{
resolveDependencies
(
monitor
,
dep
);
...
...
@@ -123,6 +127,20 @@ class DriverDownloadAutoPage extends DriverDownloadPage {
}
}
private
void
addDependencies
(
TreeItem
parent
,
DBPDriverLibrary
library
)
throws
IOException
{
Collection
<?
extends
DBPDriverLibrary
>
dependencies
=
library
.
getDependencies
(
VoidProgressMonitor
.
INSTANCE
);
if
(
dependencies
!=
null
&&
!
dependencies
.
isEmpty
())
{
for
(
DBPDriverLibrary
dep
:
dependencies
)
{
TreeItem
item
=
new
TreeItem
(
parent
,
SWT
.
NONE
);
item
.
setImage
(
DBeaverIcons
.
getImage
(
dep
.
getIcon
()));
item
.
setText
(
0
,
dep
.
getDisplayName
());
item
.
setText
(
1
,
""
);
addDependencies
(
item
,
dep
);
}
}
}
@Override
void
performFinish
()
{
downloadLibraryFiles
(
new
RunnableContextDelegate
(
getContainer
()),
getWizard
().
getFiles
());
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBPDriverLibrary.java
浏览文件 @
30cdd029
...
...
@@ -80,7 +80,7 @@ public interface DBPDriverLibrary
boolean
matchesCurrentPlatform
();
@Nullable
Collection
<
DBPDriverLibrary
>
getDependencies
(
DBRProgressMonitor
monitor
)
throws
IOException
;
Collection
<
?
extends
DBPDriverLibrary
>
getDependencies
(
DBRProgressMonitor
monitor
)
throws
IOException
;
void
downloadLibraryFile
(
DBRProgressMonitor
monitor
,
boolean
forceUpdate
)
throws
IOException
,
InterruptedException
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录