Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FIY695
jenkins
提交
38aa4858
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,发现更多精彩内容 >>
提交
38aa4858
编写于
11月 13, 2011
作者:
C
Christoph Kutzinski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make parent POM fingerprinting work with Maven 2.2, too [JENKINS-8383]
上级
f8927f40
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
29 deletion
+35
-29
changelog.html
changelog.html
+1
-1
maven-plugin/src/main/java/hudson/maven/reporters/MavenFingerprinter.java
.../main/java/hudson/maven/reporters/MavenFingerprinter.java
+34
-28
未找到文件。
changelog.html
浏览文件 @
38aa4858
...
...
@@ -83,7 +83,7 @@ Upcoming changes</a>
Description field now has the preview button to test it inline.
(
<a
href=
"https://github.com/jenkinsci/jenkins/pull/243"
>
pull #243
</a>
)
<li
class=
rfe
>
Record fingerprints of parent POMs - only working with Maven
3.x.
Record fingerprints of parent POMs - only working with Maven
2.2 or newer
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-8383"
>
issue 8383
</a>
)
<li
class=
rfe
>
Maven mojo records can be now sorted
...
...
maven-plugin/src/main/java/hudson/maven/reporters/MavenFingerprinter.java
浏览文件 @
38aa4858
...
...
@@ -23,35 +23,42 @@
*/
package
hudson.maven.reporters
;
import
hudson.FilePath
;
import
hudson.Extension
;
import
hudson.FilePath
;
import
hudson.maven.MavenBuild
;
import
hudson.maven.MavenBuildProxy
;
import
hudson.maven.MavenBuildProxy.BuildCallable
;
import
hudson.maven.MavenModule
;
import
hudson.maven.MavenModuleSetBuild
;
import
hudson.maven.MavenReporter
;
import
hudson.maven.MavenReporterDescriptor
;
import
hudson.maven.MojoInfo
;
import
hudson.maven.MavenModuleSetBuild
;
import
hudson.model.BuildListener
;
import
hudson.model.FingerprintMap
;
import
jenkins.model.Jenkins
;
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.
Fiel
d
;
import
java.lang.reflect.
Metho
d
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.logging.Logger
;
import
java.util.Set
;
import
java.util.List
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
jenkins.model.Jenkins
;
import
org.apache.maven.artifact.Artifact
;
import
org.apache.maven.artifact.DefaultArtifact
;
import
org.apache.maven.artifact.handler.DefaultArtifactHandler
;
import
org.apache.maven.artifact.repository.ArtifactRepository
;
import
org.apache.maven.artifact.versioning.VersionRange
;
import
org.apache.maven.project.MavenProject
;
import
org.apache.maven.project.ProjectBuilderConfiguration
;
/**
* Records fingerprints of the builds to keep track of dependencies.
...
...
@@ -84,7 +91,7 @@ public class MavenFingerprinter extends MavenReporter {
* Mojos perform different dependency resolution, so we need to check this for each mojo.
*/
public
boolean
postExecute
(
MavenBuildProxy
build
,
MavenProject
pom
,
MojoInfo
mojo
,
BuildListener
listener
,
Throwable
error
)
throws
InterruptedException
,
IOException
{
// TODO (kutzi, 2011/09/06): it should be perfectly sa
v
e to move all these records to the
// TODO (kutzi, 2011/09/06): it should be perfectly sa
f
e to move all these records to the
// postBuild method as artifacts should only be added by mojos, but never removed/modified.
record
(
pom
.
getArtifacts
(),
used
);
record
(
pom
.
getArtifact
(),
produced
);
...
...
@@ -165,23 +172,21 @@ public class MavenFingerprinter extends MavenReporter {
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
);
DefaultArtifactHandler
artifactHandler
=
new
DefaultArtifactHandler
(
"pom"
);
art
=
new
DefaultArtifact
(
parent
.
getGroupId
(),
parent
.
getArtifactId
(),
VersionRange
.
createFromVersion
(
parent
.
getVersion
()
),
null
,
"pom"
,
""
,
artifactHandler
);
}
return
art
;
}
private
ArtifactRepository
getLocalRepository
(
String
mavenVersion
,
MavenProject
parent
,
MavenProject
pom
)
{
// Maven 2.0 has no corresponding mechanism
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
if
(
mavenVersion
.
startsWith
(
"2.0"
)
||
mavenVersion
.
startsWith
(
"2.1"
))
{
// Maven 2.0 has no corresponding mechanism
return
null
;
}
else
if
(
mavenVersion
.
startsWith
(
"2.2"
))
{
// principally this should also work with Maven 2.1, but it's not tested, so err on the safe side
return
getArtifactRepositoryMaven21
(
pom
);
}
else
if
(
mavenVersion
.
startsWith
(
"3."
)
||
mavenVersion
.
startsWith
(
"4."
)
/* who knows? ;) */
)
{
// Maven 3+
return
parent
.
getProjectBuildingRequest
()
.
getLocalRepository
();
}
else
{
...
...
@@ -192,14 +197,15 @@ public class MavenFingerprinter extends MavenReporter {
@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
ProjectBuilderConfiguration
projectBuilderConfiguration
;
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
());
// Since maven-plugin is compiled against maven-core-3x, we need to retrieve
// this maven 2 object via reflection
Method
method
=
MavenProject
.
class
.
getMethod
(
"getProjectBuilderConfiguration"
);
projectBuilderConfiguration
=
(
ProjectBuilderConfiguration
)
method
.
invoke
(
pom
);
return
projectBuilderConfiguration
.
getLocalRepository
();
}
catch
(
Exception
e
)
{
LOGGER
.
log
(
Level
.
WARNING
,
"Could not retrieve BuilderConfigration"
,
e
);
return
null
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录