Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FIY695
jenkins
提交
4f3a285a
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,发现更多精彩内容 >>
提交
4f3a285a
编写于
8月 24, 2011
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FIXED JENKINS-8837] set a dummy mojo object in Maven3, and documented
that this feature is now deprecated.
上级
9144caad
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
67 addition
and
41 deletion
+67
-41
changelog.html
changelog.html
+3
-0
maven-plugin/src/main/java/hudson/maven/Maven3Builder.java
maven-plugin/src/main/java/hudson/maven/Maven3Builder.java
+39
-39
maven-plugin/src/main/java/hudson/maven/MojoInfo.java
maven-plugin/src/main/java/hudson/maven/MojoInfo.java
+25
-2
未找到文件。
changelog.html
浏览文件 @
4f3a285a
...
...
@@ -58,6 +58,9 @@ Upcoming changes</a>
<li
class=
bug
>
CLI clients should be able to see plugin classes
<a
href=
"http://jenkins.361315.n4.nabble.com/channel-example-and-plugin-classes-gives-ClassNotFoundException-tp3756092p3756092.html"
>
report
</a>
<li
class=
bug
>
Fixed NPE in running
<tt>
assembly:assembly
</tt>
with Maven3
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-8837"
>
issue 8837
</a>
)
</ul>
</div>
<!--=TRUNK-END=-->
...
...
maven-plugin/src/main/java/hudson/maven/Maven3Builder.java
浏览文件 @
4f3a285a
...
...
@@ -50,6 +50,7 @@ import java.util.Map.Entry;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.concurrent.ExecutionException
;
import
java.util.logging.Logger
;
import
org.apache.maven.cli.PrintStreamLogger
;
import
org.apache.maven.execution.AbstractExecutionListener
;
...
...
@@ -278,13 +279,6 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
return
null
;
}
// FIXME really used somewhere ???
// FIXME MojoInfo need the real mojo ??
// so tricky to do. need to use MavenPluginManager on the current Maven Build
private
Mojo
getMojo
(
MojoExecution
mojoExecution
,
MavenSession
mavenSession
)
{
return
null
;
}
private
ExpressionEvaluator
getExpressionEvaluator
(
MavenSession
session
,
MojoExecution
mojoExecution
)
{
return
new
PluginParameterExpressionEvaluator
(
session
,
mojoExecution
);
}
...
...
@@ -320,7 +314,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
// set all modules which are not actually being build (in incremental builds) to NOT_BUILD
// JENKINS-9072
List
<
MavenProject
>
projects
=
event
.
getSession
().
getProjects
();
//maven3Builder.listener.getLogger().println
("Projects to build: " + projects);
debug
(
"Projects to build: "
+
projects
);
Set
<
ModuleName
>
buildingProjects
=
new
HashSet
<
ModuleName
>();
for
(
MavenProject
p
:
projects
)
{
buildingProjects
.
add
(
new
ModuleName
(
p
));
...
...
@@ -341,7 +335,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
* @see org.apache.maven.execution.ExecutionListener#sessionEnded(org.apache.maven.execution.ExecutionEvent)
*/
public
void
sessionEnded
(
ExecutionEvent
event
)
{
maven3Builder
.
listener
.
getLogger
().
println
(
"sessionEnded"
);
debug
(
"sessionEnded"
);
this
.
eventLogger
.
sessionEnded
(
event
);
}
...
...
@@ -349,7 +343,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
* @see org.apache.maven.execution.ExecutionListener#projectSkipped(org.apache.maven.execution.ExecutionEvent)
*/
public
void
projectSkipped
(
ExecutionEvent
event
)
{
maven3Builder
.
listener
.
getLogger
().
println
(
"projectSkipped "
+
event
.
getProject
().
getGroupId
()
debug
(
"projectSkipped "
+
event
.
getProject
().
getGroupId
()
+
":"
+
event
.
getProject
().
getArtifactId
()
+
":"
+
event
.
getProject
().
getVersion
());
this
.
eventLogger
.
projectSkipped
(
event
);
...
...
@@ -359,8 +353,8 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
* @see org.apache.maven.execution.ExecutionListener#projectStarted(org.apache.maven.execution.ExecutionEvent)
*/
public
void
projectStarted
(
ExecutionEvent
event
)
{
//maven3Builder.listener.getLogger().println
( "projectStarted " + event.getProject().getGroupId() + ":"
//
+ event.getProject().getArtifactId() + ":" + event.getProject().getVersion() );
debug
(
"projectStarted "
+
event
.
getProject
().
getGroupId
()
+
":"
+
event
.
getProject
().
getArtifactId
()
+
":"
+
event
.
getProject
().
getVersion
()
);
recordProjectStarted
(
event
);
this
.
eventLogger
.
projectStarted
(
event
);
...
...
@@ -404,7 +398,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
* @see org.apache.maven.execution.ExecutionListener#projectSucceeded(org.apache.maven.execution.ExecutionEvent)
*/
public
void
projectSucceeded
(
ExecutionEvent
event
)
{
maven3Builder
.
listener
.
getLogger
().
println
(
"projectSucceeded "
debug
(
"projectSucceeded "
+
event
.
getProject
().
getGroupId
()
+
":"
+
event
.
getProject
().
getArtifactId
()
+
":"
+
event
.
getProject
().
getVersion
());
...
...
@@ -450,7 +444,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
* @see org.apache.maven.execution.ExecutionListener#projectFailed(org.apache.maven.execution.ExecutionEvent)
*/
public
void
projectFailed
(
ExecutionEvent
event
)
{
maven3Builder
.
listener
.
getLogger
().
println
(
"projectFailed "
+
event
.
getProject
().
getGroupId
()
debug
(
"projectFailed "
+
event
.
getProject
().
getGroupId
()
+
":"
+
event
.
getProject
().
getArtifactId
()
+
":"
+
event
.
getProject
().
getVersion
());
recordProjectFailed
(
event
);
...
...
@@ -494,7 +488,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
* @see org.apache.maven.execution.ExecutionListener#mojoSkipped(org.apache.maven.execution.ExecutionEvent)
*/
public
void
mojoSkipped
(
ExecutionEvent
event
)
{
maven3Builder
.
listener
.
getLogger
().
println
(
"mojoSkipped "
+
event
.
getMojoExecution
().
getGroupId
()
+
":"
debug
(
"mojoSkipped "
+
event
.
getMojoExecution
().
getGroupId
()
+
":"
+
event
.
getMojoExecution
().
getArtifactId
()
+
":"
+
event
.
getMojoExecution
().
getVersion
()
+
"("
+
event
.
getMojoExecution
().
getExecutionId
()
+
")"
);
...
...
@@ -505,10 +499,10 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
* @see org.apache.maven.execution.ExecutionListener#mojoStarted(org.apache.maven.execution.ExecutionEvent)
*/
public
void
mojoStarted
(
ExecutionEvent
event
)
{
//maven3Builder.listener.getLogger().println
("mojoStarted " + event.getMojoExecution().getGroupId() + ":"
//
+ event.getMojoExecution().getArtifactId() + ":"
//
+ event.getMojoExecution().getVersion()
//
+ "(" + event.getMojoExecution().getExecutionId() + ")");
debug
(
"mojoStarted "
+
event
.
getMojoExecution
().
getGroupId
()
+
":"
+
event
.
getMojoExecution
().
getArtifactId
()
+
":"
+
event
.
getMojoExecution
().
getVersion
()
+
"("
+
event
.
getMojoExecution
().
getExecutionId
()
+
")"
);
recordMojoStarted
(
event
);
this
.
eventLogger
.
mojoStarted
(
event
);
}
...
...
@@ -519,10 +513,8 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
MavenProject
mavenProject
=
event
.
getProject
();
XmlPlexusConfiguration
xmlPlexusConfiguration
=
new
XmlPlexusConfiguration
(
event
.
getMojoExecution
().
getConfiguration
()
);
Mojo
mojo
=
null
;
//getMojo( event.getMojoExecution(), event.getSession() );
MojoInfo
mojoInfo
=
new
MojoInfo
(
event
.
getMojoExecution
(),
mojo
,
xmlPlexusConfiguration
,
new
MojoInfo
(
event
.
getMojoExecution
(),
null
,
xmlPlexusConfiguration
,
getExpressionEvaluator
(
event
.
getSession
(),
event
.
getMojoExecution
()
)
);
List
<
MavenReporter
>
mavenReporters
=
getMavenReporters
(
mavenProject
);
...
...
@@ -546,10 +538,10 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
* @see org.apache.maven.execution.ExecutionListener#mojoSucceeded(org.apache.maven.execution.ExecutionEvent)
*/
public
void
mojoSucceeded
(
ExecutionEvent
event
)
{
//maven3Builder.listener.getLogger().println
("mojoSucceeded " + event.getMojoExecution().getGroupId() + ":"
//
+ event.getMojoExecution().getArtifactId() + ":"
//
+ event.getMojoExecution().getVersion()
//
+ "(" + event.getMojoExecution().getExecutionId() + ")");
debug
(
"mojoSucceeded "
+
event
.
getMojoExecution
().
getGroupId
()
+
":"
+
event
.
getMojoExecution
().
getArtifactId
()
+
":"
+
event
.
getMojoExecution
().
getVersion
()
+
"("
+
event
.
getMojoExecution
().
getExecutionId
()
+
")"
);
recordMojoSucceeded
(
event
);
this
.
eventLogger
.
mojoSucceeded
(
event
);
}
...
...
@@ -602,13 +594,19 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
* @see org.apache.maven.execution.ExecutionListener#mojoFailed(org.apache.maven.execution.ExecutionEvent)
*/
public
void
mojoFailed
(
ExecutionEvent
event
)
{
maven3Builder
.
listener
.
getLogger
().
println
(
"mojoFailed "
+
event
.
getMojoExecution
().
getGroupId
()
+
":"
debug
(
"mojoFailed "
+
event
.
getMojoExecution
().
getGroupId
()
+
":"
+
event
.
getMojoExecution
().
getArtifactId
()
+
":"
+
event
.
getMojoExecution
().
getVersion
()
+
"("
+
event
.
getMojoExecution
().
getExecutionId
()
+
")"
);
recordMojoFailed
(
event
);
this
.
eventLogger
.
mojoFailed
(
event
);
}
private
void
debug
(
String
msg
)
{
LOGGER
.
fine
(
msg
);
if
(
DEBUG
)
maven3Builder
.
listener
.
getLogger
().
println
(
msg
);
}
private
void
recordMojoFailed
(
ExecutionEvent
event
)
{
Long
startTime
=
getMojoStartTime
(
event
.
getProject
()
);
...
...
@@ -664,7 +662,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
*/
public
void
forkStarted
(
ExecutionEvent
event
)
{
maven3Builder
.
listener
.
getLogger
().
println
(
"mojo forkStarted "
+
event
.
getMojoExecution
().
getGroupId
()
+
":"
LOGGER
.
fine
(
"mojo forkStarted "
+
event
.
getMojoExecution
().
getGroupId
()
+
":"
+
event
.
getMojoExecution
().
getArtifactId
()
+
":"
+
event
.
getMojoExecution
().
getVersion
()
+
"("
+
event
.
getMojoExecution
().
getExecutionId
()
+
")"
);
...
...
@@ -675,7 +673,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
* @see org.apache.maven.execution.ExecutionListener#forkSucceeded(org.apache.maven.execution.ExecutionEvent)
*/
public
void
forkSucceeded
(
ExecutionEvent
event
)
{
maven3Builder
.
listener
.
getLogger
().
println
(
"mojo forkSucceeded "
+
event
.
getMojoExecution
().
getGroupId
()
+
":"
LOGGER
.
fine
(
"mojo forkSucceeded "
+
event
.
getMojoExecution
().
getGroupId
()
+
":"
+
event
.
getMojoExecution
().
getArtifactId
()
+
":"
+
event
.
getMojoExecution
().
getVersion
()
+
"("
+
event
.
getMojoExecution
().
getExecutionId
()
+
")"
);
...
...
@@ -686,7 +684,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
* @see org.apache.maven.execution.ExecutionListener#forkFailed(org.apache.maven.execution.ExecutionEvent)
*/
public
void
forkFailed
(
ExecutionEvent
event
)
{
maven3Builder
.
listener
.
getLogger
().
println
(
"mojo forkFailed "
+
event
.
getMojoExecution
().
getGroupId
()
+
":"
LOGGER
.
fine
(
"mojo forkFailed "
+
event
.
getMojoExecution
().
getGroupId
()
+
":"
+
event
.
getMojoExecution
().
getArtifactId
()
+
":"
+
event
.
getMojoExecution
().
getVersion
()
+
"("
+
event
.
getMojoExecution
().
getExecutionId
()
+
")"
);
...
...
@@ -697,7 +695,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
* @see org.apache.maven.execution.ExecutionListener#forkedProjectStarted(org.apache.maven.execution.ExecutionEvent)
*/
public
void
forkedProjectStarted
(
ExecutionEvent
event
)
{
maven3Builder
.
listener
.
getLogger
().
println
(
"forkedProjectStarted "
+
event
.
getProject
().
getGroupId
()
+
":"
LOGGER
.
fine
(
"forkedProjectStarted "
+
event
.
getProject
().
getGroupId
()
+
":"
+
event
.
getProject
().
getArtifactId
()
+
event
.
getProject
().
getVersion
()
);
recordProjectStarted
(
event
);
this
.
eventLogger
.
forkedProjectStarted
(
event
);
...
...
@@ -707,7 +705,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
* @see org.apache.maven.execution.ExecutionListener#forkedProjectSucceeded(org.apache.maven.execution.ExecutionEvent)
*/
public
void
forkedProjectSucceeded
(
ExecutionEvent
event
)
{
maven3Builder
.
listener
.
getLogger
().
println
(
"forkedProjectSucceeded "
LOGGER
.
fine
(
"forkedProjectSucceeded "
+
event
.
getProject
().
getGroupId
()
+
":"
+
event
.
getProject
().
getArtifactId
()
+
event
.
getProject
().
getVersion
());
...
...
@@ -719,16 +717,18 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
* @see org.apache.maven.execution.ExecutionListener#forkedProjectFailed(org.apache.maven.execution.ExecutionEvent)
*/
public
void
forkedProjectFailed
(
ExecutionEvent
event
)
{
maven3Builder
.
listener
.
getLogger
().
println
(
"forkedProjectFailed "
+
event
.
getProject
().
getGroupId
()
LOGGER
.
fine
(
"forkedProjectFailed "
+
event
.
getProject
().
getGroupId
()
+
":"
+
event
.
getProject
().
getArtifactId
()
+
":"
+
event
.
getProject
().
getVersion
());
recordProjectFailed
(
event
);
}
}
}
}
public
static
boolean
markAsSuccess
;
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
public
static
boolean
DEBUG
=
false
;
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
Maven3Builder
.
class
.
getName
());
}
maven-plugin/src/main/java/hudson/maven/MojoInfo.java
浏览文件 @
4f3a285a
...
...
@@ -23,8 +23,11 @@
*/
package
hudson.maven
;
import
org.apache.maven.plugin.AbstractMojo
;
import
org.apache.maven.plugin.MojoExecution
;
import
org.apache.maven.plugin.Mojo
;
import
org.apache.maven.plugin.MojoExecutionException
;
import
org.apache.maven.plugin.MojoFailureException
;
import
org.apache.maven.plugin.descriptor.PluginDescriptor
;
import
org.codehaus.classworlds.ClassRealm
;
import
org.codehaus.plexus.configuration.PlexusConfiguration
;
...
...
@@ -69,6 +72,12 @@ public class MojoInfo {
/**
* Mojo object that carries out the actual execution.
*
* @deprecated as of 1.427
* Maven3 can no longer provide this information, so plugins cannot rely on this value being present.
* For the time being we are setting a dummy value to avoid NPE. Use {@link #configuration} to access
* configuration values, but otherwise the ability to inject values is lost and there's no viable
* alternative.
*/
public
final
Mojo
mojo
;
...
...
@@ -92,8 +101,9 @@ public class MojoInfo {
private
final
ConverterLookup
converterLookup
=
new
DefaultConverterLookup
();
public
MojoInfo
(
MojoExecution
mojoExecution
,
Mojo
mojo
,
PlexusConfiguration
configuration
,
ExpressionEvaluator
expressionEvaluator
)
{
if
(
mojo
==
null
)
throw
new
IllegalArgumentException
();
// TODO: exactly what other variables are always non-null?
// in Maven3 there's no easy way to get the Mojo instance that's being executed,
// so we just can't pass it in.
if
(
mojo
==
null
)
mojo
=
new
Maven3ProvidesNoAccessToMojo
();
this
.
mojo
=
mojo
;
this
.
mojoExecution
=
mojoExecution
;
this
.
configuration
=
configuration
;
...
...
@@ -167,6 +177,8 @@ public class MojoInfo {
* @throws NoSuchFieldException
* if the mojo doesn't have any field of the given name.
* @since 1.232
* @deprecated as of 1.427
* See the discussion in {@link #mojo}
*/
public
<
T
>
T
inject
(
String
name
,
T
value
)
throws
NoSuchFieldException
{
for
(
Class
c
=
mojo
.
getClass
();
c
!=
Object
.
class
;
c
=
c
.
getSuperclass
())
{
...
...
@@ -205,6 +217,8 @@ public class MojoInfo {
* @throws NoSuchFieldException
* if the specified field is not found on the mojo class, or it is found but the type is not an interface.
* @since 1.232
* @deprecated as of 1.427
* See the discussion in {@link #mojo}
*/
public
void
intercept
(
String
fieldName
,
final
InvocationInterceptor
interceptor
)
throws
NoSuchFieldException
{
for
(
Class
c
=
mojo
.
getClass
();
c
!=
Object
.
class
;
c
=
c
.
getSuperclass
())
{
...
...
@@ -242,4 +256,13 @@ public class MojoInfo {
}
}
}
/**
* Instance will be set to {@link MojoInfo#mojo} to avoid NPE in plugins.
*/
public
static
class
Maven3ProvidesNoAccessToMojo
extends
AbstractMojo
{
public
void
execute
()
throws
MojoExecutionException
,
MojoFailureException
{
throw
new
UnsupportedOperationException
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录