Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
41731321
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,发现更多精彩内容 >>
提交
41731321
编写于
10月 08, 2015
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Maven model & ui
上级
30cdd029
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
215 addition
and
130 deletion
+215
-130
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenArtifact.java
...s/dbeaver/registry/driver/DriverLibraryMavenArtifact.java
+32
-28
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenDependency.java
...dbeaver/registry/driver/DriverLibraryMavenDependency.java
+3
-11
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
...e/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
+25
-27
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactDependency.java
...jkiss/dbeaver/registry/maven/MavenArtifactDependency.java
+28
-16
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactReference.java
.../jkiss/dbeaver/registry/maven/MavenArtifactReference.java
+17
-4
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactVersion.java
...rg/jkiss/dbeaver/registry/maven/MavenArtifactVersion.java
+39
-27
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenLocalVersion.java
...c/org/jkiss/dbeaver/registry/maven/MavenLocalVersion.java
+1
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
...e/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
+21
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
...src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
+3
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/driver/DriverDownloadAutoPage.java
...iss/dbeaver/ui/dialogs/driver/DriverDownloadAutoPage.java
+38
-12
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/driver/DriverDownloadDialog.java
...jkiss/dbeaver/ui/dialogs/driver/DriverDownloadDialog.java
+7
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/driver/DriverDownloadPage.java
...g/jkiss/dbeaver/ui/dialogs/driver/DriverDownloadPage.java
+1
-1
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenArtifact.java
浏览文件 @
41731321
...
...
@@ -31,9 +31,7 @@ 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
;
import
java.util.*
;
/**
* DriverLibraryDescriptor
...
...
@@ -44,8 +42,6 @@ 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
);
}
...
...
@@ -114,7 +110,7 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
// In case of local artifact make version resolve
MavenArtifactReference
artifactInfo
=
new
MavenArtifactReference
(
path
);
try
{
localVersion
=
artifact
.
resolveVersion
(
VoidProgressMonitor
.
INSTANCE
,
artifactInfo
.
getVersion
());
localVersion
=
artifact
.
resolveVersion
(
VoidProgressMonitor
.
INSTANCE
,
artifactInfo
.
getVersion
()
,
true
);
}
catch
(
IOException
e
)
{
log
.
warn
(
"Error resolving local artifact ["
+
artifact
+
"] version"
,
e
);
}
...
...
@@ -129,32 +125,40 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
@Nullable
@Override
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
)
{
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
));
List
<
DriverLibraryMavenDependency
>
dependencies
=
new
ArrayList
<>();
MavenLocalVersion
localVersion
=
resolveLocalVersion
(
monitor
,
false
);
if
(
localVersion
!=
null
)
{
MavenArtifactVersion
metaData
=
localVersion
.
getMetaData
(
monitor
);
if
(
metaData
!=
null
)
{
List
<
MavenArtifactDependency
>
artifactDeps
=
metaData
.
getDependencies
();
if
(!
CommonUtils
.
isEmpty
(
artifactDeps
))
{
for
(
MavenArtifactDependency
artifactDep
:
artifactDeps
)
{
if
(
artifactDep
.
isOptional
())
{
continue
;
}
switch
(
artifactDep
.
getScope
())
{
case
COMPILE:
case
RUNTIME:
{
MavenLocalVersion
depLocalVersion
=
artifactDep
.
resolveDependency
(
monitor
);
if
(
depLocalVersion
!=
null
)
{
dependencies
.
add
(
new
DriverLibraryMavenDependency
(
this
.
getDriver
(),
depLocalVersion
));
}
break
;
}
default
:
// We don't need it
break
;
}
}
}
}
}
return
dependencies
;
}
@NotNull
...
...
@@ -200,7 +204,7 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
return
localVersion
;
}
}
return
artifact
.
resolveVersion
(
monitor
,
artifactInfo
.
getVersion
());
return
artifact
.
resolveVersion
(
monitor
,
artifactInfo
.
getVersion
()
,
true
);
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenDependency.java
浏览文件 @
41731321
...
...
@@ -17,22 +17,14 @@
*/
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
org.jkiss.dbeaver.registry.maven.MavenArtifact
;
import
org.jkiss.dbeaver.registry.maven.MavenLocalVersion
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
/**
* DriverLibraryDescriptor
...
...
@@ -42,7 +34,7 @@ public class DriverLibraryMavenDependency extends DriverLibraryMavenArtifact
private
MavenLocalVersion
localVersion
;
public
DriverLibraryMavenDependency
(
DriverDescriptor
driverDescriptor
,
MavenLocalVersion
localVersion
)
{
super
(
driverDescriptor
,
FileType
.
jar
,
localVersion
.
getArtifact
()
.
toString
());
super
(
driverDescriptor
,
FileType
.
jar
,
PATH_PREFIX
+
localVersion
.
toString
());
this
.
localVersion
=
localVersion
;
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
浏览文件 @
41731321
...
...
@@ -53,6 +53,8 @@ public class MavenArtifact
private
String
releaseVersion
;
private
Date
lastUpdate
;
private
transient
boolean
metadataLoaded
=
false
;
private
List
<
MavenLocalVersion
>
localVersions
=
new
ArrayList
<
MavenLocalVersion
>();
private
String
activeVersion
;
...
...
@@ -69,7 +71,7 @@ public class MavenArtifact
versions
.
clear
();
lastUpdate
=
null
;
String
metadataPath
=
getArtifact
Dir
()
+
MAVEN_METADATA_XML
;
String
metadataPath
=
getArtifact
URL
()
+
MAVEN_METADATA_XML
;
monitor
.
subTask
(
"Load artifact metadata ["
+
metadataPath
+
"]"
);
System
.
out
.
println
(
"Load metadata "
+
this
);
try
(
InputStream
mdStream
=
RuntimeUtils
.
openConnectionStream
(
metadataPath
))
{
...
...
@@ -107,7 +109,10 @@ System.out.println("Load metadata " + this);
});
}
catch
(
XMLException
e
)
{
log
.
warn
(
"Error parsing artifact metadata"
,
e
);
}
finally
{
monitor
.
worked
(
1
);
}
metadataLoaded
=
true
;
}
public
MavenRepository
getRepository
()
{
...
...
@@ -150,13 +155,13 @@ System.out.println("Load metadata " + this);
this
.
activeVersion
=
activeVersion
;
}
private
String
getArtifact
Dir
()
{
String
dir
=
(
groupId
+
"/"
+
artifactId
).
replace
(
'.'
,
'/'
)
;
private
String
getArtifact
URL
()
{
String
dir
=
groupId
.
replace
(
'.'
,
'/'
)
+
"/"
+
artifactId
;
return
repository
.
getUrl
()
+
dir
+
"/"
;
}
public
String
getFileURL
(
String
version
,
String
fileType
)
{
return
getArtifact
Dir
()
+
version
+
"/"
+
getVersionFileName
(
version
,
fileType
);
return
getArtifact
URL
()
+
version
+
"/"
+
getVersionFileName
(
version
,
fileType
);
}
@NotNull
...
...
@@ -212,16 +217,13 @@ System.out.println("Load metadata " + this);
localVersions
.
remove
(
version
);
}
public
MavenLocalVersion
resolveVersion
(
DBRProgressMonitor
monitor
,
String
versionRef
)
throws
IOException
{
monitor
.
beginTask
(
"Download Maven artifact '"
+
this
+
"'"
,
3
);
try
{
monitor
.
subTask
(
"Download metadata from "
+
repository
.
getUrl
());
if
(
versions
.
isEmpty
())
{
loadMetadata
(
monitor
);
}
monitor
.
worked
(
1
);
public
MavenLocalVersion
resolveVersion
(
DBRProgressMonitor
monitor
,
String
versionRef
,
boolean
lookupVersion
)
throws
IOException
{
if
(
lookupVersion
&&
!
metadataLoaded
)
{
loadMetadata
(
monitor
);
}
String
versionInfo
=
versionRef
;
String
versionInfo
=
versionRef
;
if
(
lookupVersion
)
{
List
<
String
>
allVersions
=
versions
;
if
(
versionInfo
.
equals
(
MavenArtifactReference
.
VERSION_PATTERN_RELEASE
))
{
versionInfo
=
releaseVersion
;
...
...
@@ -255,27 +257,23 @@ System.out.println("Load metadata " + this);
// Use latest version
versionInfo
=
findLatestVersion
(
allVersions
);
}
monitor
.
subTask
(
"Download binaries for version "
+
versionInfo
);
MavenLocalVersion
localVersion
=
getActiveLocalVersion
();
if
(
localVersion
==
null
)
{
localVersion
=
makeLocalVersion
(
monitor
,
versionInfo
,
true
);
}
monitor
.
worked
(
1
);
monitor
.
subTask
(
"Save repository cache"
);
repository
.
flushCache
();
monitor
.
worked
(
1
);
}
return
localVersion
;
}
finally
{
monitor
.
done
(
);
MavenLocalVersion
localVersion
=
getActiveLocalVersion
()
;
if
(
localVersion
==
null
)
{
localVersion
=
makeLocalVersion
(
monitor
,
versionInfo
,
true
);
}
repository
.
flushCache
();
return
localVersion
;
}
private
static
boolean
isBetaVersion
(
String
versionInfo
)
{
return
versionInfo
.
contains
(
"beta"
)
||
versionInfo
.
contains
(
"alpha"
);
}
private
String
findLatestVersion
(
List
<
String
>
allVersions
)
{
private
static
String
findLatestVersion
(
List
<
String
>
allVersions
)
{
String
latest
=
null
;
for
(
String
version
:
allVersions
)
{
if
(
isBetaVersion
(
version
))
{
...
...
@@ -288,7 +286,7 @@ System.out.println("Load metadata " + this);
return
latest
;
}
private
int
compareVersions
(
String
v1
,
String
v2
)
{
private
static
int
compareVersions
(
String
v1
,
String
v2
)
{
StringTokenizer
st1
=
new
StringTokenizer
(
v1
,
".-_"
);
StringTokenizer
st2
=
new
StringTokenizer
(
v2
,
".-_"
);
while
(
st1
.
hasMoreTokens
()
&&
st2
.
hasMoreTokens
())
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactDependency.java
浏览文件 @
41731321
...
...
@@ -17,36 +17,48 @@
*/
package
org.jkiss.dbeaver.registry.maven
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
java.io.IOException
;
/**
* Maven artifact license references
*/
public
class
MavenArtifactDependency
{
private
MavenArtifactReference
artifactReference
;
private
String
type
;
private
boolean
optional
;
public
class
MavenArtifactDependency
extends
MavenArtifactReference
{
public
MavenArtifactDependency
(
MavenArtifactReference
artifactReference
,
String
type
,
boolean
optional
)
{
this
.
artifactReference
=
artifactReference
;
this
.
type
=
type
;
this
.
optional
=
optional
;
public
enum
Scope
{
COMPILE
,
PROVIDED
,
RUNTIME
,
TEST
,
SYSTEM
,
IMPORT
}
public
MavenArtifactReference
getArtifactReference
()
{
return
artifactReference
;
private
Scope
scope
;
private
boolean
optional
;
public
MavenArtifactDependency
(
@NotNull
String
groupId
,
@NotNull
String
artifactId
,
@NotNull
String
version
,
Scope
scope
,
boolean
optional
)
{
super
(
groupId
,
artifactId
,
version
);
this
.
scope
=
scope
;
this
.
optional
=
optional
;
}
public
S
tring
getTy
pe
()
{
return
ty
pe
;
public
S
cope
getSco
pe
()
{
return
sco
pe
;
}
public
boolean
isOptional
()
{
return
optional
;
}
@Override
public
String
toString
()
{
return
artifactReference
.
toString
()
+
";type="
+
type
+
"; optional="
+
optional
;
public
MavenLocalVersion
resolveDependency
(
DBRProgressMonitor
monitor
)
throws
IOException
{
MavenArtifact
depArtifact
=
MavenRegistry
.
getInstance
().
findArtifact
(
this
);
if
(
depArtifact
!=
null
)
{
return
depArtifact
.
resolveVersion
(
monitor
,
getVersion
(),
false
);
}
return
null
;
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactReference.java
浏览文件 @
41731321
...
...
@@ -17,6 +17,8 @@
*/
package
org.jkiss.dbeaver.registry.maven
;
import
org.jkiss.code.NotNull
;
/**
* Maven artifact reference
*/
...
...
@@ -27,11 +29,14 @@ public class MavenArtifactReference
private
static
final
String
DEFAULT_MAVEN_VERSION
=
VERSION_PATTERN_RELEASE
;
@NotNull
private
String
groupId
;
@NotNull
private
String
artifactId
;
@NotNull
private
String
version
;
public
MavenArtifactReference
(
String
groupId
,
String
artifactId
,
String
version
)
{
public
MavenArtifactReference
(
@NotNull
String
groupId
,
@NotNull
String
artifactId
,
@NotNull
String
version
)
{
this
.
groupId
=
groupId
;
this
.
artifactId
=
artifactId
;
this
.
version
=
version
;
...
...
@@ -61,27 +66,30 @@ public class MavenArtifactReference
}
}
@NotNull
public
String
getGroupId
()
{
return
groupId
;
}
public
void
setGroupId
(
String
groupId
)
{
public
void
setGroupId
(
@NotNull
String
groupId
)
{
this
.
groupId
=
groupId
;
}
@NotNull
public
String
getArtifactId
()
{
return
artifactId
;
}
public
void
setArtifactId
(
String
artifactId
)
{
public
void
setArtifactId
(
@NotNull
String
artifactId
)
{
this
.
artifactId
=
artifactId
;
}
@NotNull
public
String
getVersion
()
{
return
version
;
}
public
void
setVersion
(
String
version
)
{
public
void
setVersion
(
@NotNull
String
version
)
{
this
.
version
=
version
;
}
...
...
@@ -94,4 +102,9 @@ public class MavenArtifactReference
public
String
toString
()
{
return
getPath
();
}
@Override
public
int
hashCode
()
{
return
groupId
.
hashCode
()
+
artifactId
.
hashCode
()
+
version
.
hashCode
();
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactVersion.java
浏览文件 @
41731321
...
...
@@ -30,10 +30,7 @@ import org.w3c.dom.Element;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
/**
* Maven artifact version descriptor (POM).
...
...
@@ -133,7 +130,7 @@ 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
);
System
.
out
.
println
(
"Load POM "
+
localVersion
.
getArtifact
().
toString
()
+
":"
+
localVersion
.
getVersion
()
);
Document
pomDocument
;
try
(
InputStream
mdStream
=
RuntimeUtils
.
openConnectionStream
(
pomURL
))
{
pomDocument
=
XMLUtils
.
parseDocument
(
mdStream
);
...
...
@@ -149,19 +146,27 @@ System.out.println("Load POM " + localVersion.getArtifact().toString() + ":" + v
// Parent
Element
parentElement
=
XMLUtils
.
getChildElement
(
root
,
"parent"
);
if
(
parentElement
!=
null
)
{
parentReference
=
new
MavenArtifactReference
(
XMLUtils
.
getChildElementBody
(
parentElement
,
"groupId"
),
XMLUtils
.
getChildElementBody
(
parentElement
,
"artifactId"
),
XMLUtils
.
getChildElementBody
(
parentElement
,
"version"
)
);
if
(
version
==
null
)
{
version
=
parentReference
.
getVersion
();
}
MavenArtifact
parentArtifact
=
MavenRegistry
.
getInstance
().
findArtifact
(
parentReference
);
if
(
parentArtifact
==
null
)
{
log
.
error
(
"Artifact ["
+
this
+
"] parent ["
+
parentReference
+
"] not found"
);
String
parentGroupId
=
XMLUtils
.
getChildElementBody
(
parentElement
,
"groupId"
);
String
parentArtifactId
=
XMLUtils
.
getChildElementBody
(
parentElement
,
"artifactId"
);
String
parentVersion
=
XMLUtils
.
getChildElementBody
(
parentElement
,
"version"
);
if
(
parentGroupId
==
null
||
parentArtifactId
==
null
||
parentVersion
==
null
)
{
log
.
error
(
"Broken parent reference: "
+
parentGroupId
+
":"
+
parentArtifactId
+
":"
+
parentVersion
);
}
else
{
parent
=
parentArtifact
.
resolveVersion
(
monitor
,
parentReference
.
getVersion
());
parentReference
=
new
MavenArtifactReference
(
parentGroupId
,
parentArtifactId
,
parentVersion
);
if
(
this
.
version
==
null
)
{
this
.
version
=
parentReference
.
getVersion
();
}
// parent = MavenRegistry.getInstance().findArtifactVersion(parentReference);
MavenArtifact
parentArtifact
=
MavenRegistry
.
getInstance
().
findArtifact
(
parentReference
);
if
(
parentArtifact
==
null
)
{
log
.
error
(
"Artifact ["
+
this
+
"] parent ["
+
parentReference
+
"] not found"
);
}
else
{
parent
=
parentArtifact
.
resolveVersion
(
monitor
,
parentReference
.
getVersion
(),
false
);
}
}
}
}
...
...
@@ -195,6 +200,7 @@ System.out.println("Load POM " + localVersion.getArtifact().toString() + ":" + v
}
dependencies
=
parseDependencies
(
monitor
,
root
);
}
monitor
.
worked
(
1
);
}
private
List
<
MavenArtifactDependency
>
parseDependencies
(
DBRProgressMonitor
monitor
,
Element
element
)
{
...
...
@@ -204,22 +210,28 @@ System.out.println("Load POM " + localVersion.getArtifact().toString() + ":" + v
for
(
Element
dep
:
XMLUtils
.
getChildElementList
(
dependenciesElement
,
"dependency"
))
{
String
groupId
=
XMLUtils
.
getChildElementBody
(
dep
,
"groupId"
);
String
artifactId
=
XMLUtils
.
getChildElementBody
(
dep
,
"artifactId"
);
if
(
groupId
==
null
||
artifactId
==
null
)
{
log
.
warn
(
"Broken dependency reference: "
+
groupId
+
":"
+
artifactId
);
continue
;
}
String
version
=
XMLUtils
.
getChildElementBody
(
dep
,
"version"
);
if
(
CommonUtils
.
isEmpty
(
version
)
)
{
if
(
version
==
null
)
{
version
=
findDependencyVersion
(
monitor
,
groupId
,
artifactId
);
}
if
(
version
==
null
)
{
log
.
error
(
"Can't resolve artifact ["
+
groupId
+
":"
+
artifactId
+
"] version. Skip."
);
continue
;
}
MavenArtifactReference
depRef
=
new
MavenArtifactReference
(
MavenArtifactDependency
.
Scope
scope
=
MavenArtifactDependency
.
Scope
.
COMPILE
;
String
scopeName
=
XMLUtils
.
getChildElementBody
(
dep
,
"scope"
);
if
(!
CommonUtils
.
isEmpty
(
scopeName
))
{
scope
=
MavenArtifactDependency
.
Scope
.
valueOf
(
scopeName
.
toUpperCase
(
Locale
.
ENGLISH
));
}
result
.
add
(
new
MavenArtifactDependency
(
groupId
,
artifactId
,
evaluateString
(
version
)
);
result
.
add
(
new
MavenArtifactDependency
(
depRef
,
XMLUtils
.
getChildElementBody
(
dep
,
"type"
),
evaluateString
(
version
),
scope
,
CommonUtils
.
getBoolean
(
XMLUtils
.
getChildElementBody
(
dep
,
"optional"
),
false
)
));
}
...
...
@@ -230,10 +242,10 @@ System.out.println("Load POM " + localVersion.getArtifact().toString() + ":" + v
private
String
findDependencyVersion
(
DBRProgressMonitor
monitor
,
String
groupId
,
String
artifactId
)
{
if
(
dependencyManagement
!=
null
)
{
for
(
MavenArtifactDependency
dmArtifact
:
dependencyManagement
)
{
if
(
dmArtifact
.
get
ArtifactReference
().
get
GroupId
().
equals
(
groupId
)
&&
dmArtifact
.
getArtifact
Reference
().
getArtifact
Id
().
equals
(
artifactId
))
if
(
dmArtifact
.
getGroupId
().
equals
(
groupId
)
&&
dmArtifact
.
getArtifactId
().
equals
(
artifactId
))
{
return
dmArtifact
.
get
ArtifactReference
().
get
Version
();
return
dmArtifact
.
getVersion
();
}
}
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenLocalVersion.java
浏览文件 @
41731321
...
...
@@ -94,7 +94,7 @@ public class MavenLocalVersion
@Override
public
String
toString
()
{
return
artifact
.
toString
()
+
":"
+
version
+
":"
+
fileName
;
return
artifact
.
toString
()
+
":"
+
version
;
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
浏览文件 @
41731321
...
...
@@ -131,6 +131,27 @@ public class MavenRegistry
return
null
;
}
/*
@Nullable
public MavenLocalVersion findArtifactVersion(@NotNull MavenArtifactReference ref) {
String fullId = ref.getGroupId() + ":" + ref.getArtifactId();
if (notFoundArtifacts.contains(fullId)) {
return null;
}
MavenLocalVersion version = findInRepositories(groupId, artifactId, false);
if (version == null) {
version = findInRepositories(groupId, artifactId, true);
}
if (version != null) {
return version;
}
// Not found
notFoundArtifacts.add(fullId);
return null;
}
*/
public
void
resetArtifactInfo
(
MavenArtifactReference
artifactReference
)
{
String
groupId
=
artifactReference
.
getGroupId
();
String
artifactId
=
artifactReference
.
getArtifactId
();
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
浏览文件 @
41731321
...
...
@@ -68,6 +68,8 @@ public class MavenRepository
private
boolean
local
;
private
boolean
predefined
=
false
;
private
transient
volatile
boolean
needsToSave
=
false
;
private
List
<
MavenArtifact
>
cachedArtifacts
=
new
ArrayList
<
MavenArtifact
>();
public
MavenRepository
(
IConfigurationElement
config
)
...
...
@@ -90,7 +92,7 @@ public class MavenRepository
}
public
void
flushCache
()
{
saveCache
()
;
needsToSave
=
true
;
}
public
String
getId
()
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/driver/DriverDownloadAutoPage.java
浏览文件 @
41731321
...
...
@@ -17,11 +17,9 @@
*/
package
org.jkiss.dbeaver.ui.dialogs.driver
;
import
org.eclipse.core.runtime.IProgressMonitor
;
import
org.eclipse.core.runtime.IStatus
;
import
org.eclipse.jface.dialogs.ErrorDialog
;
import
org.eclipse.jface.dialogs.IDialogConstants
;
import
org.eclipse.jface.operation.IRunnableWithProgress
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.widgets.*
;
...
...
@@ -29,7 +27,6 @@ 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
;
...
...
@@ -38,7 +35,7 @@ import org.jkiss.dbeaver.utils.GeneralUtils;
import
java.io.IOException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.
Collection
;
import
java.util.
*
;
import
java.util.List
;
class
DriverDownloadAutoPage
extends
DriverDownloadPage
{
...
...
@@ -69,10 +66,10 @@ class DriverDownloadAutoPage extends DriverDownloadPage {
{
Group
filesGroup
=
UIUtils
.
createControlGroup
(
composite
,
"Files required by driver"
,
1
,
-
1
,
-
1
);
filesGroup
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_
HORIZONTAL
));
filesGroup
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_
BOTH
));
filesTree
=
new
Tree
(
filesGroup
,
SWT
.
BORDER
|
SWT
.
FULL_SELECTION
);
filesTree
.
setHeaderVisible
(
true
);
filesTree
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_
HORIZONTAL
));
filesTree
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_
BOTH
));
UIUtils
.
createTreeColumn
(
filesTree
,
SWT
.
LEFT
,
"File"
);
UIUtils
.
createTreeColumn
(
filesTree
,
SWT
.
LEFT
,
"Version"
);
}
...
...
@@ -90,16 +87,20 @@ class DriverDownloadAutoPage extends DriverDownloadPage {
@Override
void
resolveLibraries
()
{
final
Map
<
String
,
List
<
DBPDriverLibrary
>>
depMap
=
new
LinkedHashMap
<>();
try
{
new
RunnableContextDelegate
(
getContainer
()).
run
(
true
,
true
,
new
DBRRunnableWithProgress
()
{
@Override
public
void
run
(
DBRProgressMonitor
monitor
)
throws
InvocationTargetException
,
InterruptedException
{
monitor
.
beginTask
(
"Resolve dependencies"
,
100
);
try
{
for
(
DBPDriverLibrary
library
:
getWizard
().
getFiles
())
{
resolveDependencies
(
monitor
,
library
);
resolveDependencies
(
monitor
,
library
,
depMap
);
}
}
catch
(
IOException
e
)
{
throw
new
InvocationTargetException
(
e
);
}
finally
{
monitor
.
done
();
}
}
});
...
...
@@ -109,26 +110,47 @@ class DriverDownloadAutoPage extends DriverDownloadPage {
UIUtils
.
showErrorDialog
(
null
,
"Resolve libraries"
,
"Error resolving driver libraries"
,
e
.
getTargetException
());
}
int
totalItems
=
0
;
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
,
""
);
totalItems
++;
if
(
addDependencies
(
item
,
file
,
depMap
))
{
item
.
setExpanded
(
true
);
totalItems
+=
item
.
getItemCount
();
}
}
UIUtils
.
packColumns
(
filesTree
);
// GridData gd = (GridData)filesTree.getLayoutData();
// gd.heightHint = filesTree.getItemCount() * 20 + 20;
Shell
shell
=
getContainer
().
getShell
();
shell
.
setSize
(
shell
.
getSize
().
x
,
shell
.
getSize
().
y
+
filesTree
.
getItemHeight
()
*
totalItems
);
shell
.
layout
();
}
private
void
resolveDependencies
(
DBRProgressMonitor
monitor
,
DBPDriverLibrary
library
)
throws
IOException
{
private
void
resolveDependencies
(
DBRProgressMonitor
monitor
,
DBPDriverLibrary
library
,
Map
<
String
,
List
<
DBPDriverLibrary
>>
depMap
)
throws
IOException
{
String
libraryPath
=
library
.
getPath
();
List
<
DBPDriverLibrary
>
deps
=
depMap
.
get
(
libraryPath
);
if
(
deps
!=
null
)
{
return
;
}
System
.
out
.
println
(
"Resolve dependencies of ["
+
libraryPath
+
"]"
);
deps
=
new
ArrayList
<>();
depMap
.
put
(
libraryPath
,
deps
);
Collection
<?
extends
DBPDriverLibrary
>
dependencies
=
library
.
getDependencies
(
monitor
);
if
(
dependencies
!=
null
&&
!
dependencies
.
isEmpty
())
{
for
(
DBPDriverLibrary
dep
:
dependencies
)
{
resolveDependencies
(
monitor
,
dep
);
deps
.
add
(
dep
);
resolveDependencies
(
monitor
,
dep
,
depMap
);
}
}
}
private
void
addDependencies
(
TreeItem
parent
,
DBPDriverLibrary
library
)
throws
IOException
{
Collection
<?
extends
DBPDriverLibrary
>
dependencies
=
library
.
getDependencies
(
VoidProgressMonitor
.
INSTANCE
);
private
boolean
addDependencies
(
TreeItem
parent
,
DBPDriverLibrary
library
,
Map
<
String
,
List
<
DBPDriverLibrary
>>
depMap
)
{
Collection
<?
extends
DBPDriverLibrary
>
dependencies
=
depMap
.
get
(
library
.
getPath
()
);
if
(
dependencies
!=
null
&&
!
dependencies
.
isEmpty
())
{
for
(
DBPDriverLibrary
dep
:
dependencies
)
{
TreeItem
item
=
new
TreeItem
(
parent
,
SWT
.
NONE
);
...
...
@@ -136,9 +158,13 @@ class DriverDownloadAutoPage extends DriverDownloadPage {
item
.
setText
(
0
,
dep
.
getDisplayName
());
item
.
setText
(
1
,
""
);
addDependencies
(
item
,
dep
);
if
(
addDependencies
(
item
,
dep
,
depMap
))
{
//item.setExpanded(true);
}
}
return
true
;
}
return
false
;
}
@Override
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/driver/DriverDownloadDialog.java
浏览文件 @
41731321
...
...
@@ -49,8 +49,13 @@ public class DriverDownloadDialog extends WizardDialog
getWizard
().
init
(
DBeaverUI
.
getActiveWorkbenchWindow
().
getWorkbench
(),
null
);
addPageChangedListener
(
new
IPageChangedListener
()
{
@Override
public
void
pageChanged
(
PageChangedEvent
event
)
{
getWizard
().
pageActivated
(
event
.
getSelectedPage
());
public
void
pageChanged
(
final
PageChangedEvent
event
)
{
UIUtils
.
runInDetachedUI
(
getShell
(),
new
Runnable
()
{
@Override
public
void
run
()
{
getWizard
().
pageActivated
(
event
.
getSelectedPage
());
}
});
}
});
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/driver/DriverDownloadPage.java
浏览文件 @
41731321
...
...
@@ -47,7 +47,7 @@ abstract class DriverDownloadPage extends WizardPage {
protected
void
createLinksPanel
(
Composite
composite
)
{
final
DriverDescriptor
driver
=
getWizard
().
getDriver
();
UIUtils
.
createPlaceholder
(
composite
,
1
).
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
//
UIUtils.createPlaceholder(composite, 1).setLayoutData(new GridData(GridData.FILL_BOTH));
Composite
linksGroup
=
UIUtils
.
createPlaceholder
(
composite
,
2
);
GridData
gd
=
new
GridData
(
GridData
.
FILL_HORIZONTAL
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录