Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
2a3ccd84
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,发现更多精彩内容 >>
提交
2a3ccd84
编写于
10月 11, 2015
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Dependencies model
上级
542ad1b3
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
115 addition
and
112 deletion
+115
-112
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverDependencies.java
...org/jkiss/dbeaver/registry/driver/DriverDependencies.java
+1
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverDescriptor.java
...c/org/jkiss/dbeaver/registry/driver/DriverDescriptor.java
+2
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryAbstract.java
.../jkiss/dbeaver/registry/driver/DriverLibraryAbstract.java
+17
-16
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryLocal.java
...org/jkiss/dbeaver/registry/driver/DriverLibraryLocal.java
+1
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenArtifact.java
...s/dbeaver/registry/driver/DriverLibraryMavenArtifact.java
+10
-28
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenDependency.java
...dbeaver/registry/driver/DriverLibraryMavenDependency.java
+24
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
...e/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
+1
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactReference.java
.../jkiss/dbeaver/registry/maven/MavenArtifactReference.java
+16
-14
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactVersion.java
...rg/jkiss/dbeaver/registry/maven/MavenArtifactVersion.java
+8
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
...e/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
+13
-18
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
...src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
+13
-21
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/driver/DriverDownloadAutoPage.java
...iss/dbeaver/ui/dialogs/driver/DriverDownloadAutoPage.java
+3
-3
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/driver/EditMavenArtifactDialog.java
...ss/dbeaver/ui/dialogs/driver/EditMavenArtifactDialog.java
+4
-3
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/connection/DBPDriverLibrary.java
.../org/jkiss/dbeaver/model/connection/DBPDriverLibrary.java
+2
-2
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverDependencies.java
浏览文件 @
2a3ccd84
...
...
@@ -94,7 +94,7 @@ public class DriverDependencies implements DBPDriverDependencies
*/
private
void
resolveDependencies
(
DBRProgressMonitor
monitor
,
DependencyNode
ownerNode
,
Map
<
String
,
DBPDriverLibrary
>
libMap
)
throws
IOException
{
Collection
<?
extends
DBPDriverLibrary
>
dependencies
=
ownerNode
.
library
.
getDependencies
(
monitor
,
ownerNode
.
owner
);
Collection
<?
extends
DBPDriverLibrary
>
dependencies
=
ownerNode
.
library
.
getDependencies
(
monitor
);
if
(
dependencies
!=
null
&&
!
dependencies
.
isEmpty
())
{
for
(
DBPDriverLibrary
dep
:
dependencies
)
{
DependencyNode
node
=
new
DependencyNode
(
ownerNode
,
dep
);
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverDescriptor.java
浏览文件 @
2a3ccd84
...
...
@@ -846,7 +846,9 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
validateFilesPresence
(
runnableContext
);
}
long
st
=
System
.
currentTimeMillis
();
resolveDependencies
(
runnableContext
);
System
.
out
.
println
(
"Resolve: "
+
(
System
.
currentTimeMillis
()
-
st
)
+
"ms"
);
List
<
URL
>
libraryURLs
=
new
ArrayList
<>();
// Load libraries
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryAbstract.java
浏览文件 @
2a3ccd84
...
...
@@ -26,7 +26,6 @@ import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import
org.jkiss.dbeaver.model.runtime.OSDescriptor
;
import
org.jkiss.dbeaver.registry.RegistryConstants
;
import
org.jkiss.dbeaver.runtime.RuntimeUtils
;
import
org.jkiss.dbeaver.utils.ContentUtils
;
import
org.jkiss.utils.CommonUtils
;
import
java.io.*
;
...
...
@@ -152,7 +151,7 @@ public abstract class DriverLibraryAbstract implements DBPDriverLibrary
return
system
==
null
||
system
.
matches
(
DBeaverCore
.
getInstance
().
getLocalSystem
());
}
public
void
downloadLibraryFile
(
@NotNull
DBRProgressMonitor
monitor
,
boolean
forceUpdate
)
throws
IOException
,
InterruptedException
public
void
downloadLibraryFile
(
@NotNull
DBRProgressMonitor
monitor
,
boolean
forceUpdate
,
String
taskName
)
throws
IOException
,
InterruptedException
{
String
externalURL
=
getExternalURL
();
if
(
externalURL
==
null
)
{
...
...
@@ -160,11 +159,19 @@ public abstract class DriverLibraryAbstract implements DBPDriverLibrary
}
final
URLConnection
connection
=
RuntimeUtils
.
openConnection
(
externalURL
);
monitor
.
worked
(
1
);
monitor
.
done
();
final
int
contentLength
=
connection
.
getContentLength
();
monitor
.
beginTask
(
"Download "
+
externalURL
,
contentLength
);
int
contentLength
=
connection
.
getContentLength
();
if
(
contentLength
<
0
)
{
contentLength
=
0
;
}
int
bufferLength
=
contentLength
/
10
;
if
(
bufferLength
>
1000000
)
{
bufferLength
=
1000000
;
}
if
(
bufferLength
<
50000
)
{
bufferLength
=
50000
;
}
monitor
.
beginTask
(
taskName
+
" - "
+
externalURL
,
contentLength
);
boolean
success
=
false
;
final
File
localFile
=
getLocalFile
();
if
(
localFile
==
null
)
{
...
...
@@ -176,12 +183,10 @@ public abstract class DriverLibraryAbstract implements DBPDriverLibrary
log
.
warn
(
"Can't create directory for local driver file '"
+
localDir
.
getAbsolutePath
()
+
"'"
);
}
}
final
OutputStream
outputStream
=
new
FileOutputStream
(
localFile
);
try
{
final
InputStream
inputStream
=
connection
.
getInputStream
();
try
{
try
(
final
OutputStream
outputStream
=
new
FileOutputStream
(
localFile
))
{
try
(
final
InputStream
inputStream
=
connection
.
getInputStream
())
{
final
NumberFormat
numberFormat
=
NumberFormat
.
getNumberInstance
();
byte
[]
buffer
=
new
byte
[
10000
];
byte
[]
buffer
=
new
byte
[
bufferLength
];
int
totalRead
=
0
;
for
(;;)
{
if
(
monitor
.
isCanceled
())
{
...
...
@@ -198,18 +203,14 @@ public abstract class DriverLibraryAbstract implements DBPDriverLibrary
totalRead
+=
count
;
}
}
finally
{
ContentUtils
.
close
(
inputStream
);
}
}
finally
{
ContentUtils
.
close
(
outputStream
);
if
(!
success
)
{
if
(!
localFile
.
delete
())
{
log
.
warn
(
"Can't delete local driver file '"
+
localFile
.
getAbsolutePath
()
+
"'"
);
}
}
monitor
.
done
();
}
monitor
.
done
();
}
@Override
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryLocal.java
浏览文件 @
2a3ccd84
...
...
@@ -23,7 +23,6 @@ import org.eclipse.core.runtime.Platform;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.DBIcon
;
import
org.jkiss.dbeaver.model.connection.DBPDriverDependencies
;
import
org.jkiss.dbeaver.model.connection.DBPDriverLibrary
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.ui.UIIcon
;
...
...
@@ -111,7 +110,7 @@ public class DriverLibraryLocal extends DriverLibraryAbstract
@Nullable
@Override
public
Collection
<?
extends
DBPDriverLibrary
>
getDependencies
(
@NotNull
DBRProgressMonitor
monitor
,
@Nullable
DBPDriverDependencies
.
DependencyNode
ownerNode
)
throws
IOException
{
public
Collection
<?
extends
DBPDriverLibrary
>
getDependencies
(
@NotNull
DBRProgressMonitor
monitor
)
throws
IOException
{
return
null
;
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenArtifact.java
浏览文件 @
2a3ccd84
...
...
@@ -22,7 +22,6 @@ 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.connection.DBPDriverDependencies
;
import
org.jkiss.dbeaver.model.connection.DBPDriverLibrary
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
...
...
@@ -134,7 +133,7 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
@Nullable
@Override
public
Collection
<?
extends
DBPDriverLibrary
>
getDependencies
(
@NotNull
DBRProgressMonitor
monitor
,
@Nullable
DBPDriverDependencies
.
DependencyNode
ownerNode
)
throws
IOException
{
public
Collection
<?
extends
DBPDriverLibrary
>
getDependencies
(
@NotNull
DBRProgressMonitor
monitor
)
throws
IOException
{
List
<
DriverLibraryMavenDependency
>
dependencies
=
new
ArrayList
<>();
MavenLocalVersion
localVersion
=
resolveLocalVersion
(
monitor
,
false
);
if
(
localVersion
!=
null
)
{
...
...
@@ -142,15 +141,16 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
List
<
MavenArtifactDependency
>
artifactDeps
=
metaData
.
getDependencies
(
monitor
);
if
(!
CommonUtils
.
isEmpty
(
artifactDeps
))
{
for
(
MavenArtifactDependency
artifactDep
:
artifactDeps
)
{
if
(
isDependencyExcluded
(
monitor
,
artifactDep
,
ownerNode
))
{
if
(
isDependencyExcluded
(
monitor
,
artifactDep
))
{
continue
;
}
MavenLocalVersion
depLocalVersion
=
artifactDep
.
resolveDependency
(
monitor
);
if
(
depLocalVersion
!=
null
)
{
dependencies
.
add
(
new
DriverLibraryMavenDependency
(
this
.
getDriver
(),
depLocalVersion
));
this
,
depLocalVersion
,
artifactDep
));
}
}
}
...
...
@@ -159,25 +159,7 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
return
dependencies
;
}
private
boolean
isDependencyExcluded
(
DBRProgressMonitor
monitor
,
MavenArtifactDependency
dependency
,
DBPDriverDependencies
.
DependencyNode
ownerNode
)
{
for
(
DBPDriverDependencies
.
DependencyNode
node
=
ownerNode
;
node
!=
null
;
node
=
node
.
owner
)
{
DBPDriverLibrary
library
=
node
.
library
;
if
(
library
instanceof
DriverLibraryMavenArtifact
)
{
MavenLocalVersion
ownerVersion
=
((
DriverLibraryMavenArtifact
)
library
).
getMavenLocalVersion
();
if
(
ownerVersion
!=
null
)
{
for
(
MavenArtifactDependency
ownerDependency
:
ownerVersion
.
getMetaData
(
monitor
).
getDependencies
(
monitor
))
{
List
<
MavenArtifactReference
>
ownerDependencyExclusions
=
ownerDependency
.
getExclusions
();
if
(
ownerDependencyExclusions
!=
null
)
{
for
(
MavenArtifactReference
exReference
:
ownerDependencyExclusions
)
{
if
(
exReference
.
getGroupId
().
equals
(
dependency
.
getGroupId
())
&&
exReference
.
getArtifactId
().
equals
(
dependency
.
getArtifactId
()))
{
return
true
;
}
}
}
}
}
}
}
protected
boolean
isDependencyExcluded
(
DBRProgressMonitor
monitor
,
MavenArtifactDependency
dependency
)
{
return
false
;
}
...
...
@@ -211,8 +193,8 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
return
UIIcon
.
APACHE
;
}
public
void
downloadLibraryFile
(
@NotNull
DBRProgressMonitor
monitor
,
boolean
forceUpdate
)
throws
IOException
,
InterruptedException
{
monitor
.
beginTask
(
"U
pdate version information"
,
1
);
public
void
downloadLibraryFile
(
@NotNull
DBRProgressMonitor
monitor
,
boolean
forceUpdate
,
String
taskName
)
throws
IOException
,
InterruptedException
{
//monitor.beginTask(taskName + " - u
pdate version information", 1);
try
{
MavenLocalVersion
localVersion
=
resolveLocalVersion
(
monitor
,
forceUpdate
);
if
(
localVersion
.
getArtifact
().
getRepository
().
isLocal
())
{
...
...
@@ -220,9 +202,9 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
return
;
}
}
finally
{
monitor
.
done
();
//
monitor.done();
}
super
.
downloadLibraryFile
(
monitor
,
forceUpdate
);
super
.
downloadLibraryFile
(
monitor
,
forceUpdate
,
taskName
);
}
protected
MavenLocalVersion
resolveLocalVersion
(
DBRProgressMonitor
monitor
,
boolean
forceUpdate
)
throws
IOException
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenDependency.java
浏览文件 @
2a3ccd84
...
...
@@ -19,23 +19,32 @@ package org.jkiss.dbeaver.registry.driver;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.connection.DBPDriverDependencies
;
import
org.jkiss.dbeaver.model.connection.DBPDriverLibrary
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.registry.maven.MavenArtifact
;
import
org.jkiss.dbeaver.registry.maven.MavenArtifactDependency
;
import
org.jkiss.dbeaver.registry.maven.MavenArtifactReference
;
import
org.jkiss.dbeaver.registry.maven.MavenLocalVersion
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.List
;
/**
* DriverLibraryDescriptor
*/
public
class
DriverLibraryMavenDependency
extends
DriverLibraryMavenArtifact
{
private
DriverLibraryMavenArtifact
parent
;
private
MavenLocalVersion
localVersion
;
private
MavenArtifactDependency
source
;
public
DriverLibraryMavenDependency
(
DriverDescriptor
driverDescriptor
,
MavenLocalVersion
localVersion
)
{
super
(
driverDescriptor
,
FileType
.
jar
,
PATH_PREFIX
+
localVersion
.
toString
());
public
DriverLibraryMavenDependency
(
DriverLibraryMavenArtifact
parent
,
MavenLocalVersion
localVersion
,
MavenArtifactDependency
source
)
{
super
(
parent
.
getDriver
(),
FileType
.
jar
,
PATH_PREFIX
+
localVersion
.
toString
());
this
.
parent
=
parent
;
this
.
localVersion
=
localVersion
;
this
.
source
=
source
;
}
@Override
...
...
@@ -60,4 +69,17 @@ public class DriverLibraryMavenDependency extends DriverLibraryMavenArtifact
return
localVersion
;
}
protected
boolean
isDependencyExcluded
(
DBRProgressMonitor
monitor
,
MavenArtifactDependency
dependency
)
{
List
<
MavenArtifactReference
>
exclusions
=
source
.
getExclusions
();
if
(
exclusions
!=
null
)
{
for
(
MavenArtifactReference
exReference
:
exclusions
)
{
if
(
exReference
.
getGroupId
().
equals
(
dependency
.
getGroupId
())
&&
exReference
.
getArtifactId
().
equals
(
dependency
.
getArtifactId
()))
{
return
true
;
}
}
}
return
parent
.
isDependencyExcluded
(
monitor
,
dependency
);
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
浏览文件 @
2a3ccd84
...
...
@@ -207,7 +207,7 @@ public class MavenArtifact
@Override
public
String
toString
()
{
return
groupId
+
":"
+
artifactId
;
return
MavenArtifactReference
.
makeId
(
groupId
,
artifactId
)
;
}
@Nullable
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactReference.java
浏览文件 @
2a3ccd84
...
...
@@ -30,16 +30,19 @@ public class MavenArtifactReference
private
static
final
String
DEFAULT_MAVEN_VERSION
=
VERSION_PATTERN_RELEASE
;
@NotNull
private
String
groupId
;
private
final
String
groupId
;
@NotNull
private
String
artifactId
;
private
final
String
artifactId
;
@NotNull
private
String
version
;
private
final
String
version
;
@NotNull
private
final
String
id
;
public
MavenArtifactReference
(
@NotNull
String
groupId
,
@NotNull
String
artifactId
,
@NotNull
String
version
)
{
this
.
groupId
=
groupId
;
this
.
artifactId
=
artifactId
;
this
.
version
=
version
;
this
.
id
=
makeId
(
groupId
,
artifactId
);
}
public
MavenArtifactReference
(
String
ref
)
{
...
...
@@ -53,6 +56,7 @@ public class MavenArtifactReference
groupId
=
mavenUri
;
artifactId
=
mavenUri
;
version
=
DEFAULT_MAVEN_VERSION
;
id
=
makeId
(
groupId
,
artifactId
);
return
;
}
groupId
=
mavenUri
.
substring
(
0
,
divPos
);
...
...
@@ -64,6 +68,7 @@ public class MavenArtifactReference
artifactId
=
mavenUri
.
substring
(
divPos
+
1
,
divPos2
);
version
=
mavenUri
.
substring
(
divPos2
+
1
);
}
id
=
makeId
(
groupId
,
artifactId
);
}
@NotNull
...
...
@@ -71,29 +76,21 @@ public class MavenArtifactReference
return
groupId
;
}
public
void
setGroupId
(
@NotNull
String
groupId
)
{
this
.
groupId
=
groupId
;
}
@NotNull
public
String
getArtifactId
()
{
return
artifactId
;
}
public
void
setArtifactId
(
@NotNull
String
artifactId
)
{
this
.
artifactId
=
artifactId
;
}
@NotNull
public
String
getVersion
()
{
return
version
;
}
public
void
setVersion
(
@NotNull
String
version
)
{
this
.
version
=
version
;
@NotNull
public
String
getId
()
{
return
id
;
}
public
String
getPath
()
{
return
groupId
+
":"
+
artifactId
+
":"
+
version
;
}
...
...
@@ -107,4 +104,9 @@ public class MavenArtifactReference
public
int
hashCode
()
{
return
groupId
.
hashCode
()
+
artifactId
.
hashCode
()
+
version
.
hashCode
();
}
static
String
makeId
(
String
groupId
,
String
artifactId
)
{
return
groupId
+
":"
+
artifactId
;
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactVersion.java
浏览文件 @
2a3ccd84
...
...
@@ -265,7 +265,7 @@ public class MavenArtifactVersion {
boolean
optional
=
CommonUtils
.
getBoolean
(
XMLUtils
.
getChildElementBody
(
dep
,
"optional"
),
false
);
// TODO: maybe we should include some of them
if
(
depManagement
||
(!
optional
&&
(
scope
==
MavenArtifactDependency
.
Scope
.
COMPILE
||
scope
==
MavenArtifactDependency
.
Scope
.
RUNTIME
)))
{
if
(
depManagement
||
(!
optional
&&
includesScope
(
scope
)))
{
MavenArtifactDependency
dependency
=
new
MavenArtifactDependency
(
evaluateString
(
groupId
),
evaluateString
(
artifactId
),
...
...
@@ -294,6 +294,13 @@ public class MavenArtifactVersion {
return
result
;
}
private
boolean
includesScope
(
MavenArtifactDependency
.
Scope
scope
)
{
return
scope
==
MavenArtifactDependency
.
Scope
.
COMPILE
||
scope
==
MavenArtifactDependency
.
Scope
.
RUNTIME
||
scope
==
MavenArtifactDependency
.
Scope
.
PROVIDED
;
}
private
String
findDependencyVersion
(
DBRProgressMonitor
monitor
,
String
groupId
,
String
artifactId
)
{
if
(
dependencyManagement
!=
null
)
{
for
(
MavenArtifactDependency
dmArtifact
:
dependencyManagement
)
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
浏览文件 @
2a3ccd84
...
...
@@ -61,7 +61,9 @@ public class MavenRegistry
private
void
init
()
{
loadStandardRepositories
();
loadCustomRepositories
();
long
st
=
System
.
currentTimeMillis
();
loadCache
();
System
.
out
.
println
(
"Cache load: "
+
(
System
.
currentTimeMillis
()
-
st
)
+
"ms"
);
// Start config saver
new
ConfigSaver
().
schedule
(
ConfigSaver
.
SAVE_PERIOD
);
}
...
...
@@ -131,23 +133,18 @@ public class MavenRegistry
@Nullable
public
MavenArtifact
findArtifact
(
@NotNull
MavenArtifactReference
ref
)
{
return
findArtifact
(
ref
.
getGroupId
(),
ref
.
getArtifactId
()
,
true
);
return
findArtifact
(
ref
,
true
);
}
@Nullable
public
MavenArtifact
findArtifact
(
@NotNull
MavenArtifactReference
ref
,
boolean
resolve
)
{
return
findArtifact
(
ref
.
getGroupId
(),
ref
.
getArtifactId
(),
resolve
);
}
@Nullable
private
MavenArtifact
findArtifact
(
@NotNull
String
groupId
,
@NotNull
String
artifactId
,
boolean
resolve
)
{
String
fullId
=
groupId
+
":"
+
artifactId
;
String
fullId
=
ref
.
getId
();
if
(
notFoundArtifacts
.
contains
(
fullId
))
{
return
null
;
}
MavenArtifact
artifact
=
findInRepositories
(
groupId
,
artifactId
,
false
);
MavenArtifact
artifact
=
findInRepositories
(
ref
,
false
);
if
(
artifact
==
null
&&
resolve
)
{
artifact
=
findInRepositories
(
groupId
,
artifactId
,
true
);
artifact
=
findInRepositories
(
ref
,
true
);
}
if
(
artifact
!=
null
)
{
return
artifact
;
...
...
@@ -159,26 +156,24 @@ public class MavenRegistry
}
public
void
resetArtifactInfo
(
MavenArtifactReference
artifactReference
)
{
String
groupId
=
artifactReference
.
getGroupId
();
String
artifactId
=
artifactReference
.
getArtifactId
();
String
fullId
=
groupId
+
":"
+
artifactId
;
notFoundArtifacts
.
remove
(
fullId
);
notFoundArtifacts
.
remove
(
artifactReference
.
getId
());
for
(
MavenRepository
repository
:
repositories
)
{
repository
.
resetArtifactCache
(
groupId
,
artifactId
);
repository
.
resetArtifactCache
(
artifactReference
);
}
localRepository
.
resetArtifactCache
(
groupId
,
artifactId
);
localRepository
.
resetArtifactCache
(
artifactReference
);
}
@Nullable
private
MavenArtifact
findInRepositories
(
@NotNull
String
groupId
,
@NotNull
String
artifactId
,
boolean
resolve
)
{
private
MavenArtifact
findInRepositories
(
@NotNull
MavenArtifactReference
ref
,
boolean
resolve
)
{
// Try all available repositories (without resolve)
for
(
MavenRepository
repository
:
repositories
)
{
MavenArtifact
artifact
=
repository
.
findArtifact
(
groupId
,
artifactId
,
resolve
);
MavenArtifact
artifact
=
repository
.
findArtifact
(
ref
,
resolve
);
if
(
artifact
!=
null
)
{
return
artifact
;
}
}
MavenArtifact
artifact
=
localRepository
.
findArtifact
(
groupId
,
artifactId
,
resolve
);
MavenArtifact
artifact
=
localRepository
.
findArtifact
(
ref
,
resolve
);
if
(
artifact
!=
null
)
{
return
artifact
;
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
浏览文件 @
2a3ccd84
...
...
@@ -77,7 +77,7 @@ public class MavenRepository
private
transient
volatile
boolean
needsToSave
=
false
;
private
List
<
MavenArtifact
>
cachedArtifacts
=
new
ArrayList
<>();
private
Map
<
String
,
MavenArtifact
>
cachedArtifacts
=
new
LinkedHashMap
<>();
public
MavenRepository
(
IConfigurationElement
config
)
{
...
...
@@ -122,34 +122,24 @@ public class MavenRepository
}
@Nullable
public
synchronized
MavenArtifact
findArtifact
(
@NotNull
String
groupId
,
@NotNull
String
artifactId
,
boolean
resolve
)
{
for
(
MavenArtifact
artifact
:
cachedArtifacts
)
{
if
(
artifact
.
getGroupId
().
equals
(
groupId
)
&&
artifact
.
getArtifactId
().
equals
(
artifactId
))
{
return
artifact
;
}
}
if
(
resolve
)
{
public
synchronized
MavenArtifact
findArtifact
(
@NotNull
MavenArtifactReference
ref
,
boolean
resolve
)
{
MavenArtifact
artifact
=
cachedArtifacts
.
get
(
ref
.
getId
());
if
(
artifact
==
null
&&
resolve
)
{
// Not cached - look in remote repository
MavenArtifact
artifact
=
new
MavenArtifact
(
this
,
groupId
,
artifactId
);
artifact
=
new
MavenArtifact
(
this
,
ref
.
getGroupId
(),
ref
.
getArtifactId
()
);
try
{
artifact
.
loadMetadata
(
VoidProgressMonitor
.
INSTANCE
);
}
catch
(
IOException
e
)
{
log
.
debug
(
"Artifact ["
+
artifact
+
"] not found in repository ["
+
getUrl
()
+
"]"
);
return
null
;
}
cachedArtifacts
.
add
(
artifact
);
return
artifact
;
cachedArtifacts
.
put
(
ref
.
getId
(),
artifact
);
}
return
null
;
return
artifact
;
}
synchronized
void
resetArtifactCache
(
@NotNull
String
groupId
,
@NotNull
String
artifactId
)
{
for
(
Iterator
<
MavenArtifact
>
iterator
=
cachedArtifacts
.
iterator
();
iterator
.
hasNext
();
)
{
MavenArtifact
artifact
=
iterator
.
next
();
if
(
artifact
.
getGroupId
().
equals
(
groupId
)
&&
artifact
.
getArtifactId
().
equals
(
artifactId
))
{
iterator
.
remove
();
}
}
synchronized
void
resetArtifactCache
(
@NotNull
MavenArtifactReference
artifactReference
)
{
cachedArtifacts
.
remove
(
artifactReference
.
getId
());
}
File
getLocalCacheDir
()
...
...
@@ -220,7 +210,9 @@ public class MavenRepository
atts
.
getValue
(
ATTR_GROUP_ID
),
atts
.
getValue
(
ATTR_ARTIFACT_ID
));
lastArtifact
.
setActiveVersion
(
atts
.
getValue
(
ATTR_ACTIVE_VERSION
));
cachedArtifacts
.
add
(
lastArtifact
);
cachedArtifacts
.
put
(
MavenArtifactReference
.
makeId
(
lastArtifact
.
getGroupId
(),
lastArtifact
.
getArtifactId
()),
lastArtifact
);
}
else
if
(
TAG_VERSION
.
equals
(
localName
)
&&
lastArtifact
!=
null
)
{
Date
updateTime
=
new
Date
();
try
{
...
...
@@ -352,7 +344,7 @@ public class MavenRepository
xml
.
addAttribute
(
ATTR_NAME
,
name
);
xml
.
addAttribute
(
ATTR_URL
,
url
);
for
(
MavenArtifact
artifact
:
cachedArtifacts
)
{
for
(
MavenArtifact
artifact
:
cachedArtifacts
.
values
()
)
{
if
(
CommonUtils
.
isEmpty
(
artifact
.
getLocalVersions
()))
{
continue
;
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/driver/DriverDownloadAutoPage.java
浏览文件 @
2a3ccd84
...
...
@@ -173,7 +173,7 @@ class DriverDownloadAutoPage extends DriverDownloadPage {
List
<
DBPDriverLibrary
>
files
=
dependencies
.
getLibraryList
();
for
(
int
i
=
0
,
filesSize
=
files
.
size
();
i
<
filesSize
;
)
{
DBPDriverLibrary
lib
=
files
.
get
(
i
);
int
result
=
downloadLibraryFile
(
runnableContext
,
lib
);
int
result
=
downloadLibraryFile
(
runnableContext
,
lib
,
"Download "
+
(
i
+
1
)
+
"/"
+
filesSize
);
switch
(
result
)
{
case
IDialogConstants
.
CANCEL_ID
:
case
IDialogConstants
.
ABORT_ID
:
...
...
@@ -188,14 +188,14 @@ class DriverDownloadAutoPage extends DriverDownloadPage {
}
}
private
int
downloadLibraryFile
(
DBRRunnableContext
runnableContext
,
final
DBPDriverLibrary
file
)
private
int
downloadLibraryFile
(
DBRRunnableContext
runnableContext
,
final
DBPDriverLibrary
file
,
final
String
taskName
)
{
try
{
runnableContext
.
run
(
true
,
true
,
new
DBRRunnableWithProgress
()
{
@Override
public
void
run
(
DBRProgressMonitor
monitor
)
throws
InvocationTargetException
,
InterruptedException
{
try
{
file
.
downloadLibraryFile
(
monitor
,
getWizard
().
isUpdateVersion
()
);
file
.
downloadLibraryFile
(
monitor
,
false
,
taskName
);
}
catch
(
IOException
e
)
{
throw
new
InvocationTargetException
(
e
);
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/driver/EditMavenArtifactDialog.java
浏览文件 @
2a3ccd84
...
...
@@ -107,9 +107,10 @@ class EditMavenArtifactDialog extends Dialog
@Override
protected
void
okPressed
()
{
artifact
.
setGroupId
(
groupText
.
getText
());
artifact
.
setArtifactId
(
artifactText
.
getText
());
artifact
.
setVersion
(
versionText
.
getText
());
artifact
=
new
MavenArtifactReference
(
groupText
.
getText
(),
artifactText
.
getText
(),
versionText
.
getText
());
super
.
okPressed
();
}
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/connection/DBPDriverLibrary.java
浏览文件 @
2a3ccd84
...
...
@@ -94,8 +94,8 @@ public interface DBPDriverLibrary
boolean
matchesCurrentPlatform
();
@Nullable
Collection
<?
extends
DBPDriverLibrary
>
getDependencies
(
@NotNull
DBRProgressMonitor
monitor
,
@Nullable
DBPDriverDependencies
.
DependencyNode
ownerNode
)
throws
IOException
;
Collection
<?
extends
DBPDriverLibrary
>
getDependencies
(
@NotNull
DBRProgressMonitor
monitor
)
throws
IOException
;
void
downloadLibraryFile
(
@NotNull
DBRProgressMonitor
monitor
,
boolean
forceUpdate
)
void
downloadLibraryFile
(
@NotNull
DBRProgressMonitor
monitor
,
boolean
forceUpdate
,
String
taskName
)
throws
IOException
,
InterruptedException
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录