Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
95cd086c
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,发现更多精彩内容 >>
提交
95cd086c
编写于
10月 08, 2015
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Maven cache & resolve
Former-commit-id:
1a3824b4
上级
40c76a65
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
219 addition
and
68 deletion
+219
-68
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenArtifact.java
...s/dbeaver/registry/driver/DriverLibraryMavenArtifact.java
+6
-19
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenDependency.java
...dbeaver/registry/driver/DriverLibraryMavenDependency.java
+6
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
...e/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
+4
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactVersion.java
...rg/jkiss/dbeaver/registry/maven/MavenArtifactVersion.java
+33
-17
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenLocalVersion.java
...c/org/jkiss/dbeaver/registry/maven/MavenLocalVersion.java
+10
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
...e/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
+19
-4
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
...src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
+121
-12
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/utils/GeneralUtils.java
...eaver.model/src/org/jkiss/dbeaver/utils/GeneralUtils.java
+20
-11
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenArtifact.java
浏览文件 @
95cd086c
...
@@ -133,25 +133,12 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
...
@@ -133,25 +133,12 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
List
<
MavenArtifactDependency
>
artifactDeps
=
metaData
.
getDependencies
(
monitor
);
List
<
MavenArtifactDependency
>
artifactDeps
=
metaData
.
getDependencies
(
monitor
);
if
(!
CommonUtils
.
isEmpty
(
artifactDeps
))
{
if
(!
CommonUtils
.
isEmpty
(
artifactDeps
))
{
for
(
MavenArtifactDependency
artifactDep
:
artifactDeps
)
{
for
(
MavenArtifactDependency
artifactDep
:
artifactDeps
)
{
if
(
artifactDep
.
isOptional
())
{
MavenLocalVersion
depLocalVersion
=
artifactDep
.
resolveDependency
(
monitor
);
continue
;
if
(
depLocalVersion
!=
null
)
{
}
dependencies
.
add
(
switch
(
artifactDep
.
getScope
())
{
new
DriverLibraryMavenDependency
(
case
COMPILE:
this
.
getDriver
(),
case
RUNTIME:
depLocalVersion
));
{
MavenLocalVersion
depLocalVersion
=
artifactDep
.
resolveDependency
(
monitor
);
if
(
depLocalVersion
!=
null
)
{
dependencies
.
add
(
new
DriverLibraryMavenDependency
(
this
.
getDriver
(),
depLocalVersion
));
}
break
;
}
default
:
// We don't need it
break
;
}
}
}
}
}
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenDependency.java
浏览文件 @
95cd086c
...
@@ -34,7 +34,7 @@ public class DriverLibraryMavenDependency extends DriverLibraryMavenArtifact
...
@@ -34,7 +34,7 @@ public class DriverLibraryMavenDependency extends DriverLibraryMavenArtifact
private
MavenLocalVersion
localVersion
;
private
MavenLocalVersion
localVersion
;
public
DriverLibraryMavenDependency
(
DriverDescriptor
driverDescriptor
,
MavenLocalVersion
localVersion
)
{
public
DriverLibraryMavenDependency
(
DriverDescriptor
driverDescriptor
,
MavenLocalVersion
localVersion
)
{
super
(
driverDescriptor
,
FileType
.
jar
,
PATH_PREFIX
+
localVersion
.
getArtifact
().
toString
());
super
(
driverDescriptor
,
FileType
.
jar
,
PATH_PREFIX
+
localVersion
.
toString
());
this
.
localVersion
=
localVersion
;
this
.
localVersion
=
localVersion
;
}
}
...
@@ -64,7 +64,11 @@ public class DriverLibraryMavenDependency extends DriverLibraryMavenArtifact
...
@@ -64,7 +64,11 @@ public class DriverLibraryMavenDependency extends DriverLibraryMavenArtifact
@NotNull
@NotNull
public
String
getDisplayName
()
{
public
String
getDisplayName
()
{
return
localVersion
.
getArtifact
().
getGroupId
()
+
":"
+
localVersion
.
getArtifact
().
getArtifactId
()
+
":"
+
localVersion
.
getVersion
();
return
localVersion
.
getArtifact
().
getGroupId
()
+
":"
+
localVersion
.
getArtifact
().
getArtifactId
();
}
public
String
getVersion
()
{
return
localVersion
.
getVersion
();
}
}
protected
MavenLocalVersion
resolveLocalVersion
(
DBRProgressMonitor
monitor
,
boolean
forceUpdate
)
throws
IOException
{
protected
MavenLocalVersion
resolveLocalVersion
(
DBRProgressMonitor
monitor
,
boolean
forceUpdate
)
throws
IOException
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
浏览文件 @
95cd086c
...
@@ -259,7 +259,10 @@ public class MavenArtifact
...
@@ -259,7 +259,10 @@ public class MavenArtifact
}
}
}
}
MavenLocalVersion
localVersion
=
getActiveLocalVersion
();
MavenLocalVersion
localVersion
=
getLocalVersion
(
versionInfo
);
if
(
localVersion
==
null
&&
lookupVersion
)
{
localVersion
=
getActiveLocalVersion
();
}
if
(
localVersion
==
null
)
{
if
(
localVersion
==
null
)
{
localVersion
=
makeLocalVersion
(
monitor
,
versionInfo
,
true
);
localVersion
=
makeLocalVersion
(
monitor
,
versionInfo
,
true
);
}
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactVersion.java
浏览文件 @
95cd086c
...
@@ -19,7 +19,7 @@ package org.jkiss.dbeaver.registry.maven;
...
@@ -19,7 +19,7 @@ package org.jkiss.dbeaver.registry.maven;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.
model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.
registry.driver.DriverLibraryMavenDependency
;
import
org.jkiss.dbeaver.runtime.RuntimeUtils
;
import
org.jkiss.dbeaver.runtime.RuntimeUtils
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
import
org.jkiss.utils.CommonUtils
;
import
org.jkiss.utils.CommonUtils
;
...
@@ -48,7 +48,6 @@ public class MavenArtifactVersion {
...
@@ -48,7 +48,6 @@ public class MavenArtifactVersion {
private
String
description
;
private
String
description
;
private
String
url
;
private
String
url
;
private
MavenLocalVersion
parent
;
private
MavenLocalVersion
parent
;
private
MavenArtifactReference
parentReference
;
private
Map
<
String
,
String
>
properties
=
new
LinkedHashMap
<>();
private
Map
<
String
,
String
>
properties
=
new
LinkedHashMap
<>();
private
List
<
MavenArtifactLicense
>
licenses
=
new
ArrayList
<>();
private
List
<
MavenArtifactLicense
>
licenses
=
new
ArrayList
<>();
private
List
<
MavenArtifactDependency
>
dependencies
;
private
List
<
MavenArtifactDependency
>
dependencies
;
...
@@ -66,7 +65,7 @@ public class MavenArtifactVersion {
...
@@ -66,7 +65,7 @@ public class MavenArtifactVersion {
}
else
if
(
name
.
equals
(
PROP_PROJECT_ARTIFACT_ID
))
{
}
else
if
(
name
.
equals
(
PROP_PROJECT_ARTIFACT_ID
))
{
value
=
localVersion
.
getArtifact
().
getArtifactId
();
value
=
localVersion
.
getArtifact
().
getArtifactId
();
}
else
if
(
parent
!=
null
)
{
}
else
if
(
parent
!=
null
)
{
return
parent
.
getMetaData
(
VoidProgressMonitor
.
INSTANCE
).
variableResolver
.
get
(
name
);
return
parent
.
getMetaData
().
variableResolver
.
get
(
name
);
}
}
}
}
return
value
;
return
value
;
...
@@ -78,7 +77,8 @@ public class MavenArtifactVersion {
...
@@ -78,7 +77,8 @@ public class MavenArtifactVersion {
loadPOM
(
monitor
);
loadPOM
(
monitor
);
}
}
MavenArtifactVersion
(
String
name
,
String
version
)
{
MavenArtifactVersion
(
MavenLocalVersion
localVersion
,
String
name
,
String
version
)
{
this
.
localVersion
=
localVersion
;
this
.
name
=
name
;
this
.
name
=
name
;
this
.
version
=
version
;
this
.
version
=
version
;
}
}
...
@@ -103,8 +103,19 @@ public class MavenArtifactVersion {
...
@@ -103,8 +103,19 @@ public class MavenArtifactVersion {
return
url
;
return
url
;
}
}
public
MavenArtifactReference
getParentReference
()
{
public
MavenLocalVersion
getParent
()
{
return
parentReference
;
return
parent
;
}
void
setParent
(
MavenLocalVersion
parent
)
{
this
.
parent
=
parent
;
}
void
addDependency
(
MavenArtifactDependency
dependency
)
{
if
(
dependencies
==
null
)
{
dependencies
=
new
ArrayList
<>();
}
dependencies
.
add
(
dependency
);
}
}
public
Map
<
String
,
String
>
getProperties
()
{
public
Map
<
String
,
String
>
getProperties
()
{
...
@@ -164,7 +175,7 @@ public class MavenArtifactVersion {
...
@@ -164,7 +175,7 @@ public class MavenArtifactVersion {
if
(
parentGroupId
==
null
||
parentArtifactId
==
null
||
parentVersion
==
null
)
{
if
(
parentGroupId
==
null
||
parentArtifactId
==
null
||
parentVersion
==
null
)
{
log
.
error
(
"Broken parent reference: "
+
parentGroupId
+
":"
+
parentArtifactId
+
":"
+
parentVersion
);
log
.
error
(
"Broken parent reference: "
+
parentGroupId
+
":"
+
parentArtifactId
+
":"
+
parentVersion
);
}
else
{
}
else
{
parentReference
=
new
MavenArtifactReference
(
MavenArtifactReference
parentReference
=
new
MavenArtifactReference
(
parentGroupId
,
parentGroupId
,
parentArtifactId
,
parentArtifactId
,
parentVersion
parentVersion
...
@@ -208,14 +219,14 @@ public class MavenArtifactVersion {
...
@@ -208,14 +219,14 @@ public class MavenArtifactVersion {
// Dependencies
// Dependencies
Element
dmElement
=
XMLUtils
.
getChildElement
(
root
,
"dependencyManagement"
);
Element
dmElement
=
XMLUtils
.
getChildElement
(
root
,
"dependencyManagement"
);
if
(
dmElement
!=
null
)
{
if
(
dmElement
!=
null
)
{
dependencyManagement
=
parseDependencies
(
monitor
,
dmElement
);
dependencyManagement
=
parseDependencies
(
monitor
,
dmElement
,
true
);
}
}
dependencies
=
parseDependencies
(
monitor
,
root
);
dependencies
=
parseDependencies
(
monitor
,
root
,
false
);
}
}
monitor
.
worked
(
1
);
monitor
.
worked
(
1
);
}
}
private
List
<
MavenArtifactDependency
>
parseDependencies
(
DBRProgressMonitor
monitor
,
Element
element
)
{
private
List
<
MavenArtifactDependency
>
parseDependencies
(
DBRProgressMonitor
monitor
,
Element
element
,
boolean
all
)
{
List
<
MavenArtifactDependency
>
result
=
new
ArrayList
<>();
List
<
MavenArtifactDependency
>
result
=
new
ArrayList
<>();
Element
dependenciesElement
=
XMLUtils
.
getChildElement
(
element
,
"dependencies"
);
Element
dependenciesElement
=
XMLUtils
.
getChildElement
(
element
,
"dependencies"
);
if
(
dependenciesElement
!=
null
)
{
if
(
dependenciesElement
!=
null
)
{
...
@@ -239,13 +250,18 @@ public class MavenArtifactVersion {
...
@@ -239,13 +250,18 @@ public class MavenArtifactVersion {
if
(!
CommonUtils
.
isEmpty
(
scopeName
))
{
if
(!
CommonUtils
.
isEmpty
(
scopeName
))
{
scope
=
MavenArtifactDependency
.
Scope
.
valueOf
(
scopeName
.
toUpperCase
(
Locale
.
ENGLISH
));
scope
=
MavenArtifactDependency
.
Scope
.
valueOf
(
scopeName
.
toUpperCase
(
Locale
.
ENGLISH
));
}
}
result
.
add
(
new
MavenArtifactDependency
(
boolean
optional
=
CommonUtils
.
getBoolean
(
XMLUtils
.
getChildElementBody
(
dep
,
"optional"
),
false
);
evaluateString
(
groupId
),
evaluateString
(
artifactId
),
// TODO: maybe we should include some of them
evaluateString
(
version
),
if
(
all
||
(!
optional
&&
(
scope
==
MavenArtifactDependency
.
Scope
.
COMPILE
||
scope
==
MavenArtifactDependency
.
Scope
.
RUNTIME
)))
{
scope
,
result
.
add
(
new
MavenArtifactDependency
(
CommonUtils
.
getBoolean
(
XMLUtils
.
getChildElementBody
(
dep
,
"optional"
),
false
)
evaluateString
(
groupId
),
));
evaluateString
(
artifactId
),
evaluateString
(
version
),
scope
,
optional
));
}
}
}
}
}
return
result
;
return
result
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenLocalVersion.java
浏览文件 @
95cd086c
...
@@ -88,19 +88,27 @@ public class MavenLocalVersion
...
@@ -88,19 +88,27 @@ public class MavenLocalVersion
metaData
=
new
MavenArtifactVersion
(
monitor
,
this
);
metaData
=
new
MavenArtifactVersion
(
monitor
,
this
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
log
.
warn
(
"Error fetching POM file"
,
e
);
log
.
warn
(
"Error fetching POM file"
,
e
);
metaData
=
new
MavenArtifactVersion
(
artifact
.
getArtifactId
(),
version
);
metaData
=
new
MavenArtifactVersion
(
this
,
artifact
.
getArtifactId
(),
version
);
}
}
}
}
return
metaData
;
return
metaData
;
}
}
public
String
getPath
()
{
return
artifact
.
toString
()
+
":"
+
version
;
}
MavenArtifactVersion
getMetaData
()
{
MavenArtifactVersion
getMetaData
()
{
return
metaData
;
return
metaData
;
}
}
void
setMetaData
(
MavenArtifactVersion
metaData
)
{
this
.
metaData
=
metaData
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
artifact
.
toString
()
+
":"
+
version
;
return
getPath
()
;
}
}
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
浏览文件 @
95cd086c
...
@@ -44,18 +44,29 @@ public class MavenRegistry
...
@@ -44,18 +44,29 @@ public class MavenRegistry
{
{
if
(
instance
==
null
)
{
if
(
instance
==
null
)
{
instance
=
new
MavenRegistry
();
instance
=
new
MavenRegistry
();
instance
.
loadCustomRepositories
();
instance
.
init
();
}
}
return
instance
;
return
instance
;
}
}
private
final
List
<
MavenRepository
>
repositories
=
new
ArrayList
<
MavenRepository
>();
private
final
List
<
MavenRepository
>
repositories
=
new
ArrayList
<
MavenRepository
>();
private
final
MavenRepository
localRepository
;
private
MavenRepository
localRepository
;
// Cache for not found artifact ids. Avoid multiple remote metadata reading
// Cache for not found artifact ids. Avoid multiple remote metadata reading
private
final
Set
<
String
>
notFoundArtifacts
=
new
HashSet
<
String
>();
private
final
Set
<
String
>
notFoundArtifacts
=
new
HashSet
<
String
>();
private
MavenRegistry
()
private
MavenRegistry
()
{
{
}
private
void
init
()
{
loadStandardRepositories
();
loadCustomRepositories
();
loadCache
();
// Start config saver
new
ConfigSaver
().
schedule
(
ConfigSaver
.
SAVE_PERIOD
);
}
private
void
loadStandardRepositories
()
{
// Load repositories info
// Load repositories info
{
{
IConfigurationElement
[]
extElements
=
Platform
.
getExtensionRegistry
().
getConfigurationElementsFor
(
MavenRepository
.
EXTENSION_ID
);
IConfigurationElement
[]
extElements
=
Platform
.
getExtensionRegistry
().
getConfigurationElementsFor
(
MavenRepository
.
EXTENSION_ID
);
...
@@ -76,9 +87,13 @@ public class MavenRegistry
...
@@ -76,9 +87,13 @@ public class MavenRegistry
MAVEN_LOCAL_REPO_NAME
,
MAVEN_LOCAL_REPO_NAME
,
localRepoURL
,
localRepoURL
,
true
);
true
);
}
// Start config saver
private
void
loadCache
()
{
new
ConfigSaver
().
schedule
(
ConfigSaver
.
SAVE_PERIOD
);
localRepository
.
loadCache
();
for
(
MavenRepository
repository
:
repositories
)
{
repository
.
loadCache
();
}
}
}
public
void
loadCustomRepositories
()
{
public
void
loadCustomRepositories
()
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
浏览文件 @
95cd086c
...
@@ -33,6 +33,9 @@ import org.jkiss.utils.xml.XMLException;
...
@@ -33,6 +33,9 @@ import org.jkiss.utils.xml.XMLException;
import
org.xml.sax.Attributes
;
import
org.xml.sax.Attributes
;
import
java.io.*
;
import
java.io.*
;
import
java.text.DateFormat
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
/**
/**
...
@@ -46,10 +49,10 @@ public class MavenRepository
...
@@ -46,10 +49,10 @@ public class MavenRepository
public
static
final
String
METADATA_CACHE_FILE
=
"metadata-cache.xml"
;
public
static
final
String
METADATA_CACHE_FILE
=
"metadata-cache.xml"
;
p
rivate
static
final
String
TAG_CACHE
=
"cache"
;
p
ublic
static
final
String
TAG_CACHE
=
"cache"
;
p
rivate
static
final
String
TAG_ARTIFACT
=
"artifact"
;
p
ublic
static
final
String
TAG_ARTIFACT
=
"artifact"
;
p
rivate
static
final
String
TAG_VERSION
=
"version"
;
p
ublic
static
final
String
TAG_VERSION
=
"version"
;
p
rivate
static
final
String
TAG_DEPENDENCY
=
"dependency"
;
p
ublic
static
final
String
TAG_DEPENDENCY
=
"dependency"
;
public
static
final
String
ATTR_NAME
=
"name"
;
public
static
final
String
ATTR_NAME
=
"name"
;
public
static
final
String
ATTR_URL
=
"url"
;
public
static
final
String
ATTR_URL
=
"url"
;
...
@@ -59,9 +62,12 @@ public class MavenRepository
...
@@ -59,9 +62,12 @@ public class MavenRepository
public
static
final
String
ATTR_VERSION
=
"version"
;
public
static
final
String
ATTR_VERSION
=
"version"
;
public
static
final
String
ATTR_PATH
=
"path"
;
public
static
final
String
ATTR_PATH
=
"path"
;
public
static
final
String
ATTR_SCOPE
=
"scope"
;
public
static
final
String
ATTR_SCOPE
=
"scope"
;
private
static
final
String
ATTR_PARENT
=
"parent"
;
public
static
final
String
ATTR_OPTIONAL
=
"optional"
;
public
static
final
String
ATTR_PARENT
=
"parent"
;
public
static
final
String
ATTR_UPDATE_TIME
=
"updateTime"
;
public
static
final
String
ATTR_UPDATE_TIME
=
"updateTime"
;
private
static
final
DateFormat
UPDATE_TIME_FORMAT
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
private
String
id
;
private
String
id
;
private
String
name
;
private
String
name
;
private
String
url
;
private
String
url
;
...
@@ -88,7 +94,6 @@ public class MavenRepository
...
@@ -88,7 +94,6 @@ public class MavenRepository
if
(!
url
.
endsWith
(
"/"
))
url
+=
"/"
;
if
(!
url
.
endsWith
(
"/"
))
url
+=
"/"
;
this
.
url
=
url
;
this
.
url
=
url
;
this
.
local
=
local
;
this
.
local
=
local
;
loadCache
();
}
}
public
void
flushCache
()
{
public
void
flushCache
()
{
...
@@ -158,17 +163,52 @@ public class MavenRepository
...
@@ -158,17 +163,52 @@ public class MavenRepository
return
homeFolder
;
return
homeFolder
;
}
}
synchronized
private
void
loadCache
()
{
private
static
class
DependencyResolveInfo
{
String
path
;
MavenArtifactDependency
.
Scope
scope
;
boolean
optional
;
DependencyResolveInfo
(
String
path
,
MavenArtifactDependency
.
Scope
scope
,
boolean
optional
)
{
this
.
path
=
path
;
this
.
scope
=
scope
;
this
.
optional
=
optional
;
}
@Override
public
String
toString
()
{
return
path
;
}
}
private
static
class
VersionResolveInfo
{
MavenLocalVersion
localVersion
;
String
parentPath
;
List
<
DependencyResolveInfo
>
dependencies
=
new
ArrayList
<>();
public
VersionResolveInfo
(
MavenLocalVersion
localVersion
,
String
parentPath
)
{
this
.
localVersion
=
localVersion
;
this
.
parentPath
=
parentPath
;
}
@Override
public
String
toString
()
{
return
localVersion
.
toString
();
}
}
synchronized
void
loadCache
()
{
File
cacheFile
=
new
File
(
getLocalCacheDir
(),
METADATA_CACHE_FILE
);
File
cacheFile
=
new
File
(
getLocalCacheDir
(),
METADATA_CACHE_FILE
);
if
(!
cacheFile
.
exists
())
{
if
(!
cacheFile
.
exists
())
{
return
;
return
;
}
}
final
List
<
VersionResolveInfo
>
lateResolutions
=
new
ArrayList
<>();
try
{
try
{
InputStream
mdStream
=
new
FileInputStream
(
cacheFile
);
InputStream
mdStream
=
new
FileInputStream
(
cacheFile
);
try
{
try
{
SAXReader
reader
=
new
SAXReader
(
mdStream
);
SAXReader
reader
=
new
SAXReader
(
mdStream
);
reader
.
parse
(
new
SAXListener
()
{
reader
.
parse
(
new
SAXListener
()
{
public
MavenArtifact
lastArtifact
;
MavenArtifact
lastArtifact
;
VersionResolveInfo
lastVersionResolveInfo
;
@Override
@Override
public
void
saxStartElement
(
SAXReader
reader
,
String
namespaceURI
,
String
localName
,
Attributes
atts
)
throws
XMLException
{
public
void
saxStartElement
(
SAXReader
reader
,
String
namespaceURI
,
String
localName
,
Attributes
atts
)
throws
XMLException
{
if
(
TAG_ARTIFACT
.
equals
(
localName
))
{
if
(
TAG_ARTIFACT
.
equals
(
localName
))
{
...
@@ -179,11 +219,38 @@ public class MavenRepository
...
@@ -179,11 +219,38 @@ public class MavenRepository
lastArtifact
.
setActiveVersion
(
atts
.
getValue
(
ATTR_ACTIVE_VERSION
));
lastArtifact
.
setActiveVersion
(
atts
.
getValue
(
ATTR_ACTIVE_VERSION
));
cachedArtifacts
.
add
(
lastArtifact
);
cachedArtifacts
.
add
(
lastArtifact
);
}
else
if
(
TAG_VERSION
.
equals
(
localName
)
&&
lastArtifact
!=
null
)
{
}
else
if
(
TAG_VERSION
.
equals
(
localName
)
&&
lastArtifact
!=
null
)
{
Date
updateTime
=
new
Date
();
try
{
updateTime
=
UPDATE_TIME_FORMAT
.
parse
(
atts
.
getValue
(
ATTR_UPDATE_TIME
));
}
catch
(
ParseException
e
)
{
// ignore
}
String
versionNumber
=
atts
.
getValue
(
ATTR_VERSION
);
MavenLocalVersion
version
=
new
MavenLocalVersion
(
MavenLocalVersion
version
=
new
MavenLocalVersion
(
lastArtifact
,
lastArtifact
,
atts
.
getValue
(
ATTR_VERSION
)
,
versionNumber
,
new
Date
(
Long
.
parseLong
(
atts
.
getValue
(
ATTR_UPDATE_TIME
)))
);
updateTime
);
lastArtifact
.
addLocalVersion
(
version
);
lastArtifact
.
addLocalVersion
(
version
);
MavenArtifactVersion
lastVersion
=
new
MavenArtifactVersion
(
version
,
lastArtifact
.
getArtifactId
(),
versionNumber
);
version
.
setMetaData
(
lastVersion
);
lastVersionResolveInfo
=
new
VersionResolveInfo
(
version
,
atts
.
getValue
(
ATTR_PARENT
));
lateResolutions
.
add
(
lastVersionResolveInfo
);
}
else
if
(
TAG_DEPENDENCY
.
equals
(
localName
)
&&
lastVersionResolveInfo
!=
null
)
{
MavenArtifactDependency
.
Scope
scope
=
MavenArtifactDependency
.
Scope
.
COMPILE
;
String
scopeString
=
atts
.
getValue
(
ATTR_SCOPE
);
if
(
scopeString
!=
null
)
{
try
{
scope
=
MavenArtifactDependency
.
Scope
.
valueOf
(
scopeString
.
toUpperCase
(
Locale
.
ENGLISH
));
}
catch
(
IllegalArgumentException
e
)
{
log
.
debug
(
e
);
}
}
lastVersionResolveInfo
.
dependencies
.
add
(
new
DependencyResolveInfo
(
atts
.
getValue
(
ATTR_PATH
),
scope
,
CommonUtils
.
getBoolean
(
atts
.
getValue
(
ATTR_OPTIONAL
),
false
)
));
}
}
}
}
@Override
@Override
...
@@ -194,6 +261,8 @@ public class MavenRepository
...
@@ -194,6 +261,8 @@ public class MavenRepository
public
void
saxEndElement
(
SAXReader
reader
,
String
namespaceURI
,
String
localName
)
throws
XMLException
{
public
void
saxEndElement
(
SAXReader
reader
,
String
namespaceURI
,
String
localName
)
throws
XMLException
{
if
(
TAG_ARTIFACT
.
equals
(
localName
))
{
if
(
TAG_ARTIFACT
.
equals
(
localName
))
{
lastArtifact
=
null
;
lastArtifact
=
null
;
}
else
if
(
TAG_VERSION
.
equals
(
localName
))
{
lastVersionResolveInfo
=
null
;
}
}
}
}
});
});
...
@@ -205,6 +274,43 @@ public class MavenRepository
...
@@ -205,6 +274,43 @@ public class MavenRepository
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
log
.
warn
(
"IO error while reading cached Maven repository '"
+
id
+
"'"
,
e
);
log
.
warn
(
"IO error while reading cached Maven repository '"
+
id
+
"'"
,
e
);
}
}
// Perform late resolution
for
(
VersionResolveInfo
vri
:
lateResolutions
)
{
if
(
vri
.
parentPath
!=
null
)
{
MavenLocalVersion
parentVersion
=
resolveLocalVersion
(
vri
.
parentPath
);
if
(
parentVersion
!=
null
)
{
vri
.
localVersion
.
getMetaData
().
setParent
(
parentVersion
);
}
}
for
(
DependencyResolveInfo
dri
:
vri
.
dependencies
)
{
MavenLocalVersion
depVersion
=
resolveLocalVersion
(
dri
.
path
);
if
(
depVersion
!=
null
)
{
vri
.
localVersion
.
getMetaData
().
addDependency
(
new
MavenArtifactDependency
(
depVersion
.
getArtifact
().
getGroupId
(),
depVersion
.
getArtifact
().
getArtifactId
(),
depVersion
.
getVersion
(),
dri
.
scope
,
dri
.
optional
));
}
}
}
}
private
MavenLocalVersion
resolveLocalVersion
(
String
path
)
{
MavenArtifactReference
parentRef
=
new
MavenArtifactReference
(
path
);
MavenArtifact
parentArtifact
=
MavenRegistry
.
getInstance
().
findArtifact
(
parentRef
);
if
(
parentArtifact
==
null
)
{
log
.
warn
(
"Can't resolve artifact "
+
parentRef
);
return
null
;
}
else
{
MavenLocalVersion
localVersion
=
parentArtifact
.
getLocalVersion
(
parentRef
.
getVersion
());
if
(
localVersion
==
null
)
{
log
.
warn
(
"Can't resolve artifact version "
+
parentRef
);
}
return
localVersion
;
}
}
}
void
saveCacheIfNeeded
()
{
void
saveCacheIfNeeded
()
{
...
@@ -242,11 +348,11 @@ public class MavenRepository
...
@@ -242,11 +348,11 @@ public class MavenRepository
for
(
MavenLocalVersion
version
:
artifact
.
getLocalVersions
())
{
for
(
MavenLocalVersion
version
:
artifact
.
getLocalVersions
())
{
try
(
XMLBuilder
.
Element
e2
=
xml
.
startElement
(
TAG_VERSION
))
{
try
(
XMLBuilder
.
Element
e2
=
xml
.
startElement
(
TAG_VERSION
))
{
xml
.
addAttribute
(
ATTR_VERSION
,
version
.
getVersion
());
xml
.
addAttribute
(
ATTR_VERSION
,
version
.
getVersion
());
xml
.
addAttribute
(
ATTR_UPDATE_TIME
,
version
.
getUpdateTime
().
getTime
(
));
xml
.
addAttribute
(
ATTR_UPDATE_TIME
,
UPDATE_TIME_FORMAT
.
format
(
version
.
getUpdateTime
()
));
MavenArtifactVersion
metaData
=
version
.
getMetaData
();
MavenArtifactVersion
metaData
=
version
.
getMetaData
();
if
(
metaData
!=
null
)
{
if
(
metaData
!=
null
)
{
Maven
ArtifactReference
parentReference
=
metaData
.
getParentReference
();
Maven
LocalVersion
parentReference
=
metaData
.
getParent
();
if
(
parentReference
!=
null
)
{
if
(
parentReference
!=
null
)
{
xml
.
addAttribute
(
ATTR_PARENT
,
parentReference
.
getPath
());
xml
.
addAttribute
(
ATTR_PARENT
,
parentReference
.
getPath
());
}
}
...
@@ -258,6 +364,9 @@ public class MavenRepository
...
@@ -258,6 +364,9 @@ public class MavenRepository
if
(
dependency
.
getScope
()
!=
MavenArtifactDependency
.
Scope
.
COMPILE
)
{
if
(
dependency
.
getScope
()
!=
MavenArtifactDependency
.
Scope
.
COMPILE
)
{
xml
.
addAttribute
(
ATTR_SCOPE
,
dependency
.
getScope
().
name
().
toLowerCase
(
Locale
.
ENGLISH
));
xml
.
addAttribute
(
ATTR_SCOPE
,
dependency
.
getScope
().
name
().
toLowerCase
(
Locale
.
ENGLISH
));
}
}
if
(
dependency
.
isOptional
())
{
xml
.
addAttribute
(
ATTR_OPTIONAL
,
true
);
}
}
}
}
}
}
}
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/utils/GeneralUtils.java
浏览文件 @
95cd086c
...
@@ -252,19 +252,28 @@ public class GeneralUtils {
...
@@ -252,19 +252,28 @@ public class GeneralUtils {
}
}
public
static
String
replaceVariables
(
String
string
,
IVariableResolver
resolver
)
{
public
static
String
replaceVariables
(
String
string
,
IVariableResolver
resolver
)
{
Matcher
matcher
=
VAR_PATTERN
.
matcher
(
string
);
try
{
int
pos
=
0
;
Matcher
matcher
=
VAR_PATTERN
.
matcher
(
string
);
while
(
matcher
.
find
(
pos
))
{
int
pos
=
0
;
pos
=
matcher
.
end
();
while
(
matcher
.
find
(
pos
))
{
String
varName
=
matcher
.
group
(
2
);
pos
=
matcher
.
end
();
String
varValue
=
resolver
.
get
(
varName
);
String
varName
=
matcher
.
group
(
2
);
if
(
varValue
!=
null
)
{
String
varValue
=
resolver
.
get
(
varName
);
matcher
=
VAR_PATTERN
.
matcher
(
if
(
varValue
!=
null
)
{
string
=
matcher
.
replaceFirst
(
varValue
));
if
(
matcher
.
start
()
==
0
&&
matcher
.
end
()
==
string
.
length
()
-
1
)
{
pos
=
0
;
string
=
varValue
;
}
else
{
string
=
string
.
substring
(
0
,
matcher
.
start
())
+
varValue
+
string
.
substring
(
matcher
.
end
());
}
matcher
=
VAR_PATTERN
.
matcher
(
string
);
pos
=
0
;
}
}
}
return
string
;
}
catch
(
Exception
e
)
{
log
.
warn
(
"Error matching regex"
,
e
);
return
string
;
}
}
return
string
;
}
}
public
static
String
[]
parseCommandLine
(
String
commandLine
)
{
public
static
String
[]
parseCommandLine
(
String
commandLine
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录