Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
c35ad67d
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,发现更多精彩内容 >>
提交
c35ad67d
编写于
10月 12, 2015
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Maven model refactoring
Former-commit-id:
a1785602
上级
852bd4d1
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
237 addition
and
500 deletion
+237
-500
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryAbstract.java
.../jkiss/dbeaver/registry/driver/DriverLibraryAbstract.java
+14
-10
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenArtifact.java
...s/dbeaver/registry/driver/DriverLibraryMavenArtifact.java
+23
-72
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenDependency.java
...dbeaver/registry/driver/DriverLibraryMavenDependency.java
+5
-9
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
...e/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
+55
-48
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactDependency.java
...jkiss/dbeaver/registry/maven/MavenArtifactDependency.java
+8
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactReference.java
.../jkiss/dbeaver/registry/maven/MavenArtifactReference.java
+1
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactVersion.java
...rg/jkiss/dbeaver/registry/maven/MavenArtifactVersion.java
+91
-52
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenLocalVersion.java
...c/org/jkiss/dbeaver/registry/maven/MavenLocalVersion.java
+0
-114
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
...e/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
+7
-15
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
...src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
+31
-180
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/RuntimeUtils.java
...aver.core/src/org/jkiss/dbeaver/runtime/RuntimeUtils.java
+2
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryAbstract.java
浏览文件 @
c35ad67d
...
...
@@ -153,6 +153,20 @@ public abstract class DriverLibraryAbstract implements DBPDriverLibrary
public
void
downloadLibraryFile
(
@NotNull
DBRProgressMonitor
monitor
,
boolean
forceUpdate
,
String
taskName
)
throws
IOException
,
InterruptedException
{
final
File
localFile
=
getLocalFile
();
if
(
localFile
==
null
)
{
throw
new
IOException
(
"No target file for '"
+
getPath
()
+
"'"
);
}
if
(!
forceUpdate
&&
localFile
.
exists
())
{
return
;
}
final
File
localDir
=
localFile
.
getParentFile
();
if
(!
localDir
.
exists
())
{
if
(!
localDir
.
mkdirs
())
{
log
.
warn
(
"Can't create directory for local driver file '"
+
localDir
.
getAbsolutePath
()
+
"'"
);
}
}
String
externalURL
=
getExternalURL
();
if
(
externalURL
==
null
)
{
throw
new
IOException
(
"Unresolved file reference: "
+
getPath
());
...
...
@@ -173,16 +187,6 @@ public abstract class DriverLibraryAbstract implements DBPDriverLibrary
}
monitor
.
beginTask
(
taskName
+
" - "
+
externalURL
,
contentLength
);
boolean
success
=
false
;
final
File
localFile
=
getLocalFile
();
if
(
localFile
==
null
)
{
throw
new
IOException
(
"No target file for '"
+
getPath
()
+
"'"
);
}
final
File
localDir
=
localFile
.
getParentFile
();
if
(!
localDir
.
exists
())
{
if
(!
localDir
.
mkdirs
())
{
log
.
warn
(
"Can't create directory for local driver file '"
+
localDir
.
getAbsolutePath
()
+
"'"
);
}
}
try
(
final
OutputStream
outputStream
=
new
FileOutputStream
(
localFile
))
{
try
(
final
InputStream
inputStream
=
connection
.
getInputStream
())
{
final
NumberFormat
numberFormat
=
NumberFormat
.
getNumberInstance
();
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenArtifact.java
浏览文件 @
c35ad67d
...
...
@@ -68,28 +68,18 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
@Override
public
boolean
isResolved
()
{
MavenArtifact
artifact
=
getMavenArtifact
();
return
artifact
!=
null
&&
artifact
.
getActiveLocalVersion
()
!=
null
;
return
getMavenVersion
()
!=
null
;
}
@Nullable
private
MavenArtifact
getMavenArtifact
()
{
return
MavenRegistry
.
getInstance
().
findArtifact
(
reference
);
}
@Nullable
protected
MavenLocalVersion
getMavenLocalVersion
()
{
MavenArtifact
artifact
=
getMavenArtifact
();
if
(
artifact
!=
null
)
{
return
artifact
.
getActiveLocalVersion
();
}
return
null
;
protected
MavenArtifactVersion
getMavenVersion
()
{
return
MavenRegistry
.
getInstance
().
findArtifact
(
VoidProgressMonitor
.
INSTANCE
,
reference
);
}
@Nullable
@Override
public
String
getExternalURL
()
{
Maven
LocalVersion
localVersion
=
getMavenLocal
Version
();
Maven
ArtifactVersion
localVersion
=
getMaven
Version
();
if
(
localVersion
!=
null
)
{
return
localVersion
.
getExternalURL
(
MavenArtifact
.
FILE_JAR
);
}
...
...
@@ -113,20 +103,9 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
private
File
detectLocalFile
()
{
MavenArtifact
artifact
=
getMavenArtifact
();
if
(
artifact
!=
null
)
{
MavenLocalVersion
localVersion
=
artifact
.
getActiveLocalVersion
();
if
(
localVersion
==
null
&&
artifact
.
getRepository
().
isLocal
())
{
// In case of local artifact make version resolve
try
{
localVersion
=
artifact
.
resolveVersion
(
VoidProgressMonitor
.
INSTANCE
,
reference
.
getVersion
(),
true
);
}
catch
(
IOException
e
)
{
log
.
warn
(
"Error resolving local artifact ["
+
artifact
+
"] version"
,
e
);
}
}
if
(
localVersion
!=
null
)
{
return
localVersion
.
getCacheFile
();
}
MavenArtifactVersion
localVersion
=
getMavenVersion
();
if
(
localVersion
!=
null
)
{
return
localVersion
.
getCacheFile
();
}
return
null
;
}
...
...
@@ -135,42 +114,25 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
@Override
public
Collection
<?
extends
DBPDriverLibrary
>
getDependencies
(
@NotNull
DBRProgressMonitor
monitor
)
throws
IOException
{
List
<
DriverLibraryMavenDependency
>
dependencies
=
new
ArrayList
<>();
Maven
Local
Version
localVersion
=
resolveLocalVersion
(
monitor
,
false
);
Maven
Artifact
Version
localVersion
=
resolveLocalVersion
(
monitor
,
false
);
if
(
localVersion
!=
null
)
{
MavenArtifactVersion
metaData
=
localVersion
.
getMetaData
(
monitor
);
List
<
MavenArtifactDependency
>
artifactDeps
=
metaData
.
getDependencies
(
monitor
);
List
<
MavenArtifactDependency
>
artifactDeps
=
localVersion
.
getDependencies
(
monitor
);
if
(!
CommonUtils
.
isEmpty
(
artifactDeps
))
{
List
<
MavenArtifactDependency
>
brokenDependencies
=
null
;
for
(
MavenArtifactDependency
dependency
:
artifactDeps
)
{
if
(
isDependencyExcluded
(
monitor
,
dependency
))
{
continue
;
}
MavenArtifact
depArtifact
=
MavenRegistry
.
getInstance
().
findArtifact
(
dependency
);
MavenArtifact
Version
depArtifact
=
MavenRegistry
.
getInstance
().
findArtifact
(
monitor
,
dependency
);
if
(
depArtifact
!=
null
)
{
MavenLocalVersion
depLocalVersion
=
depArtifact
.
resolveVersion
(
monitor
,
dependency
.
getVersion
(),
false
);
if
(
depLocalVersion
!=
null
)
{
dependencies
.
add
(
new
DriverLibraryMavenDependency
(
this
,
depLocalVersion
,
dependency
));
}
dependencies
.
add
(
new
DriverLibraryMavenDependency
(
this
,
depArtifact
,
dependency
));
}
else
{
// Artifact not found - broken dependency
if
(
brokenDependencies
==
null
)
{
brokenDependencies
=
new
ArrayList
<>();
}
brokenDependencies
.
add
(
dependency
);
}
}
if
(
brokenDependencies
!=
null
)
{
for
(
MavenArtifactDependency
dependency
:
brokenDependencies
)
{
log
.
warn
(
"Artifact ["
+
dependency
+
"] not found. Remove from ["
+
reference
+
"] dependency list."
);
metaData
.
removeDependency
(
dependency
);
dependency
.
setBroken
(
true
);
}
localVersion
.
getArtifact
().
getRepository
().
flushCache
();
}
}
}
...
...
@@ -184,11 +146,7 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
@NotNull
public
String
getDisplayName
()
{
MavenArtifact
artifact
=
getMavenArtifact
();
if
(
artifact
!=
null
)
{
return
artifact
.
getGroupId
()
+
":"
+
artifact
.
getArtifactId
();
}
return
path
;
return
getId
();
}
@Override
...
...
@@ -198,7 +156,7 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
@Override
public
String
getVersion
()
{
Maven
LocalVersion
version
=
getMavenLocal
Version
();
Maven
ArtifactVersion
version
=
getMaven
Version
();
if
(
version
!=
null
)
{
return
version
.
getVersion
();
}
...
...
@@ -215,7 +173,7 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
public
void
downloadLibraryFile
(
@NotNull
DBRProgressMonitor
monitor
,
boolean
forceUpdate
,
String
taskName
)
throws
IOException
,
InterruptedException
{
//monitor.beginTask(taskName + " - update version information", 1);
try
{
Maven
Local
Version
localVersion
=
resolveLocalVersion
(
monitor
,
forceUpdate
);
Maven
Artifact
Version
localVersion
=
resolveLocalVersion
(
monitor
,
forceUpdate
);
if
(
localVersion
.
getArtifact
().
getRepository
().
isLocal
())
{
// No need to download local artifacts
return
;
...
...
@@ -226,22 +184,15 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
super
.
downloadLibraryFile
(
monitor
,
forceUpdate
,
taskName
);
}
protected
Maven
Local
Version
resolveLocalVersion
(
DBRProgressMonitor
monitor
,
boolean
forceUpdate
)
throws
IOException
{
protected
Maven
Artifact
Version
resolveLocalVersion
(
DBRProgressMonitor
monitor
,
boolean
forceUpdate
)
throws
IOException
{
if
(
forceUpdate
)
{
MavenRegistry
.
getInstance
().
resetArtifactInfo
(
reference
);
}
MavenArtifact
artifact
=
MavenRegistry
.
getInstance
().
findArtifact
(
reference
);
if
(
artifact
==
null
)
{
MavenArtifact
Version
version
=
MavenRegistry
.
getInstance
().
findArtifact
(
monitor
,
reference
);
if
(
version
==
null
)
{
throw
new
IOException
(
"Maven artifact '"
+
path
+
"' not found"
);
}
if
(!
forceUpdate
)
{
MavenLocalVersion
localVersion
=
artifact
.
getActiveLocalVersion
();
if
(
localVersion
!=
null
)
{
// Already cached
return
localVersion
;
}
}
return
artifact
.
resolveVersion
(
monitor
,
reference
.
getVersion
(),
true
);
return
version
;
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenDependency.java
浏览文件 @
c35ad67d
...
...
@@ -17,15 +17,11 @@
*/
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.Maven
Local
Version
;
import
org.jkiss.dbeaver.registry.maven.Maven
Artifact
Version
;
import
java.io.File
;
import
java.io.IOException
;
...
...
@@ -37,10 +33,10 @@ import java.util.List;
public
class
DriverLibraryMavenDependency
extends
DriverLibraryMavenArtifact
{
private
DriverLibraryMavenArtifact
parent
;
private
Maven
Local
Version
localVersion
;
private
Maven
Artifact
Version
localVersion
;
private
MavenArtifactDependency
source
;
public
DriverLibraryMavenDependency
(
DriverLibraryMavenArtifact
parent
,
Maven
Local
Version
localVersion
,
MavenArtifactDependency
source
)
{
public
DriverLibraryMavenDependency
(
DriverLibraryMavenArtifact
parent
,
Maven
Artifact
Version
localVersion
,
MavenArtifactDependency
source
)
{
super
(
parent
.
getDriver
(),
FileType
.
jar
,
PATH_PREFIX
+
localVersion
.
toString
());
this
.
parent
=
parent
;
this
.
localVersion
=
localVersion
;
...
...
@@ -54,7 +50,7 @@ public class DriverLibraryMavenDependency extends DriverLibraryMavenArtifact
@Nullable
@Override
protected
Maven
LocalVersion
getMavenLocal
Version
()
{
protected
Maven
ArtifactVersion
getMaven
Version
()
{
return
localVersion
;
}
...
...
@@ -65,7 +61,7 @@ public class DriverLibraryMavenDependency extends DriverLibraryMavenArtifact
return
localVersion
.
getCacheFile
();
}
protected
Maven
Local
Version
resolveLocalVersion
(
DBRProgressMonitor
monitor
,
boolean
forceUpdate
)
throws
IOException
{
protected
Maven
Artifact
Version
resolveLocalVersion
(
DBRProgressMonitor
monitor
,
boolean
forceUpdate
)
throws
IOException
{
return
localVersion
;
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
浏览文件 @
c35ad67d
...
...
@@ -54,14 +54,14 @@ public class MavenArtifact
private
final
MavenRepository
repository
;
private
final
String
groupId
;
private
final
String
artifactId
;
private
List
<
String
>
versions
=
new
ArrayList
<>();
private
String
latestVersion
;
private
String
releaseVersion
;
private
Date
lastUpdate
;
private
transient
boolean
metadataLoaded
=
false
;
private
List
<
Maven
Local
Version
>
localVersions
=
new
ArrayList
<>();
private
List
<
Maven
Artifact
Version
>
localVersions
=
new
ArrayList
<>();
private
String
activeVersion
;
public
MavenArtifact
(
MavenRepository
repository
,
String
groupId
,
String
artifactId
)
...
...
@@ -166,32 +166,14 @@ public class MavenArtifact
return
artifactId
;
}
/*
public List<ArtifactVersion> getVersions() {
return versions;
}
public String getLatestVersion() {
return latestVersion;
}
public String getReleaseVersion() {
return releaseVersion;
}
*/
public
Date
getLastUpdate
()
{
return
lastUpdate
;
}
public
List
<
Maven
Local
Version
>
getLocalVersions
()
{
public
List
<
Maven
Artifact
Version
>
getLocalVersions
()
{
return
localVersions
;
}
public
String
getActiveVersion
()
{
return
activeVersion
;
}
public
void
setActiveVersion
(
String
activeVersion
)
{
this
.
activeVersion
=
activeVersion
;
}
...
...
@@ -216,16 +198,16 @@ public class MavenArtifact
}
@Nullable
public
Maven
LocalVersion
getActiveLocal
Version
()
{
return
get
Local
Version
(
activeVersion
);
public
Maven
ArtifactVersion
getActive
Version
()
{
return
getVersion
(
activeVersion
);
}
@Nullable
public
Maven
LocalVersion
getLocal
Version
(
String
versionStr
)
{
public
Maven
ArtifactVersion
get
Version
(
String
versionStr
)
{
if
(
CommonUtils
.
isEmpty
(
activeVersion
))
{
return
null
;
}
for
(
Maven
Local
Version
version
:
localVersions
)
{
for
(
Maven
Artifact
Version
version
:
localVersions
)
{
if
(
version
.
getVersion
().
equals
(
versionStr
))
{
return
version
;
}
...
...
@@ -233,33 +215,47 @@ public class MavenArtifact
return
null
;
}
private
MavenLocalVersion
makeLocalVersion
(
DBRProgressMonitor
monitor
,
String
versionStr
,
boolean
setActive
)
throws
IllegalArgumentException
{
MavenLocalVersion
version
=
getLocalVersion
(
versionStr
);
public
void
addVersion
(
MavenArtifactVersion
version
)
{
localVersions
.
add
(
version
);
}
private
MavenArtifactVersion
makeLocalVersion
(
DBRProgressMonitor
monitor
,
String
versionStr
,
boolean
setActive
)
throws
IllegalArgumentException
,
IOException
{
MavenArtifactVersion
version
=
getVersion
(
versionStr
);
if
(
version
==
null
)
{
version
=
new
MavenLocalVersion
(
this
,
versionStr
,
new
Date
());
version
.
getMetaData
(
monitor
);
version
=
new
MavenArtifactVersion
(
monitor
,
this
,
versionStr
);
localVersions
.
add
(
version
);
repository
.
flushCache
();
}
if
(
setActive
)
{
activeVersion
=
versionStr
;
repository
.
flushCache
();
}
return
version
;
}
void
addLocalVersion
(
MavenLocalVersion
version
)
{
localVersions
.
add
(
version
);
}
private
void
removeLocalVersion
(
MavenLocalVersion
version
)
{
localVersions
.
remove
(
version
);
}
public
MavenLocalVersion
resolveVersion
(
DBRProgressMonitor
monitor
,
String
versionRef
,
boolean
lookupVersion
)
throws
IOException
{
// if (versionRef.startsWith("[") || versionRef.startsWith("(") || versionRef.endsWith("]") || versionRef.endsWith(")")) {
// lookupVersion = true;
// }
public
MavenArtifactVersion
resolveVersion
(
DBRProgressMonitor
monitor
,
String
versionRef
)
throws
IOException
{
if
(
CommonUtils
.
isEmpty
(
versionRef
))
{
throw
new
IOException
(
"Empty artifact "
+
this
+
" version"
);
}
char
firstChar
=
versionRef
.
charAt
(
0
),
lastChar
=
versionRef
.
charAt
(
versionRef
.
length
()
-
1
);
boolean
predefinedVersion
=
versionRef
.
equals
(
MavenArtifactReference
.
VERSION_PATTERN_RELEASE
)
||
versionRef
.
equals
(
MavenArtifactReference
.
VERSION_PATTERN_LATEST
)
||
versionRef
.
equals
(
MavenArtifactReference
.
VERSION_PATTERN_SNAPSHOT
);
boolean
lookupVersion
=
firstChar
==
'['
||
firstChar
==
'('
||
firstChar
==
'{'
||
lastChar
==
']'
||
lastChar
==
')'
||
lastChar
==
'}'
||
versionRef
.
contains
(
","
)
||
predefinedVersion
;
if
(
lookupVersion
&&
!
CommonUtils
.
isEmpty
(
activeVersion
))
{
// We already have some active version
// Let's use it if it matches pattern
lookupVersion
=
!(
predefinedVersion
||
versionMatches
(
activeVersion
,
versionRef
));
if
(!
lookupVersion
)
{
versionRef
=
activeVersion
;
}
}
if
(
lookupVersion
&&
!
metadataLoaded
)
{
loadMetadata
(
monitor
);
}
...
...
@@ -313,17 +309,28 @@ public class MavenArtifact
}
}
MavenLocalVersion
localVersion
=
getLocalVersion
(
versionInfo
);
if
(
localVersion
==
null
&&
lookupVersion
)
{
localVersion
=
getActiveLocalVersion
();
}
MavenArtifactVersion
localVersion
=
getVersion
(
versionInfo
);
if
(
localVersion
==
null
)
{
localVersion
=
makeLocalVersion
(
monitor
,
versionInfo
,
true
);
localVersion
=
makeLocalVersion
(
monitor
,
versionInfo
,
lookupVersion
);
}
return
localVersion
;
}
private
boolean
versionMatches
(
String
version
,
String
versionSpec
)
{
try
{
if
(
versionSpec
.
startsWith
(
"{"
)
&&
versionSpec
.
endsWith
(
"}"
))
{
Pattern
versionPattern
=
Pattern
.
compile
(
versionSpec
.
substring
(
1
,
versionSpec
.
length
()
-
1
));
return
versionPattern
.
matcher
(
version
).
matches
();
}
else
{
return
VersionRange
.
createFromVersionSpec
(
versionSpec
).
containsVersion
(
new
DefaultArtifactVersion
(
version
));
}
}
catch
(
Exception
e
)
{
log
.
debug
(
e
);
return
false
;
}
}
@Nullable
private
String
getVersionFromSpec
(
String
versionRef
)
throws
IOException
{
String
versionInfo
;
...
...
@@ -336,7 +343,7 @@ public class MavenArtifact
}
else
{
versionInfo
=
null
;
}
}
catch
(
InvalidVersionSpecification
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
IOException
(
"Bad version pattern: "
+
versionRef
,
e
);
}
return
versionInfo
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactDependency.java
浏览文件 @
c35ad67d
...
...
@@ -39,6 +39,7 @@ public class MavenArtifactDependency extends MavenArtifactReference {
private
Scope
scope
;
private
boolean
optional
;
private
List
<
MavenArtifactReference
>
exclusions
;
private
boolean
broken
;
public
MavenArtifactDependency
(
@NotNull
String
groupId
,
@NotNull
String
artifactId
,
@NotNull
String
version
,
Scope
scope
,
boolean
optional
)
{
super
(
groupId
,
artifactId
,
version
);
...
...
@@ -65,4 +66,11 @@ public class MavenArtifactDependency extends MavenArtifactReference {
exclusions
.
add
(
ref
);
}
public
boolean
isBroken
()
{
return
broken
;
}
public
void
setBroken
(
boolean
broken
)
{
this
.
broken
=
broken
;
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactReference.java
浏览文件 @
c35ad67d
...
...
@@ -26,6 +26,7 @@ public class MavenArtifactReference
{
public
static
final
String
VERSION_PATTERN_RELEASE
=
"RELEASE"
;
public
static
final
String
VERSION_PATTERN_LATEST
=
"LATEST"
;
public
static
final
String
VERSION_PATTERN_SNAPSHOT
=
"SNAPSHOT"
;
private
static
final
String
DEFAULT_MAVEN_VERSION
=
VERSION_PATTERN_RELEASE
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactVersion.java
浏览文件 @
c35ad67d
...
...
@@ -22,13 +22,16 @@ import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import
org.jkiss.dbeaver.runtime.RuntimeUtils
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
import
org.jkiss.utils.CommonUtils
;
import
org.jkiss.utils.IOUtils
;
import
org.jkiss.utils.xml.XMLException
;
import
org.jkiss.utils.xml.XMLUtils
;
import
org.w3c.dom.Document
;
import
org.w3c.dom.Element
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.*
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.net.URL
;
import
java.util.*
;
/**
...
...
@@ -41,49 +44,44 @@ public class MavenArtifactVersion {
public
static
final
String
PROP_PROJECT_GROUP_ID
=
"project.groupId"
;
public
static
final
String
PROP_PROJECT_ARTIFACT_ID
=
"project.artifactId"
;
private
Maven
LocalVersion
localVersion
;
private
Maven
Artifact
artifact
;
private
String
name
;
private
String
version
;
private
String
description
;
private
String
url
;
private
Maven
Local
Version
parent
;
private
Maven
Artifact
Version
parent
;
private
Map
<
String
,
String
>
properties
=
new
LinkedHashMap
<>();
private
List
<
MavenArtifactLicense
>
licenses
=
new
ArrayList
<>();
private
List
<
MavenArtifactDependency
>
dependencies
;
private
List
<
MavenArtifactDependency
>
dependencyManagement
;
private
final
GeneralUtils
.
IVariableResolver
variable
Resolver
=
new
GeneralUtils
.
IVariableResolver
()
{
private
GeneralUtils
.
IVariableResolver
property
Resolver
=
new
GeneralUtils
.
IVariableResolver
()
{
@Override
public
String
get
(
String
name
)
{
String
value
=
properties
.
get
(
name
);
if
(
value
==
null
)
{
if
(
name
.
equals
(
PROP_PROJECT_VERSION
))
{
value
=
version
;
for
(
MavenArtifactVersion
v
=
MavenArtifactVersion
.
this
;
v
!=
null
;
v
=
v
.
parent
)
{
String
value
=
v
.
properties
.
get
(
name
);
if
(
value
!=
null
)
{
return
value
;
}
else
if
(
name
.
equals
(
PROP_PROJECT_VERSION
))
{
return
v
.
version
;
}
else
if
(
name
.
equals
(
PROP_PROJECT_GROUP_ID
))
{
value
=
localVersion
.
getArtifact
()
.
getGroupId
();
return
v
.
artifact
.
getGroupId
();
}
else
if
(
name
.
equals
(
PROP_PROJECT_ARTIFACT_ID
))
{
value
=
localVersion
.
getArtifact
().
getArtifactId
();
}
else
if
(
parent
!=
null
)
{
return
parent
.
getMetaData
().
variableResolver
.
get
(
name
);
return
v
.
artifact
.
getArtifactId
();
}
}
return
value
;
return
null
;
}
};
MavenArtifactVersion
(
DBRProgressMonitor
monitor
,
MavenLocalVersion
localVersion
)
throws
IOException
{
this
.
localVersion
=
localVersion
;
loadPOM
(
monitor
);
}
MavenArtifactVersion
(
MavenLocalVersion
localVersion
,
String
name
,
String
version
)
{
this
.
localVersion
=
localVersion
;
this
.
name
=
name
;
MavenArtifactVersion
(
DBRProgressMonitor
monitor
,
MavenArtifact
artifact
,
String
version
)
throws
IOException
{
this
.
artifact
=
artifact
;
this
.
version
=
version
;
loadPOM
(
monitor
);
}
public
Maven
LocalVersion
getLocalVersion
()
{
return
localVersion
;
public
Maven
Artifact
getArtifact
()
{
return
artifact
;
}
public
String
getName
()
{
...
...
@@ -102,21 +100,10 @@ public class MavenArtifactVersion {
return
url
;
}
public
Maven
Local
Version
getParent
()
{
public
Maven
Artifact
Version
getParent
()
{
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
()
{
return
properties
;
}
...
...
@@ -127,7 +114,7 @@ public class MavenArtifactVersion {
public
List
<
MavenArtifactDependency
>
getDependencies
(
DBRProgressMonitor
monitor
)
{
if
(
parent
!=
null
)
{
List
<
MavenArtifactDependency
>
parentDependencies
=
parent
.
get
MetaData
(
monitor
).
get
Dependencies
(
monitor
);
List
<
MavenArtifactDependency
>
parentDependencies
=
parent
.
getDependencies
(
monitor
);
if
(!
CommonUtils
.
isEmpty
(
parentDependencies
))
{
if
(
CommonUtils
.
isEmpty
(
dependencies
))
{
return
parentDependencies
;
...
...
@@ -141,27 +128,64 @@ public class MavenArtifactVersion {
return
this
.
dependencies
;
}
public
void
removeDependency
(
MavenArtifactDependency
dependency
)
{
if
(
this
.
dependencies
!=
null
)
{
this
.
dependencies
.
remove
(
dependency
);
List
<
MavenArtifactDependency
>
getDependencies
()
{
return
dependencies
;
}
public
File
getCacheFile
()
{
if
(
artifact
.
getRepository
().
isLocal
())
{
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
()
+
"/"
+
artifact
.
getVersionFileName
(
version
,
MavenArtifact
.
FILE_JAR
));
}
List
<
MavenArtifactDependency
>
getDependencies
()
{
return
dependencies
;
public
String
getExternalURL
(
String
fileType
)
{
return
artifact
.
getFileURL
(
version
,
fileType
);
}
public
String
getPath
()
{
return
artifact
.
toString
()
+
":"
+
version
;
}
@Override
public
String
toString
()
{
return
localVersion
.
toString
();
return
getPath
();
}
private
File
getLocalPOM
()
{
if
(
artifact
.
getRepository
().
isLocal
())
{
try
{
return
new
File
(
new
URI
(
getRemotePOMLocation
()));
}
catch
(
URISyntaxException
e
)
{
log
.
warn
(
e
);
}
}
return
new
File
(
artifact
.
getRepository
().
getLocalCacheDir
(),
artifact
.
getGroupId
()
+
"/"
+
artifact
.
getVersionFileName
(
version
,
MavenArtifact
.
FILE_POM
));
}
private
String
getRemotePOMLocation
()
{
return
artifact
.
getFileURL
(
version
,
MavenArtifact
.
FILE_POM
);
}
private
void
loadPOM
(
DBRProgressMonitor
monitor
)
throws
IOException
{
String
pomURL
=
localVersion
.
getArtifact
().
getFileURL
(
localVersion
.
getVersion
(),
MavenArtifact
.
FILE_POM
);
monitor
.
subTask
(
"Load POM "
+
localVersion
);
File
localPOM
=
getLocalPOM
();
if
(!
localPOM
.
exists
())
{
cachePOM
(
localPOM
);
}
monitor
.
subTask
(
"Load POM "
+
this
);
Document
pomDocument
;
try
(
InputStream
mdStream
=
RuntimeUtils
.
openConnectionStream
(
pomURL
))
{
try
(
InputStream
mdStream
=
new
FileInputStream
(
localPOM
))
{
pomDocument
=
XMLUtils
.
parseDocument
(
mdStream
);
}
catch
(
XMLException
e
)
{
throw
new
IOException
(
"Error parsing POM"
,
e
);
...
...
@@ -189,11 +213,9 @@ public class MavenArtifactVersion {
if
(
this
.
version
==
null
)
{
this
.
version
=
parentReference
.
getVersion
();
}
MavenArtifact
parentArtifact
=
MavenRegistry
.
getInstance
().
findArtifact
(
parentReference
);
if
(
parent
Artifact
==
null
)
{
parent
=
MavenRegistry
.
getInstance
().
findArtifact
(
monitor
,
parentReference
);
if
(
parent
==
null
)
{
log
.
error
(
"Artifact ["
+
this
+
"] parent ["
+
parentReference
+
"] not found"
);
}
else
{
parent
=
parentArtifact
.
resolveVersion
(
monitor
,
parentReference
.
getVersion
(),
false
);
}
}
}
...
...
@@ -231,6 +253,23 @@ public class MavenArtifactVersion {
monitor
.
worked
(
1
);
}
private
void
cachePOM
(
File
localPOM
)
throws
IOException
{
if
(
artifact
.
getRepository
().
isLocal
())
{
return
;
}
String
pomURL
=
getRemotePOMLocation
();
try
(
InputStream
is
=
RuntimeUtils
.
openConnectionStream
(
pomURL
))
{
File
folder
=
localPOM
.
getParentFile
();
if
(!
folder
.
exists
()
&&
!
folder
.
mkdirs
())
{
throw
new
IOException
(
"Can't create cache folder '"
+
folder
.
getAbsolutePath
()
+
"'"
);
}
try
(
OutputStream
os
=
new
FileOutputStream
(
localPOM
))
{
IOUtils
.
fastCopy
(
is
,
os
);
}
}
}
private
List
<
MavenArtifactDependency
>
parseDependencies
(
DBRProgressMonitor
monitor
,
Element
element
,
boolean
depManagement
)
{
List
<
MavenArtifactDependency
>
result
=
new
ArrayList
<>();
Element
dependenciesElement
=
XMLUtils
.
getChildElement
(
element
,
"dependencies"
);
...
...
@@ -305,14 +344,14 @@ public class MavenArtifactVersion {
}
}
}
return
parent
==
null
?
null
:
parent
.
getMetaData
(
monitor
).
findDependencyVersion
(
monitor
,
groupId
,
artifactId
);
return
parent
==
null
?
null
:
parent
.
findDependencyVersion
(
monitor
,
groupId
,
artifactId
);
}
private
String
evaluateString
(
String
value
)
{
if
(
value
==
null
)
{
return
null
;
}
return
GeneralUtils
.
replaceVariables
(
value
,
variable
Resolver
);
return
GeneralUtils
.
replaceVariables
(
value
,
property
Resolver
);
}
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenLocalVersion.java
已删除
100644 → 0
浏览文件 @
852bd4d1
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package
org.jkiss.dbeaver.registry.maven
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.util.Date
;
/**
* Maven artifact version info.
* It is a resolved version information. This version exists in maven repository and can be obtained.
* Also it is cached locally.
*/
public
class
MavenLocalVersion
{
static
final
Log
log
=
Log
.
getLog
(
MavenLocalVersion
.
class
);
private
MavenArtifact
artifact
;
private
String
version
;
private
String
fileName
;
private
Date
updateTime
;
private
MavenArtifactVersion
metaData
;
public
MavenLocalVersion
(
MavenArtifact
artifact
,
String
version
,
Date
updateTime
)
{
this
.
artifact
=
artifact
;
this
.
version
=
version
;
this
.
fileName
=
artifact
.
getVersionFileName
(
version
,
MavenArtifact
.
FILE_JAR
);
this
.
updateTime
=
updateTime
;
}
public
MavenArtifact
getArtifact
()
{
return
artifact
;
}
public
String
getVersion
()
{
return
version
;
}
public
String
getFileName
()
{
return
fileName
;
}
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
File
getCacheFile
()
{
if
(
artifact
.
getRepository
().
isLocal
())
{
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
);
}
public
String
getExternalURL
(
String
fileType
)
{
return
artifact
.
getFileURL
(
version
,
fileType
);
}
@NotNull
public
MavenArtifactVersion
getMetaData
(
DBRProgressMonitor
monitor
)
{
if
(
metaData
==
null
)
{
try
{
metaData
=
new
MavenArtifactVersion
(
monitor
,
this
);
}
catch
(
IOException
e
)
{
log
.
warn
(
"Error fetching POM file"
,
e
);
metaData
=
new
MavenArtifactVersion
(
this
,
artifact
.
getArtifactId
(),
version
);
}
}
return
metaData
;
}
public
String
getPath
()
{
return
artifact
.
toString
()
+
":"
+
version
;
}
MavenArtifactVersion
getMetaData
()
{
return
metaData
;
}
void
setMetaData
(
MavenArtifactVersion
metaData
)
{
this
.
metaData
=
metaData
;
}
@Override
public
String
toString
()
{
return
getPath
();
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
浏览文件 @
c35ad67d
...
...
@@ -49,10 +49,10 @@ public class MavenRegistry
return
instance
;
}
private
final
List
<
MavenRepository
>
repositories
=
new
ArrayList
<
MavenRepository
>();
private
final
List
<
MavenRepository
>
repositories
=
new
ArrayList
<>();
private
MavenRepository
localRepository
;
// 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
<>();
private
MavenRegistry
()
{
...
...
@@ -133,20 +133,12 @@ public class MavenRegistry
}
@Nullable
public
MavenArtifact
findArtifact
(
@NotNull
MavenArtifactReference
ref
)
{
return
findArtifact
(
ref
,
true
);
}
@Nullable
public
MavenArtifact
findArtifact
(
@NotNull
MavenArtifactReference
ref
,
boolean
resolve
)
{
public
MavenArtifactVersion
findArtifact
(
@NotNull
DBRProgressMonitor
monitor
,
@NotNull
MavenArtifactReference
ref
)
{
String
fullId
=
ref
.
getId
();
if
(
notFoundArtifacts
.
contains
(
fullId
))
{
return
null
;
}
MavenArtifact
artifact
=
findInRepositories
(
ref
,
false
);
if
(
artifact
==
null
&&
resolve
)
{
artifact
=
findInRepositories
(
ref
,
true
);
}
MavenArtifactVersion
artifact
=
findInRepositories
(
monitor
,
ref
);
if
(
artifact
!=
null
)
{
return
artifact
;
}
...
...
@@ -166,15 +158,15 @@ public class MavenRegistry
}
@Nullable
private
MavenArtifact
findInRepositories
(
@NotNull
MavenArtifactReference
ref
,
boolean
resolve
)
{
private
MavenArtifact
Version
findInRepositories
(
@NotNull
DBRProgressMonitor
monitor
,
@NotNull
MavenArtifactReference
ref
)
{
// Try all available repositories (without resolve)
for
(
MavenRepository
repository
:
repositories
)
{
MavenArtifact
artifact
=
repository
.
findArtifact
(
ref
,
resolve
);
MavenArtifact
Version
artifact
=
repository
.
findArtifact
(
monitor
,
ref
);
if
(
artifact
!=
null
)
{
return
artifact
;
}
}
MavenArtifact
artifact
=
localRepository
.
findArtifact
(
ref
,
resolve
);
MavenArtifact
Version
artifact
=
localRepository
.
findArtifact
(
monitor
,
ref
);
if
(
artifact
!=
null
)
{
return
artifact
;
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
浏览文件 @
c35ad67d
...
...
@@ -22,6 +22,7 @@ import org.jkiss.code.NotNull;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.core.DBeaverActivator
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.registry.RegistryConstants
;
import
org.jkiss.utils.CommonUtils
;
...
...
@@ -33,10 +34,8 @@ import org.jkiss.utils.xml.XMLException;
import
org.xml.sax.Attributes
;
import
java.io.*
;
import
java.text.DateFormat
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
/**
* Maven repository manager.
...
...
@@ -52,8 +51,6 @@ public class MavenRepository
public
static
final
String
TAG_CACHE
=
"cache"
;
public
static
final
String
TAG_ARTIFACT
=
"artifact"
;
public
static
final
String
TAG_VERSION
=
"version"
;
public
static
final
String
TAG_DEPENDENCY
=
"dependency"
;
public
static
final
String
TAG_EXCLUDE
=
"exclude"
;
public
static
final
String
ATTR_NAME
=
"name"
;
public
static
final
String
ATTR_URL
=
"url"
;
...
...
@@ -61,13 +58,6 @@ public class MavenRepository
public
static
final
String
ATTR_ARTIFACT_ID
=
"artifactId"
;
public
static
final
String
ATTR_ACTIVE_VERSION
=
"activeVersion"
;
public
static
final
String
ATTR_VERSION
=
"version"
;
public
static
final
String
ATTR_PATH
=
"path"
;
public
static
final
String
ATTR_SCOPE
=
"scope"
;
public
static
final
String
ATTR_OPTIONAL
=
"optional"
;
public
static
final
String
ATTR_PARENT
=
"parent"
;
public
static
final
String
ATTR_UPDATE_TIME
=
"updateTime"
;
private
static
final
DateFormat
UPDATE_TIME_FORMAT
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
private
String
id
;
private
String
name
;
...
...
@@ -122,20 +112,24 @@ public class MavenRepository
}
@Nullable
public
synchronized
MavenArtifact
findArtifact
(
@NotNull
MavenArtifactReference
ref
,
boolean
resolve
)
{
public
synchronized
MavenArtifactVersion
findArtifact
(
DBRProgressMonitor
monitor
,
@NotNull
MavenArtifactReference
ref
)
{
boolean
newArtifact
=
false
;
MavenArtifact
artifact
=
cachedArtifacts
.
get
(
ref
.
getId
());
if
(
artifact
==
null
&&
resolve
)
{
// Not cached - look in remote repository
if
(
artifact
==
null
)
{
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
;
newArtifact
=
true
;
}
try
{
MavenArtifactVersion
version
=
artifact
.
resolveVersion
(
monitor
,
ref
.
getVersion
());
if
(
newArtifact
)
{
cachedArtifacts
.
put
(
ref
.
getId
(),
artifact
);
flushCache
();
}
cachedArtifacts
.
put
(
ref
.
getId
(),
artifact
);
return
version
;
}
catch
(
IOException
e
)
{
log
.
debug
(
"Artifact version "
+
ref
+
" not found"
,
e
);
return
null
;
}
return
artifact
;
}
synchronized
void
resetArtifactCache
(
@NotNull
MavenArtifactReference
artifactReference
)
{
...
...
@@ -154,54 +148,17 @@ public class MavenRepository
return
homeFolder
;
}
private
static
class
DependencyResolveInfo
{
String
path
;
MavenArtifactDependency
.
Scope
scope
;
boolean
optional
;
List
<
String
>
exclusions
;
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
);
if
(!
cacheFile
.
exists
())
{
return
;
}
final
List
<
VersionResolveInfo
>
lateResolutions
=
new
ArrayList
<>();
try
{
InputStream
mdStream
=
new
FileInputStream
(
cacheFile
);
try
{
SAXReader
reader
=
new
SAXReader
(
mdStream
);
reader
.
parse
(
new
SAXListener
()
{
MavenArtifact
lastArtifact
;
VersionResolveInfo
lastVersionResolveInfo
;
DependencyResolveInfo
lastDependencyInfo
;
@Override
public
void
saxStartElement
(
SAXReader
reader
,
String
namespaceURI
,
String
localName
,
Attributes
atts
)
throws
XMLException
{
if
(
TAG_ARTIFACT
.
equals
(
localName
))
{
...
...
@@ -214,44 +171,16 @@ public class MavenRepository
MavenArtifactReference
.
makeId
(
lastArtifact
.
getGroupId
(),
lastArtifact
.
getArtifactId
()),
lastArtifact
);
}
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
(
lastArtifact
,
versionNumber
,
updateTime
);
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
);
}
}
lastDependencyInfo
=
new
DependencyResolveInfo
(
atts
.
getValue
(
ATTR_PATH
),
scope
,
CommonUtils
.
getBoolean
(
atts
.
getValue
(
ATTR_OPTIONAL
),
false
)
);
lastVersionResolveInfo
.
dependencies
.
add
(
lastDependencyInfo
);
}
else
if
(
TAG_EXCLUDE
.
equals
(
localName
)
&&
lastDependencyInfo
!=
null
)
{
if
(
lastDependencyInfo
.
exclusions
==
null
)
{
lastDependencyInfo
.
exclusions
=
new
ArrayList
<>();
try
{
MavenArtifactVersion
version
=
new
MavenArtifactVersion
(
VoidProgressMonitor
.
INSTANCE
,
lastArtifact
,
versionNumber
);
lastArtifact
.
addVersion
(
version
);
}
catch
(
IOException
e
)
{
log
.
warn
(
"Error loading artifact version"
,
e
);
}
lastDependencyInfo
.
exclusions
.
add
(
atts
.
getValue
(
ATTR_PATH
));
}
}
@Override
...
...
@@ -262,10 +191,6 @@ public class MavenRepository
public
void
saxEndElement
(
SAXReader
reader
,
String
namespaceURI
,
String
localName
)
throws
XMLException
{
if
(
TAG_ARTIFACT
.
equals
(
localName
))
{
lastArtifact
=
null
;
}
else
if
(
TAG_VERSION
.
equals
(
localName
))
{
lastVersionResolveInfo
=
null
;
}
else
if
(
TAG_DEPENDENCY
.
equals
(
localName
))
{
lastDependencyInfo
=
null
;
}
}
});
...
...
@@ -277,47 +202,6 @@ public class MavenRepository
}
catch
(
IOException
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
=
resolveCachedVersion
(
vri
.
parentPath
);
if
(
parentVersion
!=
null
)
{
vri
.
localVersion
.
getMetaData
().
setParent
(
parentVersion
);
}
}
for
(
DependencyResolveInfo
dri
:
vri
.
dependencies
)
{
//MavenLocalVersion cachedVersion = resolveCachedVersion(dri.path);
MavenArtifactReference
reference
=
new
MavenArtifactReference
(
dri
.
path
);
MavenArtifactDependency
dependency
=
new
MavenArtifactDependency
(
reference
.
getGroupId
(),
reference
.
getArtifactId
(),
reference
.
getVersion
(),
dri
.
scope
,
dri
.
optional
);
if
(!
CommonUtils
.
isEmpty
(
dri
.
exclusions
))
{
for
(
String
path
:
dri
.
exclusions
)
{
dependency
.
addExclusion
(
new
MavenArtifactReference
(
path
));
}
}
vri
.
localVersion
.
getMetaData
().
addDependency
(
dependency
);
}
}
}
private
MavenLocalVersion
resolveCachedVersion
(
String
path
)
{
MavenArtifactReference
parentRef
=
new
MavenArtifactReference
(
path
);
MavenArtifact
parentArtifact
=
MavenRegistry
.
getInstance
().
findArtifact
(
parentRef
,
false
);
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
()
{
...
...
@@ -348,45 +232,12 @@ public class MavenRepository
if
(
CommonUtils
.
isEmpty
(
artifact
.
getLocalVersions
()))
{
continue
;
}
try
(
XMLBuilder
.
Element
e1
=
xml
.
startElement
(
TAG_ARTIFACT
))
{
xml
.
addAttribute
(
ATTR_GROUP_ID
,
artifact
.
getGroupId
());
xml
.
addAttribute
(
ATTR_ARTIFACT_ID
,
artifact
.
getArtifactId
());
xml
.
addAttribute
(
ATTR_ACTIVE_VERSION
,
artifact
.
getActiveVersion
());
for
(
MavenLocalVersion
version
:
artifact
.
getLocalVersions
())
{
try
(
XMLBuilder
.
Element
e2
=
xml
.
startElement
(
TAG_VERSION
))
{
xml
.
addAttribute
(
ATTR_VERSION
,
version
.
getVersion
());
xml
.
addAttribute
(
ATTR_UPDATE_TIME
,
UPDATE_TIME_FORMAT
.
format
(
version
.
getUpdateTime
()));
MavenArtifactVersion
metaData
=
version
.
getMetaData
();
if
(
metaData
!=
null
)
{
MavenLocalVersion
parentReference
=
metaData
.
getParent
();
if
(
parentReference
!=
null
)
{
xml
.
addAttribute
(
ATTR_PARENT
,
parentReference
.
getPath
());
}
List
<
MavenArtifactDependency
>
dependencies
=
metaData
.
getDependencies
();
if
(
dependencies
!=
null
)
{
for
(
MavenArtifactDependency
dependency
:
dependencies
)
{
try
(
XMLBuilder
.
Element
e3
=
xml
.
startElement
(
TAG_DEPENDENCY
))
{
xml
.
addAttribute
(
ATTR_PATH
,
dependency
.
getPath
());
if
(
dependency
.
getScope
()
!=
MavenArtifactDependency
.
Scope
.
COMPILE
)
{
xml
.
addAttribute
(
ATTR_SCOPE
,
dependency
.
getScope
().
name
().
toLowerCase
(
Locale
.
ENGLISH
));
}
if
(
dependency
.
isOptional
())
{
xml
.
addAttribute
(
ATTR_OPTIONAL
,
true
);
}
List
<
MavenArtifactReference
>
exclusions
=
dependency
.
getExclusions
();
if
(
exclusions
!=
null
)
{
for
(
MavenArtifactReference
ex
:
exclusions
)
{
try
(
XMLBuilder
.
Element
e4
=
xml
.
startElement
(
TAG_EXCLUDE
))
{
xml
.
addAttribute
(
ATTR_PATH
,
ex
.
getPath
());
}
}
}
}
}
}
}
}
MavenArtifactVersion
activeVersion
=
artifact
.
getActiveVersion
();
if
(
activeVersion
!=
null
)
{
try
(
XMLBuilder
.
Element
e1
=
xml
.
startElement
(
TAG_ARTIFACT
))
{
xml
.
addAttribute
(
ATTR_GROUP_ID
,
artifact
.
getGroupId
());
xml
.
addAttribute
(
ATTR_ARTIFACT_ID
,
artifact
.
getArtifactId
());
xml
.
addAttribute
(
ATTR_ACTIVE_VERSION
,
activeVersion
.
getVersion
());
}
}
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/RuntimeUtils.java
浏览文件 @
c35ad67d
...
...
@@ -280,6 +280,8 @@ public class RuntimeUtils {
public
static
URLConnection
openConnection
(
String
urlString
)
throws
IOException
{
System
.
out
.
println
(
"Open ["
+
urlString
+
"]"
);
log
.
debug
(
"Open ["
+
urlString
+
"]"
);
DBPPreferenceStore
prefs
=
DBeaverCore
.
getGlobalPreferenceStore
();
String
proxyHost
=
prefs
.
getString
(
DBeaverPreferences
.
UI_PROXY_HOST
);
Proxy
proxy
=
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录