Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
84fbe383
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,发现更多精彩内容 >>
提交
84fbe383
编写于
9月 19, 2015
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Maven local repository
上级
cc329424
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
67 addition
and
21 deletion
+67
-21
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DriverFileDescriptor.java
.../src/org/jkiss/dbeaver/registry/DriverFileDescriptor.java
+12
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
...e/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
+9
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenLocalVersion.java
...c/org/jkiss/dbeaver/registry/maven/MavenLocalVersion.java
+11
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
...e/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
+17
-7
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
...src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
+18
-10
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DriverFileDescriptor.java
浏览文件 @
84fbe383
...
...
@@ -26,6 +26,7 @@ import org.jkiss.dbeaver.core.DBeaverCore;
import
org.jkiss.dbeaver.model.DBPDriverFile
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.OSDescriptor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.registry.maven.MavenArtifact
;
import
org.jkiss.dbeaver.registry.maven.MavenArtifactReference
;
import
org.jkiss.dbeaver.registry.maven.MavenLocalVersion
;
...
...
@@ -34,7 +35,8 @@ import org.jkiss.dbeaver.runtime.RuntimeUtils;
import
org.jkiss.dbeaver.utils.ContentUtils
;
import
java.io.*
;
import
java.net.*
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.text.NumberFormat
;
/**
...
...
@@ -171,6 +173,15 @@ public class DriverFileDescriptor implements DBPDriverFile
MavenArtifact
artifact
=
getMavenArtifact
();
if
(
artifact
!=
null
)
{
MavenLocalVersion
localVersion
=
artifact
.
getActiveLocalVersion
();
if
(
localVersion
==
null
&&
artifact
.
getRepository
().
isLocal
())
{
// In case of local artifact make version resolve
MavenArtifactReference
artifactInfo
=
new
MavenArtifactReference
(
path
);
try
{
localVersion
=
artifact
.
resolveVersion
(
VoidProgressMonitor
.
INSTANCE
,
artifactInfo
.
getVersion
());
}
catch
(
IOException
e
)
{
log
.
warn
(
"Error resolving local artifact ["
+
artifact
+
"] version"
,
e
);
}
}
if
(
localVersion
!=
null
)
{
return
localVersion
.
getCacheFile
();
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
浏览文件 @
84fbe383
...
...
@@ -64,6 +64,11 @@ public class MavenArtifact
}
public
void
loadMetadata
()
throws
IOException
{
latestVersion
=
null
;
releaseVersion
=
null
;
versions
.
clear
();
lastUpdate
=
null
;
String
metadataPath
=
getArtifactDir
()
+
MAVEN_METADATA_XML
;
InputStream
mdStream
=
RuntimeUtils
.
openConnectionStream
(
metadataPath
);
try
{
...
...
@@ -211,7 +216,7 @@ public class MavenArtifact
localVersions
.
remove
(
version
);
}
public
void
resolveVersion
(
DBRProgressMonitor
monitor
,
String
versionRef
)
throws
IOException
{
public
MavenLocalVersion
resolveVersion
(
DBRProgressMonitor
monitor
,
String
versionRef
)
throws
IOException
{
monitor
.
beginTask
(
"Download Maven artifact '"
+
this
+
"'"
,
3
);
try
{
monitor
.
subTask
(
"Download metadata from "
+
repository
.
getUrl
());
...
...
@@ -257,12 +262,14 @@ public class MavenArtifact
localVersion
=
null
;
}
if
(
localVersion
==
null
)
{
makeLocalVersion
(
versionInfo
,
true
);
localVersion
=
makeLocalVersion
(
versionInfo
,
true
);
}
monitor
.
worked
(
1
);
monitor
.
subTask
(
"Save repository cache"
);
repository
.
flushCache
();
monitor
.
worked
(
1
);
return
localVersion
;
}
finally
{
monitor
.
done
();
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenLocalVersion.java
浏览文件 @
84fbe383
...
...
@@ -21,6 +21,9 @@ import org.jkiss.dbeaver.Log;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.MalformedURLException
;
import
java.net.URISyntaxException
;
import
java.net.URL
;
import
java.util.Date
;
/**
...
...
@@ -31,6 +34,7 @@ import java.util.Date;
public
class
MavenLocalVersion
{
static
final
Log
log
=
Log
.
getLog
(
MavenLocalVersion
.
class
);
private
static
final
java
.
lang
.
String
FILE_PROTOCOL
=
"file:/"
;
private
MavenArtifact
artifact
;
private
String
version
;
...
...
@@ -63,7 +67,13 @@ public class MavenLocalVersion
public
File
getCacheFile
()
{
if
(
artifact
.
getRepository
().
isLocal
())
{
return
new
File
(
getExternalURL
(
MavenArtifact
.
FILE_JAR
));
String
externalURL
=
getExternalURL
(
MavenArtifact
.
FILE_JAR
);
try
{
return
new
File
(
new
URL
(
externalURL
).
toURI
());
}
catch
(
Exception
e
)
{
log
.
warn
(
"Bad repository URL"
,
e
);
return
new
File
(
externalURL
);
}
}
return
new
File
(
artifact
.
getRepository
().
getLocalCacheDir
(),
artifact
.
getGroupId
()
+
"/"
+
fileName
);
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
浏览文件 @
84fbe383
...
...
@@ -119,22 +119,32 @@ public class MavenRegistry
if
(
notFoundArtifacts
.
contains
(
fullId
))
{
return
null
;
}
MavenArtifact
artifact
=
findInRepositories
(
groupId
,
artifactId
,
false
);
if
(
artifact
==
null
)
{
artifact
=
findInRepositories
(
groupId
,
artifactId
,
true
);
}
if
(
artifact
!=
null
)
{
return
artifact
;
}
// Try all available repositories
// Not found
notFoundArtifacts
.
add
(
fullId
);
return
null
;
}
@Nullable
private
MavenArtifact
findInRepositories
(
@NotNull
String
groupId
,
@NotNull
String
artifactId
,
boolean
resolve
)
{
// Try all available repositories (without resolve)
for
(
MavenRepository
repository
:
repositories
)
{
MavenArtifact
artifact
=
repository
.
findArtifact
(
groupId
,
artifactId
);
MavenArtifact
artifact
=
repository
.
findArtifact
(
groupId
,
artifactId
,
resolve
);
if
(
artifact
!=
null
)
{
return
artifact
;
}
}
// Try local repository
MavenArtifact
artifact
=
localRepository
.
findArtifact
(
groupId
,
artifactId
);
MavenArtifact
artifact
=
localRepository
.
findArtifact
(
groupId
,
artifactId
,
resolve
);
if
(
artifact
!=
null
)
{
return
artifact
;
}
// Not found
notFoundArtifacts
.
add
(
fullId
);
return
null
;
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
浏览文件 @
84fbe383
...
...
@@ -81,6 +81,7 @@ public class MavenRepository
MavenRepository
(
String
id
,
String
name
,
String
url
,
boolean
local
)
{
this
.
id
=
id
;
this
.
name
=
name
;
if
(!
url
.
endsWith
(
"/"
))
url
+=
"/"
;
this
.
url
=
url
;
this
.
local
=
local
;
if
(!
local
)
{
...
...
@@ -113,22 +114,25 @@ public class MavenRepository
}
@Nullable
public
MavenArtifact
findArtifact
(
@NotNull
String
groupId
,
@NotNull
String
artifactId
)
{
public
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
;
}
}
// Not cached - look in remote repository
MavenArtifact
artifact
=
new
MavenArtifact
(
this
,
groupId
,
artifactId
);
try
{
artifact
.
loadMetadata
();
}
catch
(
IOException
e
)
{
log
.
debug
(
"Artifact ["
+
artifact
+
"] not found in repository ["
+
getUrl
()
+
"]"
);
return
null
;
if
(
resolve
)
{
// Not cached - look in remote repository
MavenArtifact
artifact
=
new
MavenArtifact
(
this
,
groupId
,
artifactId
);
try
{
artifact
.
loadMetadata
();
}
catch
(
IOException
e
)
{
log
.
debug
(
"Artifact ["
+
artifact
+
"] not found in repository ["
+
getUrl
()
+
"]"
);
return
null
;
}
cachedArtifacts
.
add
(
artifact
);
return
artifact
;
}
cachedArtifacts
.
add
(
artifact
);
return
artifact
;
return
null
;
}
private
synchronized
void
addCachedArtifact
(
@NotNull
MavenArtifact
artifact
)
{
...
...
@@ -244,4 +248,8 @@ public class MavenRepository
}
}
@Override
public
String
toString
()
{
return
url
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录