Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
87fb68a0
J
jenkins
项目概览
LinuxSuRen
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
87fb68a0
编写于
10月 08, 2011
作者:
C
Christoph Kutzinski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make futures list private and provide accessor methods
上级
731c9777
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
62 addition
and
50 deletion
+62
-50
maven-plugin/src/main/java/hudson/maven/AbstractMavenBuilder.java
...ugin/src/main/java/hudson/maven/AbstractMavenBuilder.java
+49
-2
maven-plugin/src/main/java/hudson/maven/Maven3Builder.java
maven-plugin/src/main/java/hudson/maven/Maven3Builder.java
+6
-22
maven-plugin/src/main/java/hudson/maven/MavenBuild.java
maven-plugin/src/main/java/hudson/maven/MavenBuild.java
+1
-2
maven-plugin/src/main/java/hudson/maven/MavenBuilder.java
maven-plugin/src/main/java/hudson/maven/MavenBuilder.java
+6
-24
未找到文件。
maven-plugin/src/main/java/hudson/maven/AbstractMavenBuilder.java
浏览文件 @
87fb68a0
...
...
@@ -24,7 +24,7 @@
package
hudson.maven
;
import
hudson.model.BuildListener
;
import
jenkins.model.Jenkins
;
import
hudson.model.Executor
;
import
hudson.model.Result
;
import
hudson.remoting.Channel
;
import
hudson.remoting.DelegatingCallable
;
...
...
@@ -35,6 +35,10 @@ import java.io.Serializable;
import
java.text.NumberFormat
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.concurrent.ExecutionException
;
import
jenkins.model.Jenkins
;
/**
* @author Olivier Lamy
...
...
@@ -61,7 +65,7 @@ public abstract class AbstractMavenBuilder implements DelegatingCallable<Result,
* Record all asynchronous executions as they are scheduled,
* to make sure they are all completed before we finish.
*/
pr
otected
transient
/*final*/
List
<
Future
<?>>
futures
;
pr
ivate
transient
/*final*/
List
<
Future
<?>>
futures
;
protected
AbstractMavenBuilder
(
BuildListener
listener
,
List
<
String
>
goals
,
Map
<
String
,
String
>
systemProps
)
{
this
.
listener
=
listener
;
...
...
@@ -109,10 +113,53 @@ public abstract class AbstractMavenBuilder implements DelegatingCallable<Result,
return
Jenkins
.
getInstance
().
getPluginManager
().
uberClassLoader
;
}
/**
* Initialize the collection of the asynchronous executions.
* The method must be called in the Maven jail process i.e. inside the call method!
*/
protected
void
initializeAsynchronousExecutions
()
{
futures
=
new
CopyOnWriteArrayList
<
Future
<?>>();
}
/**
* Records a new asynchronous exection.
*/
protected
void
recordAsynchronousExecution
(
Future
<?>
future
)
{
futures
.
add
(
future
);
}
/**
* Waits until all asynchronous executions are finished.
*
* @return null in success case; returns an ABORT result if we were interrupted while waiting
*/
protected
Result
waitForAsynchronousExecutions
()
{
try
{
boolean
messageReported
=
false
;
for
(
Future
<?>
f
:
futures
)
{
try
{
if
(!
f
.
isDone
()
&&
!
messageReported
)
{
messageReported
=
true
;
listener
.
getLogger
().
println
(
Messages
.
MavenBuilder_Waiting
());
}
f
.
get
();
}
catch
(
InterruptedException
e
)
{
// attempt to cancel all asynchronous tasks
for
(
Future
<?>
g
:
futures
)
g
.
cancel
(
true
);
listener
.
getLogger
().
println
(
Messages
.
MavenBuilder_Aborted
());
return
Executor
.
currentExecutor
().
abortResult
();
}
catch
(
ExecutionException
e
)
{
e
.
printStackTrace
(
listener
.
error
(
Messages
.
MavenBuilder_AsyncFailed
()));
}
}
return
null
;
}
finally
{
futures
.
clear
();
}
}
protected
class
FilterImpl
extends
MavenBuildProxy2
.
Filter
<
MavenBuildProxy2
>
implements
Serializable
{
private
MavenBuildInformation
mavenBuildInformation
;
...
...
maven-plugin/src/main/java/hudson/maven/Maven3Builder.java
浏览文件 @
87fb68a0
...
...
@@ -27,11 +27,9 @@ import hudson.Launcher;
import
hudson.maven.MavenBuild.ProxyImpl2
;
import
hudson.maven.util.ExecutionEventLogger
;
import
hudson.model.BuildListener
;
import
hudson.model.Executor
;
import
hudson.model.Result
;
import
hudson.remoting.Channel
;
import
hudson.remoting.DelegatingCallable
;
import
hudson.remoting.Future
;
import
hudson.util.IOException2
;
import
java.io.IOException
;
...
...
@@ -48,7 +46,6 @@ import java.util.Set;
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
;
...
...
@@ -101,7 +98,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
MavenExecutionListener
mavenExecutionListener
=
new
MavenExecutionListener
(
this
);
try
{
futures
=
new
CopyOnWriteArrayList
<
Future
<?>>(
);
initializeAsynchronousExecutions
(
);
Maven3Launcher
.
setMavenExecutionListener
(
mavenExecutionListener
);
...
...
@@ -115,27 +112,14 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
int
r
=
Maven3Main
.
launch
(
goals
.
toArray
(
new
String
[
goals
.
size
()]));
// now check the completion status of async ops
boolean
messageReported
=
false
;
long
startTime
=
System
.
nanoTime
();
for
(
Future
<?>
f
:
futures
)
{
try
{
if
(!
f
.
isDone
()
&&
!
messageReported
)
{
messageReported
=
true
;
listener
.
getLogger
().
println
(
Messages
.
MavenBuilder_Waiting
());
}
f
.
get
();
}
catch
(
InterruptedException
e
)
{
// attempt to cancel all asynchronous tasks
for
(
Future
<?>
g
:
futures
)
g
.
cancel
(
true
);
listener
.
getLogger
().
println
(
Messages
.
MavenBuilder_Aborted
());
return
Executor
.
currentExecutor
().
abortResult
();
}
catch
(
ExecutionException
e
)
{
e
.
printStackTrace
(
listener
.
error
(
Messages
.
MavenBuilder_AsyncFailed
()));
}
Result
waitForAsyncExecutionsResult
=
waitForAsynchronousExecutions
();
if
(
waitForAsyncExecutionsResult
!=
null
)
{
return
waitForAsyncExecutionsResult
;
}
mavenExecutionListener
.
overheadTime
+=
System
.
nanoTime
()-
startTime
;
futures
.
clear
();
if
(
profile
)
{
NumberFormat
n
=
NumberFormat
.
getInstance
();
...
...
maven-plugin/src/main/java/hudson/maven/MavenBuild.java
浏览文件 @
87fb68a0
...
...
@@ -36,7 +36,6 @@ import hudson.model.Computer;
import
hudson.model.Descriptor
;
import
hudson.model.Environment
;
import
hudson.model.Executor
;
import
jenkins.model.Jenkins
;
import
hudson.model.Node
;
import
hudson.model.Result
;
import
hudson.model.Run
;
...
...
@@ -319,7 +318,7 @@ public class MavenBuild extends AbstractMavenBuild<MavenModule,MavenBuild> {
@Override
public
void
executeAsync
(
final
BuildCallable
<?,?>
program
)
throws
IOException
{
futures
.
add
(
Channel
.
current
().
callAsync
(
new
AsyncInvoker
(
core
,
program
)));
recordAsynchronousExecution
(
Channel
.
current
().
callAsync
(
new
AsyncInvoker
(
core
,
program
)));
}
public
MavenBuildInformation
getMavenBuildInformation
()
...
...
maven-plugin/src/main/java/hudson/maven/MavenBuilder.java
浏览文件 @
87fb68a0
...
...
@@ -29,12 +29,10 @@ import hudson.maven.agent.Main;
import
hudson.maven.agent.PluginManagerListener
;
import
hudson.maven.reporters.SurefireArchiver
;
import
hudson.model.BuildListener
;
import
hudson.model.Executor
;
import
hudson.model.Result
;
import
hudson.remoting.Callable
;
import
hudson.remoting.Channel
;
import
hudson.remoting.DelegatingCallable
;
import
hudson.remoting.Future
;
import
hudson.util.IOException2
;
import
java.io.IOException
;
...
...
@@ -42,11 +40,8 @@ import java.io.PrintStream;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.text.NumberFormat
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ExecutionException
;
import
org.apache.maven.BuildFailureException
;
import
org.apache.maven.execution.MavenSession
;
import
org.apache.maven.execution.ReactorManager
;
...
...
@@ -137,7 +132,7 @@ public abstract class MavenBuilder extends AbstractMavenBuilder implements Deleg
try
{
futures
=
new
ArrayList
<
Future
<?>>
();
initializeAsynchronousExecutions
();
Adapter
a
=
new
Adapter
(
this
);
callSetListenerWithReflectOnInterceptors
(
a
,
mavenJailProcessClassLoader
);
...
...
@@ -154,27 +149,14 @@ public abstract class MavenBuilder extends AbstractMavenBuilder implements Deleg
int
r
=
Main
.
launch
(
goals
.
toArray
(
new
String
[
goals
.
size
()]));
// now check the completion status of async ops
boolean
messageReported
=
false
;
long
startTime
=
System
.
nanoTime
();
for
(
Future
<?>
f
:
futures
)
{
try
{
if
(!
f
.
isDone
()
&&
!
messageReported
)
{
messageReported
=
true
;
listener
.
getLogger
().
println
(
Messages
.
MavenBuilder_Waiting
());
}
f
.
get
();
}
catch
(
InterruptedException
e
)
{
// attempt to cancel all asynchronous tasks
for
(
Future
<?>
g
:
futures
)
g
.
cancel
(
true
);
listener
.
getLogger
().
println
(
Messages
.
MavenBuilder_Aborted
());
return
Executor
.
currentExecutor
().
abortResult
();
}
catch
(
ExecutionException
e
)
{
e
.
printStackTrace
(
listener
.
error
(
Messages
.
MavenBuilder_AsyncFailed
()));
}
Result
waitForAsyncExecutionsResult
=
waitForAsynchronousExecutions
();
if
(
waitForAsyncExecutionsResult
!=
null
)
{
return
waitForAsyncExecutionsResult
;
}
a
.
overheadTime
+=
System
.
nanoTime
()-
startTime
;
futures
.
clear
();
if
(
profile
)
{
NumberFormat
n
=
NumberFormat
.
getInstance
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录