Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
823c745e
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,发现更多精彩内容 >>
提交
823c745e
编写于
10月 13, 2015
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Maven profiles
Former-commit-id:
3aa9d505
上级
52730f25
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
144 addition
and
50 deletion
+144
-50
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/MavenArtifactVersion.java
...rg/jkiss/dbeaver/registry/maven/MavenArtifactVersion.java
+80
-49
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenProfile.java
...re/src/org/jkiss/dbeaver/registry/maven/MavenProfile.java
+63
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
浏览文件 @
823c745e
...
...
@@ -320,7 +320,7 @@ public class MavenArtifact
return
localVersion
;
}
p
rivate
boolean
versionMatches
(
String
version
,
String
versionSpec
)
{
p
ublic
static
boolean
versionMatches
(
String
version
,
String
versionSpec
)
{
try
{
if
(
versionSpec
.
startsWith
(
"{"
)
&&
versionSpec
.
endsWith
(
"}"
))
{
Pattern
versionPattern
=
Pattern
.
compile
(
versionSpec
.
substring
(
1
,
versionSpec
.
length
()
-
1
));
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactVersion.java
浏览文件 @
823c745e
...
...
@@ -32,7 +32,9 @@ import java.io.*;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.net.URL
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Locale
;
/**
* Maven artifact version descriptor (POM).
...
...
@@ -50,24 +52,27 @@ public class MavenArtifactVersion {
private
String
description
;
private
String
url
;
private
MavenArtifactVersion
parent
;
private
Map
<
String
,
String
>
properties
=
new
LinkedHashMap
<>();
private
List
<
MavenArtifactLicense
>
licenses
=
new
ArrayList
<>();
private
List
<
MavenArtifactDependency
>
dependencies
;
private
List
<
MavenArtifactDependency
>
dependencyManagement
;
private
final
List
<
MavenArtifactLicense
>
licenses
=
new
ArrayList
<>();
private
final
List
<
MavenProfile
>
profiles
=
new
ArrayList
<>();
private
GeneralUtils
.
IVariableResolver
propertyResolver
=
new
GeneralUtils
.
IVariableResolver
()
{
@Override
public
String
get
(
String
name
)
{
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
))
{
return
v
.
artifact
.
getGroupId
();
}
else
if
(
name
.
equals
(
PROP_PROJECT_ARTIFACT_ID
))
{
return
v
.
artifact
.
getArtifactId
();
for
(
MavenProfile
profile
:
profiles
)
{
if
(!
profile
.
isActive
())
{
continue
;
}
String
value
=
profile
.
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
))
{
return
v
.
artifact
.
getGroupId
();
}
else
if
(
name
.
equals
(
PROP_PROJECT_ARTIFACT_ID
))
{
return
v
.
artifact
.
getArtifactId
();
}
}
}
return
null
;
...
...
@@ -104,35 +109,26 @@ public class MavenArtifactVersion {
return
parent
;
}
public
Map
<
String
,
String
>
getProperties
()
{
return
properties
;
}
public
List
<
MavenArtifactLicense
>
getLicenses
()
{
return
licenses
;
}
public
List
<
MavenArtifactDependency
>
getDependencies
(
DBRProgressMonitor
monitor
)
{
List
<
MavenArtifactDependency
>
dependencies
=
new
ArrayList
<>();
for
(
MavenProfile
profile
:
profiles
)
{
if
(
profile
.
isActive
()
&&
!
CommonUtils
.
isEmpty
(
profile
.
dependencies
))
{
dependencies
.
addAll
(
profile
.
dependencies
);
}
}
if
(
parent
!=
null
)
{
List
<
MavenArtifactDependency
>
parentDependencies
=
parent
.
getDependencies
(
monitor
);
if
(!
CommonUtils
.
isEmpty
(
parentDependencies
))
{
if
(
CommonUtils
.
isEmpty
(
dependencies
))
{
return
parentDependencies
;
}
List
<
MavenArtifactDependency
>
result
=
new
ArrayList
<>(
dependencies
.
size
()
+
parentDependencies
.
size
());
result
.
addAll
(
dependencies
);
result
.
addAll
(
parentDependencies
);
return
result
;
dependencies
.
addAll
(
parentDependencies
);
}
}
return
this
.
dependencies
;
}
List
<
MavenArtifactDependency
>
getDependencies
()
{
return
dependencies
;
}
public
File
getCacheFile
()
{
if
(
artifact
.
getRepository
().
isLocal
())
{
String
externalURL
=
getExternalURL
(
MavenArtifact
.
FILE_JAR
);
...
...
@@ -221,15 +217,6 @@ public class MavenArtifactVersion {
}
}
{
// Properties
Element
propsElement
=
XMLUtils
.
getChildElement
(
root
,
"properties"
);
if
(
propsElement
!=
null
)
{
for
(
Element
prop
:
XMLUtils
.
getChildElementList
(
propsElement
))
{
properties
.
put
(
prop
.
getTagName
(),
XMLUtils
.
getElementBody
(
prop
));
}
}
}
{
// Licenses
Element
licensesElement
=
XMLUtils
.
getChildElement
(
root
,
"licenses"
);
...
...
@@ -242,15 +229,58 @@ public class MavenArtifactVersion {
}
}
}
// Default profile
MavenProfile
defaultProfile
=
new
MavenProfile
(
null
);
parseProfile
(
monitor
,
defaultProfile
,
root
);
profiles
.
add
(
defaultProfile
);
{
// Profiles
Element
licensesElement
=
XMLUtils
.
getChildElement
(
root
,
"profiles"
);
if
(
licensesElement
!=
null
)
{
for
(
Element
profElement
:
XMLUtils
.
getChildElementList
(
licensesElement
,
"profile"
))
{
MavenProfile
profile
=
new
MavenProfile
(
XMLUtils
.
getChildElementBody
(
profElement
,
"id"
));
parseProfile
(
monitor
,
profile
,
profElement
);
}
}
}
monitor
.
worked
(
1
);
}
private
void
parseProfile
(
DBRProgressMonitor
monitor
,
MavenProfile
profile
,
Element
element
)
{
{
// Activation
Element
activationElement
=
XMLUtils
.
getChildElement
(
element
,
"activation"
);
if
(
activationElement
!=
null
)
{
String
activeByDefault
=
XMLUtils
.
getChildElementBody
(
element
,
"activeByDefault"
);
if
(!
CommonUtils
.
isEmpty
(
activeByDefault
))
{
profile
.
active
=
CommonUtils
.
getBoolean
(
activeByDefault
);
}
String
jdk
=
XMLUtils
.
getChildElementBody
(
element
,
"jdk"
);
if
(!
CommonUtils
.
isEmpty
(
jdk
))
{
profile
.
active
=
MavenArtifact
.
versionMatches
(
System
.
getProperty
(
"java.version"
),
jdk
);
}
}
}
{
// Properties
Element
propsElement
=
XMLUtils
.
getChildElement
(
element
,
"properties"
);
if
(
propsElement
!=
null
)
{
for
(
Element
prop
:
XMLUtils
.
getChildElementList
(
propsElement
))
{
profile
.
properties
.
put
(
prop
.
getTagName
(),
XMLUtils
.
getElementBody
(
prop
));
}
}
}
{
// Dependencies
Element
dmElement
=
XMLUtils
.
getChildElement
(
roo
t
,
"dependencyManagement"
);
Element
dmElement
=
XMLUtils
.
getChildElement
(
elemen
t
,
"dependencyManagement"
);
if
(
dmElement
!=
null
)
{
dependencyManagement
=
parseDependencies
(
monitor
,
dmElement
,
true
);
profile
.
dependencyManagement
=
parseDependencies
(
monitor
,
dmElement
,
true
);
}
dependencies
=
parseDependencies
(
monitor
,
roo
t
,
false
);
profile
.
dependencies
=
parseDependencies
(
monitor
,
elemen
t
,
false
);
}
monitor
.
worked
(
1
);
}
private
void
cachePOM
(
File
localPOM
)
throws
IOException
{
...
...
@@ -335,12 +365,13 @@ public class MavenArtifactVersion {
}
private
String
findDependencyVersion
(
DBRProgressMonitor
monitor
,
String
groupId
,
String
artifactId
)
{
if
(
dependencyManagement
!=
null
)
{
for
(
MavenArtifactDependency
dmArtifact
:
dependencyManagement
)
{
if
(
dmArtifact
.
getGroupId
().
equals
(
groupId
)
&&
dmArtifact
.
getArtifactId
().
equals
(
artifactId
))
{
return
dmArtifact
.
getVersion
();
for
(
MavenProfile
profile
:
profiles
)
{
if
(
profile
.
isActive
()
&&
profile
.
dependencyManagement
!=
null
)
{
for
(
MavenArtifactDependency
dmArtifact
:
profile
.
dependencyManagement
)
{
if
(
dmArtifact
.
getGroupId
().
equals
(
groupId
)
&&
dmArtifact
.
getArtifactId
().
equals
(
artifactId
))
{
return
dmArtifact
.
getVersion
();
}
}
}
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenProfile.java
0 → 100644
浏览文件 @
823c745e
/*
* 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.w3c.dom.Element
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* Maven build profile
*/
public
class
MavenProfile
{
private
final
String
id
;
Map
<
String
,
String
>
properties
=
new
LinkedHashMap
<>();
List
<
MavenArtifactDependency
>
dependencies
;
List
<
MavenArtifactDependency
>
dependencyManagement
;
boolean
active
;
public
MavenProfile
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getId
()
{
return
id
;
}
public
Map
<
String
,
String
>
getProperties
()
{
return
properties
;
}
public
List
<
MavenArtifactDependency
>
getDependencies
()
{
return
dependencies
;
}
public
List
<
MavenArtifactDependency
>
getDependencyManagement
()
{
return
dependencyManagement
;
}
public
boolean
isActive
()
{
return
active
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录