Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
b836857d
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
提交
b836857d
编写于
10月 25, 2011
作者:
I
imod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
upgrade to newer version of config-provider-model
上级
cd024812
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
126 addition
and
74 deletion
+126
-74
maven-plugin/pom.xml
maven-plugin/pom.xml
+8
-2
maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java
maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java
+7
-8
maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java
...lugin/src/main/java/hudson/maven/MavenModuleSetBuild.java
+11
-11
maven-plugin/src/main/java/hudson/maven/RedeployPublisher.java
...-plugin/src/main/java/hudson/maven/RedeployPublisher.java
+2
-2
maven-plugin/src/main/java/hudson/maven/settings/SettingsProviderUtils.java
...ain/java/hudson/maven/settings/SettingsProviderUtils.java
+98
-51
未找到文件。
maven-plugin/pom.xml
浏览文件 @
b836857d
...
...
@@ -134,9 +134,15 @@ THE SOFTWARE.
<dependency>
<groupId>
org.jenkins-ci.lib
</groupId>
<artifactId>
config-provider-model
</artifactId>
<version>
1.
0
</version>
<version>
1.
1
</version>
</dependency>
<!-- the dependency between config-file-provider and maven-plugin should be in the other direction -->
<!-- <dependency> -->
<!-- <groupId>org.jenkins-ci.plugins</groupId> -->
<!-- <artifactId>config-file-provider</artifactId> -->
<!-- <version>1.2-SNAPSHOT</version> -->
<!-- <optional>true</optional> -->
<!-- </dependency> -->
<dependency>
<groupId>
org.apache.ant
</groupId>
<artifactId>
ant
</artifactId>
...
...
maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java
浏览文件 @
b836857d
...
...
@@ -34,13 +34,10 @@ import hudson.FilePath;
import
hudson.Functions
;
import
hudson.Indenter
;
import
hudson.Util
;
import
hudson.maven.settings.GlobalMavenSettingsProvider
;
import
hudson.maven.settings.MavenSettingsProvider
;
import
hudson.maven.settings.SettingsProviderUtils
;
import
hudson.model.AbstractProject
;
import
hudson.model.Action
;
import
hudson.model.BuildableItemWithBuildWrappers
;
import
hudson.model.Result
;
import
hudson.tasks.Builder
;
import
hudson.model.DependencyGraph
;
import
hudson.model.Descriptor
;
import
hudson.model.Descriptor.FormException
;
...
...
@@ -51,6 +48,7 @@ import hudson.model.Job;
import
hudson.model.Queue
;
import
hudson.model.Queue.Task
;
import
hudson.model.ResourceActivity
;
import
hudson.model.Result
;
import
hudson.model.SCMedItem
;
import
hudson.model.Saveable
;
import
hudson.model.TaskListener
;
...
...
@@ -61,12 +59,13 @@ import hudson.tasks.BuildStep;
import
hudson.tasks.BuildStepDescriptor
;
import
hudson.tasks.BuildWrapper
;
import
hudson.tasks.BuildWrappers
;
import
hudson.tasks.Builder
;
import
hudson.tasks.Fingerprinter
;
import
hudson.tasks.JavadocArchiver
;
import
hudson.tasks.Mailer
;
import
hudson.tasks.Maven
;
import
hudson.tasks.Maven.MavenInstallation
;
import
hudson.tasks.Publisher
;
import
hudson.tasks.JavadocArchiver
;
import
hudson.tasks.junit.JUnitResultArchiver
;
import
hudson.util.CopyOnWriteMap
;
import
hudson.util.DescribableList
;
...
...
@@ -887,14 +886,14 @@ public class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenMod
ExtensionList
<
ConfigProvider
>
configProviders
=
ConfigProvider
.
all
();
if
(
configProviders
!=
null
&&
configProviders
.
size
()
>
0
)
{
for
(
ConfigProvider
configProvider
:
configProviders
)
{
if
(
configProvider
instanceof
MavenSettingsProvider
)
{
if
(
SettingsProviderUtils
.
isMavenSettingsProvider
(
configProvider
))
{
mavenSettingsConfigs
.
addAll
(
configProvider
.
getAllConfigs
()
);
}
}
}
return
mavenSettingsConfigs
;
}
/**
* @since 1.426
* @return
...
...
@@ -904,7 +903,7 @@ public class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenMod
ExtensionList
<
ConfigProvider
>
configProviders
=
ConfigProvider
.
all
();
if
(
configProviders
!=
null
&&
configProviders
.
size
()
>
0
)
{
for
(
ConfigProvider
configProvider
:
configProviders
)
{
if
(
configProvider
instanceof
GlobalMavenSettingsProvider
)
{
if
(
SettingsProviderUtils
.
isGlobalMavenSettingsProvider
(
configProvider
))
{
globalMavenSettingsConfigs
.
addAll
(
configProvider
.
getAllConfigs
()
);
}
}
...
...
maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java
浏览文件 @
b836857d
...
...
@@ -613,14 +613,14 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
String
settingsConfigId
=
project
.
getSettingConfigId
();
if
(
StringUtils
.
isNotBlank
(
settingsConfigId
))
{
Config
config
=
SettingsProviderUtils
.
findConfig
(
settingsConfigId
,
MavenSettingsProvider
.
class
);
if
(
c
onfig
==
null
)
{
Config
settingsConfig
=
SettingsProviderUtils
.
findConfig
(
settingsConfigId
,
MavenSettingsProvider
.
class
,
org
.
jenkinsci
.
lib
.
configprovider
.
maven
.
MavenSettingsProvider
.
class
);
if
(
settingsC
onfig
==
null
)
{
logger
.
println
(
" your Apache Maven build is setup to use a config with id "
+
settingsConfigId
+
" but cannot find the config"
);
}
else
{
logger
.
println
(
"using settings config with name "
+
c
onfig
.
name
);
if
(
c
onfig
.
content
!=
null
)
{
remoteSettings
=
SettingsProviderUtils
.
copyConfigContentToFilePath
(
c
onfig
,
getWorkspace
()
);
logger
.
println
(
"using settings config with name "
+
settingsC
onfig
.
name
);
if
(
settingsC
onfig
.
content
!=
null
)
{
remoteSettings
=
SettingsProviderUtils
.
copyConfigContentToFilePath
(
settingsC
onfig
,
getWorkspace
()
);
project
.
setAlternateSettings
(
remoteSettings
.
getRemote
()
);
}
}
...
...
@@ -628,18 +628,18 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
String
globalSettingsConfigId
=
project
.
getGlobalSettingConfigId
();
if
(
StringUtils
.
isNotBlank
(
globalSettingsConfigId
))
{
Config
config
=
SettingsProviderUtils
.
findConfig
(
globalSettingsConfigId
,
GlobalMavenSettingsProvider
.
class
);
if
(
c
onfig
==
null
)
{
Config
settingsConfig
=
SettingsProviderUtils
.
findConfig
(
globalSettingsConfigId
,
GlobalMavenSettingsProvider
.
class
,
org
.
jenkinsci
.
lib
.
configprovider
.
maven
.
GlobalMavenSettingsProvider
.
class
);
if
(
settingsC
onfig
==
null
)
{
logger
.
println
(
" your Apache Maven build is setup to use a global settings config with id "
+
globalSettingsConfigId
+
" but cannot find the config"
);
}
else
{
logger
.
println
(
"using global settings config with name "
+
c
onfig
.
name
);
if
(
c
onfig
.
content
!=
null
)
{
remoteGlobalSettings
=
SettingsProviderUtils
.
copyConfigContentToFilePath
(
c
onfig
,
getWorkspace
()
);
logger
.
println
(
"using global settings config with name "
+
settingsC
onfig
.
name
);
if
(
settingsC
onfig
.
content
!=
null
)
{
remoteGlobalSettings
=
SettingsProviderUtils
.
copyConfigContentToFilePath
(
settingsC
onfig
,
getWorkspace
()
);
project
.
globalSettingConfigPath
=
remoteGlobalSettings
.
getRemote
();
}
}
}
}
parsePoms
(
listener
,
logger
,
envVars
,
mvn
,
mavenVersion
);
// #5428 : do pre-build *before* parsing pom
SplittableBuildListener
slistener
=
new
SplittableBuildListener
(
listener
);
...
...
maven-plugin/src/main/java/hudson/maven/RedeployPublisher.java
浏览文件 @
b836857d
...
...
@@ -216,7 +216,7 @@ public class RedeployPublisher extends Recorder {
if
(!
StringUtils
.
isBlank
(
settingsConfigId
))
{
Config
config
=
SettingsProviderUtils
.
findConfig
(
settingsConfigId
,
MavenSettingsProvider
.
class
);
MavenSettingsProvider
.
class
,
org
.
jenkinsci
.
lib
.
configprovider
.
maven
.
MavenSettingsProvider
.
class
);
if
(
config
==
null
)
{
listener
.
getLogger
().
println
(
" your Apache Maven build is setup to use a config with id "
+
settingsConfigId
...
...
@@ -236,7 +236,7 @@ public class RedeployPublisher extends Recorder {
String
globalSettingsConfigId
=
mavenModuleSet
.
getGlobalSettingConfigId
();
if
(!
StringUtils
.
isBlank
(
globalSettingsConfigId
))
{
Config
config
=
SettingsProviderUtils
.
findConfig
(
globalSettingsConfigId
,
GlobalMavenSettingsProvider
.
class
);
Config
config
=
SettingsProviderUtils
.
findConfig
(
globalSettingsConfigId
,
GlobalMavenSettingsProvider
.
class
,
org
.
jenkinsci
.
lib
.
configprovider
.
maven
.
GlobalMavenSettingsProvider
.
class
);
if
(
config
==
null
)
{
listener
.
getLogger
().
println
(
" your Apache Maven build is setup to use a global settings config with id "
...
...
maven-plugin/src/main/java/hudson/maven/settings/SettingsProviderUtils.java
浏览文件 @
b836857d
...
...
@@ -17,70 +17,117 @@ package hudson.maven.settings;
import
hudson.ExtensionList
;
import
hudson.FilePath
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.jenkinsci.lib.configprovider.ConfigProvider
;
import
org.jenkinsci.lib.configprovider.model.Config
;
import
java.io.ByteArrayInputStream
;
import
java.io.File
;
import
java.io.IOException
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.jenkinsci.lib.configprovider.ConfigProvider
;
import
org.jenkinsci.lib.configprovider.model.Config
;
/**
* @author Olivier Lamy
* @since 1.426
*/
public
class
SettingsProviderUtils
{
/**
* utility method to retrieve Config of type (MavenSettingsProvider etc..)
* @param settingsConfigId
* @param type
* @return Config
*/
public
static
Config
findConfig
(
String
settingsConfigId
,
Class
<?>
type
)
{
ExtensionList
<
ConfigProvider
>
configProviders
=
ConfigProvider
.
all
();
if
(
configProviders
!=
null
&&
configProviders
.
size
()
>
0
)
{
for
(
ConfigProvider
configProvider
:
configProviders
)
{
if
(
type
.
isAssignableFrom
(
configProvider
.
getClass
()
)
)
{
if
(
configProvider
.
isResponsibleFor
(
settingsConfigId
)
)
{
return
configProvider
.
getConfigById
(
settingsConfigId
);
}
}
}
}
return
null
;
}
/**
* utility method to retrieve Config of type (MavenSettingsProvider etc..)
*
* @param settingsConfigId
* @param type
* @return Config
*/
public
static
Config
findConfig
(
String
settingsConfigId
,
Class
<?>...
types
)
{
ExtensionList
<
ConfigProvider
>
configProviders
=
ConfigProvider
.
all
();
if
(
configProviders
!=
null
&&
configProviders
.
size
()
>
0
)
{
for
(
ConfigProvider
configProvider
:
configProviders
)
{
for
(
Class
<?>
type
:
types
)
{
if
(
type
.
isAssignableFrom
(
configProvider
.
getClass
()))
{
if
(
configProvider
.
isResponsibleFor
(
settingsConfigId
))
{
return
configProvider
.
getConfigById
(
settingsConfigId
);
}
}
}
}
}
return
null
;
}
/**
*
* @param config
* @param workspace
*/
public
static
FilePath
copyConfigContentToFilePath
(
Config
config
,
FilePath
workspace
)
throws
IOException
,
InterruptedException
{
File
tmpContentFile
=
null
;
ByteArrayInputStream
bs
=
null
;
try
{
tmpContentFile
=
File
.
createTempFile
(
"config"
,
"tmp"
);
FilePath
filePath
=
new
FilePath
(
workspace
,
tmpContentFile
.
getName
());
bs
=
new
ByteArrayInputStream
(
config
.
content
.
getBytes
());
filePath
.
copyFrom
(
bs
);
return
filePath
;
}
finally
{
FileUtils
.
deleteQuietly
(
tmpContentFile
);
IOUtils
.
closeQuietly
(
bs
);
}
}
/**
*
* @return a temp file which must be deleted after use
*/
public
static
File
copyConfigContentToFile
(
Config
config
)
throws
IOException
{
/**
*
* @param config
* @param workspace
*/
public
static
FilePath
copyConfigContentToFilePath
(
Config
config
,
FilePath
workspace
)
throws
IOException
,
InterruptedException
{
File
tmpContentFile
=
null
;
ByteArrayInputStream
bs
=
null
;
File
tmpContentFile
=
File
.
createTempFile
(
"config"
,
"tmp"
);
FileUtils
.
writeStringToFile
(
tmpContentFile
,
config
.
content
);
return
tmpContentFile
;
}
try
{
tmpContentFile
=
File
.
createTempFile
(
"config"
,
"tmp"
);
FilePath
filePath
=
new
FilePath
(
workspace
,
tmpContentFile
.
getName
()
);
bs
=
new
ByteArrayInputStream
(
config
.
content
.
getBytes
());
filePath
.
copyFrom
(
bs
);
return
filePath
;
}
finally
{
FileUtils
.
deleteQuietly
(
tmpContentFile
);
IOUtils
.
closeQuietly
(
bs
);
}
}
/**
* tells whether a config file provider serves global settings configs
*
* @param configProvider
* the provider to check
* @return <code>true</code> if it implements one of the supported
* interfaces
*/
public
static
boolean
isGlobalMavenSettingsProvider
(
ConfigProvider
configProvider
)
{
// first prio to old implementation
if
(
configProvider
instanceof
GlobalMavenSettingsProvider
)
{
return
true
;
}
// second prio to new impl, only if the plugin is installed
if
(
org
.
jenkinsci
.
lib
.
configprovider
.
maven
.
GlobalMavenSettingsProvider
.
class
.
isAssignableFrom
(
configProvider
.
getClass
()))
{
return
true
;
}
return
false
;
}
/**
*
* @return a temp file which must be deleted after use
*/
public
static
File
copyConfigContentToFile
(
Config
config
)
throws
IOException
{
/**
* tells whether a config file provider serves settings configs
*
* @param configProvider
* the provider to check
* @return <code>true</code> if it implements one of the supported
* interfaces
*/
public
static
boolean
isMavenSettingsProvider
(
ConfigProvider
configProvider
)
{
// first prio to old implementation
if
(
configProvider
instanceof
MavenSettingsProvider
)
{
return
true
;
}
// second prio to new impl, only if the plugin is installed
if
(
org
.
jenkinsci
.
lib
.
configprovider
.
maven
.
MavenSettingsProvider
.
class
.
isAssignableFrom
(
configProvider
.
getClass
()))
{
return
true
;
}
return
false
;
}
File
tmpContentFile
=
File
.
createTempFile
(
"config"
,
"tmp"
);
FileUtils
.
writeStringToFile
(
tmpContentFile
,
config
.
content
);
return
tmpContentFile
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录