Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FIY695
jenkins
提交
d3a3abea
J
jenkins
项目概览
FIY695
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d3a3abea
编写于
11月 13, 2011
作者:
C
Christoph Kutzinski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Still unsuccessful attempt to get parent fingerprinting working with Maven 2.1/2.2
上级
1deb827c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
52 addition
and
11 deletion
+52
-11
maven-plugin/src/main/java/hudson/maven/reporters/MavenFingerprinter.java
.../main/java/hudson/maven/reporters/MavenFingerprinter.java
+52
-11
未找到文件。
maven-plugin/src/main/java/hudson/maven/reporters/MavenFingerprinter.java
浏览文件 @
d3a3abea
...
...
@@ -40,13 +40,16 @@ import hudson.tasks.Fingerprinter.FingerprintAction;
import
org.apache.maven.artifact.Artifact
;
import
org.apache.maven.artifact.repository.ArtifactRepository
;
import
org.apache.maven.project.MavenProject
;
import
org.apache.maven.project.ProjectBuilderConfiguration
;
import
java.io.File
;
import
java.io.IOException
;
import
java.lang.reflect.Field
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.logging.Logger
;
import
java.util.Set
;
import
java.util.List
;
...
...
@@ -136,11 +139,14 @@ public class MavenFingerprinter extends MavenReporter {
// Parent artifact contains no actual file, so we resolve against
// the local repository
ArtifactRepository
localRepository
=
getLocalRepository
(
mavenVersion
,
parent
);
ArtifactRepository
localRepository
=
getLocalRepository
(
mavenVersion
,
parent
,
pom
);
if
(
localRepository
!=
null
)
{
// Don't use ArtifactRepository.find(), for compatibility with M2
parentFile
=
new
File
(
localRepository
.
getBasedir
(),
localRepository
.
pathOf
(
parent
.
getArtifact
()));
Artifact
parentArtifact
=
getArtifact
(
parent
);
// Don't use ArtifactRepository.find(), for compatibility with Maven 2.x
if
(
parentArtifact
!=
null
)
{
parentFile
=
new
File
(
localRepository
.
getBasedir
(),
localRepository
.
pathOf
(
parentArtifact
));
}
}
}
...
...
@@ -155,17 +161,50 @@ public class MavenFingerprinter extends MavenReporter {
}
}
private
ArtifactRepository
getLocalRepository
(
String
mavenVersion
,
MavenProject
parent
)
{
private
Artifact
getArtifact
(
MavenProject
parent
)
{
Artifact
art
=
parent
.
getArtifact
();
if
(
art
==
null
)
{
// happens for Maven 2.x
// TODO: this constructor didn't exist in Maven 2.x:
//art = new DefaultArtifact(parent.getGroupId(), parent.getGroupId(),
// parent.getVersion(), "compile", "pom", null, null);
}
return
art
;
}
private
ArtifactRepository
getLocalRepository
(
String
mavenVersion
,
MavenProject
parent
,
MavenProject
pom
)
{
// Maven 2.0 has no corresponding mechanism
// Maven 2.1,2.2 has a projectBuildConfiguration, however it is null, need to further look into this
if
(
mavenVersion
.
startsWith
(
"2."
))
return
null
;
// Maven 3
return
parent
.
getProjectBuildingRequest
()
if
(
mavenVersion
.
startsWith
(
"2.0"
))
{
return
null
;
}
else
if
(
mavenVersion
.
startsWith
(
"2.1"
)
||
mavenVersion
.
startsWith
(
"2.2"
))
{
//return getArtifactRepositoryMaven21(pom);
// still fails, because of missing artifact later
return
null
;
}
else
if
(
mavenVersion
.
startsWith
(
"3."
)
||
mavenVersion
.
startsWith
(
"4."
)
/* who knows? ;) */
)
{
// Maven 3+
return
parent
.
getProjectBuildingRequest
()
.
getLocalRepository
();
}
else
{
LOGGER
.
warning
(
"Unknown Maven version: "
+
mavenVersion
);
return
null
;
}
}
private
void
record
(
Collection
<
Artifact
>
artifacts
,
Map
<
String
,
String
>
record
)
throws
IOException
,
InterruptedException
{
@SuppressWarnings
(
"deprecation"
)
private
ArtifactRepository
getArtifactRepositoryMaven21
(
MavenProject
pom
)
{
// Maven 2.1,2.2 has a projectBuildConfiguration in the original project (not parent itself), but no direct accessor
try
{
Field
field
=
MavenProject
.
class
.
getDeclaredField
(
"projectBuilderConfiguration"
);
field
.
setAccessible
(
true
);
ProjectBuilderConfiguration
projBuilderConfig
=
(
ProjectBuilderConfiguration
)
field
.
get
(
pom
);
return
projBuilderConfig
!=
null
?
projBuilderConfig
.
getLocalRepository
()
:
null
;
}
catch
(
Exception
e
)
{
LOGGER
.
warning
(
e
.
toString
());
return
null
;
}
}
private
void
record
(
Collection
<
Artifact
>
artifacts
,
Map
<
String
,
String
>
record
)
throws
IOException
,
InterruptedException
{
for
(
Artifact
a
:
artifacts
)
record
(
a
,
record
);
}
...
...
@@ -228,4 +267,6 @@ public class MavenFingerprinter extends MavenReporter {
}
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
MavenFingerprinter
.
class
.
getName
());
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录