Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
fff55f85
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,发现更多精彩内容 >>
提交
fff55f85
编写于
3月 25, 2012
作者:
I
imod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor interaction with config-file-provider plugin to make dependency optional
上级
9cc6e16d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
58 addition
and
176 deletion
+58
-176
maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java
maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java
+5
-25
maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java
...lugin/src/main/java/hudson/maven/MavenModuleSetBuild.java
+3
-5
maven-plugin/src/main/java/hudson/maven/RedeployPublisher.java
...-plugin/src/main/java/hudson/maven/RedeployPublisher.java
+6
-9
maven-plugin/src/main/java/hudson/maven/settings/GlobalMavenSettingsProvider.java
...va/hudson/maven/settings/GlobalMavenSettingsProvider.java
+0
-24
maven-plugin/src/main/java/hudson/maven/settings/MavenSettingsProvider.java
...ain/java/hudson/maven/settings/MavenSettingsProvider.java
+0
-32
maven-plugin/src/main/java/hudson/maven/settings/SettingsProviderUtils.java
...ain/java/hudson/maven/settings/SettingsProviderUtils.java
+44
-81
未找到文件。
maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java
浏览文件 @
fff55f85
...
...
@@ -37,6 +37,7 @@ import hudson.Util;
import
hudson.maven.local_repo.DefaultLocalRepositoryLocator
;
import
hudson.maven.local_repo.LocalRepositoryLocator
;
import
hudson.maven.local_repo.PerJobLocalRepositoryLocator
;
import
hudson.maven.settings.SettingConfig
;
import
hudson.maven.settings.SettingsProviderUtils
;
import
hudson.model.AbstractProject
;
import
hudson.model.Action
;
...
...
@@ -96,8 +97,6 @@ import net.sf.json.JSONObject;
import
org.apache.commons.lang.math.NumberUtils
;
import
org.apache.maven.model.building.ModelBuildingRequest
;
import
org.jenkinsci.lib.configprovider.ConfigProvider
;
import
org.jenkinsci.lib.configprovider.model.Config
;
import
org.kohsuke.stapler.HttpResponse
;
import
org.kohsuke.stapler.HttpResponses
;
import
org.kohsuke.stapler.QueryParameter
;
...
...
@@ -117,7 +116,6 @@ import org.kohsuke.stapler.export.Exported;
*/
public
class
MavenModuleSet
extends
AbstractMavenProject
<
MavenModuleSet
,
MavenModuleSetBuild
>
implements
TopLevelItem
,
ItemGroup
<
MavenModule
>,
SCMedItem
,
Saveable
,
BuildableItemWithBuildWrappers
{
/**
* All {@link MavenModule}s, keyed by their {@link MavenModule#getModuleName()} module name}s.
*/
...
...
@@ -944,34 +942,16 @@ public class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenMod
* @since 1.426
* @return
*/
public
List
<
Config
>
getAllMavenSettingsConfigs
()
{
List
<
Config
>
mavenSettingsConfigs
=
new
ArrayList
<
Config
>();
ExtensionList
<
ConfigProvider
>
configProviders
=
ConfigProvider
.
all
();
if
(
configProviders
!=
null
&&
configProviders
.
size
()
>
0
)
{
for
(
ConfigProvider
configProvider
:
configProviders
)
{
if
(
SettingsProviderUtils
.
isMavenSettingsProvider
(
configProvider
)){
mavenSettingsConfigs
.
addAll
(
configProvider
.
getAllConfigs
()
);
}
}
}
return
mavenSettingsConfigs
;
public
List
<
SettingConfig
>
getAllMavenSettingsConfigs
()
{
return
SettingsProviderUtils
.
getAllMavenSettingsConfigs
();
}
/**
* @since 1.426
* @return
*/
public
List
<
Config
>
getAllGlobalMavenSettingsConfigs
()
{
List
<
Config
>
globalMavenSettingsConfigs
=
new
ArrayList
<
Config
>();
ExtensionList
<
ConfigProvider
>
configProviders
=
ConfigProvider
.
all
();
if
(
configProviders
!=
null
&&
configProviders
.
size
()
>
0
)
{
for
(
ConfigProvider
configProvider
:
configProviders
)
{
if
(
SettingsProviderUtils
.
isGlobalMavenSettingsProvider
(
configProvider
)){
globalMavenSettingsConfigs
.
addAll
(
configProvider
.
getAllConfigs
()
);
}
}
}
return
globalMavenSettingsConfigs
;
public
List
<
SettingConfig
>
getAllGlobalMavenSettingsConfigs
()
{
return
SettingsProviderUtils
.
getAllGlobalMavenSettingsConfigs
();
}
/**
...
...
maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java
浏览文件 @
fff55f85
...
...
@@ -34,8 +34,7 @@ import hudson.maven.MavenBuild.ProxyImpl2;
import
hudson.maven.reporters.MavenAggregatedArtifactRecord
;
import
hudson.maven.reporters.MavenFingerprinter
;
import
hudson.maven.reporters.MavenMailer
;
import
hudson.maven.settings.GlobalMavenSettingsProvider
;
import
hudson.maven.settings.MavenSettingsProvider
;
import
hudson.maven.settings.SettingConfig
;
import
hudson.maven.settings.SettingsProviderUtils
;
import
hudson.model.AbstractProject
;
import
hudson.model.Action
;
...
...
@@ -92,7 +91,6 @@ import org.apache.maven.model.building.ModelBuildingRequest;
import
org.apache.maven.project.MavenProject
;
import
org.apache.maven.project.ProjectBuildingException
;
import
org.codehaus.plexus.util.PathTool
;
import
org.jenkinsci.lib.configprovider.model.Config
;
import
org.kohsuke.stapler.StaplerRequest
;
import
org.kohsuke.stapler.StaplerResponse
;
import
org.kohsuke.stapler.export.Exported
;
...
...
@@ -624,7 +622,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
String
settingsConfigId
=
project
.
getSettingConfigId
();
if
(
StringUtils
.
isNotBlank
(
settingsConfigId
))
{
Config
settingsConfig
=
SettingsProviderUtils
.
findConfig
(
settingsConfigId
,
MavenSettingsProvider
.
class
,
org
.
jenkinsci
.
lib
.
configprovider
.
maven
.
MavenSettingsProvider
.
class
);
SettingConfig
settingsConfig
=
SettingsProviderUtils
.
findSettings
(
settingsConfigId
);
if
(
settingsConfig
==
null
)
{
logger
.
println
(
" your Apache Maven build is setup to use a config with id "
+
settingsConfigId
+
" but cannot find the config"
);
...
...
@@ -639,7 +637,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
String
globalSettingsConfigId
=
project
.
getGlobalSettingConfigId
();
if
(
StringUtils
.
isNotBlank
(
globalSettingsConfigId
))
{
Config
settingsConfig
=
SettingsProviderUtils
.
findConfig
(
globalSettingsConfigId
,
GlobalMavenSettingsProvider
.
class
,
org
.
jenkinsci
.
lib
.
configprovider
.
maven
.
GlobalMavenSettingsProvider
.
class
);
SettingConfig
settingsConfig
=
SettingsProviderUtils
.
findSettings
(
globalSettingsConfigId
);
if
(
settingsConfig
==
null
)
{
logger
.
println
(
" your Apache Maven build is setup to use a global settings config with id "
+
globalSettingsConfigId
+
" but cannot find the config"
);
...
...
maven-plugin/src/main/java/hudson/maven/RedeployPublisher.java
浏览文件 @
fff55f85
...
...
@@ -29,8 +29,7 @@ import hudson.Launcher;
import
hudson.Util
;
import
hudson.maven.reporters.MavenAbstractArtifactRecord
;
import
hudson.maven.reporters.MavenArtifactRecord
;
import
hudson.maven.settings.GlobalMavenSettingsProvider
;
import
hudson.maven.settings.MavenSettingsProvider
;
import
hudson.maven.settings.SettingConfig
;
import
hudson.maven.settings.SettingsProviderUtils
;
import
hudson.model.AbstractBuild
;
import
hudson.model.AbstractProject
;
...
...
@@ -54,6 +53,9 @@ import java.util.List;
import
java.util.Map.Entry
;
import
java.util.Properties
;
import
jenkins.model.Jenkins
;
import
net.sf.json.JSONObject
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.maven.artifact.Artifact
;
...
...
@@ -67,13 +69,9 @@ import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import
org.apache.maven.cli.BatchModeMavenTransferListener
;
import
org.apache.maven.repository.Proxy
;
import
org.codehaus.plexus.component.repository.exception.ComponentLookupException
;
import
org.jenkinsci.lib.configprovider.model.Config
;
import
org.kohsuke.stapler.DataBoundConstructor
;
import
org.kohsuke.stapler.StaplerRequest
;
import
jenkins.model.Jenkins
;
import
net.sf.json.JSONObject
;
/**
* {@link Publisher} for {@link MavenModuleSetBuild} to deploy artifacts
* after a build is fully succeeded.
...
...
@@ -233,8 +231,7 @@ public class RedeployPublisher extends Recorder {
String
altSettingsPath
=
null
;
if
(!
StringUtils
.
isBlank
(
settingsConfigId
))
{
Config
config
=
SettingsProviderUtils
.
findConfig
(
settingsConfigId
,
MavenSettingsProvider
.
class
,
org
.
jenkinsci
.
lib
.
configprovider
.
maven
.
MavenSettingsProvider
.
class
);
SettingConfig
config
=
SettingsProviderUtils
.
findSettings
(
settingsConfigId
);
if
(
config
==
null
)
{
listener
.
getLogger
().
println
(
" your Apache Maven build is setup to use a config with id "
+
settingsConfigId
...
...
@@ -254,7 +251,7 @@ public class RedeployPublisher extends Recorder {
String
globalSettingsConfigId
=
mavenModuleSet
.
getGlobalSettingConfigId
();
if
(!
StringUtils
.
isBlank
(
globalSettingsConfigId
))
{
Config
config
=
SettingsProviderUtils
.
findConfig
(
globalSettingsConfigId
,
GlobalMavenSettingsProvider
.
class
,
org
.
jenkinsci
.
lib
.
configprovider
.
maven
.
GlobalMavenSettingsProvider
.
class
);
SettingConfig
config
=
SettingsProviderUtils
.
findSettings
(
globalSettingsConfigId
);
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/GlobalMavenSettingsProvider.java
已删除
100644 → 0
浏览文件 @
9cc6e16d
/*
* Copyright 20011 Olivier Lamy
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
hudson.maven.settings
;
/**
* @author Olivier Lamy
* @since 1.426
*/
public
interface
GlobalMavenSettingsProvider
{
// no op only a marker interface
}
maven-plugin/src/main/java/hudson/maven/settings/MavenSettingsProvider.java
已删除
100644 → 0
浏览文件 @
9cc6e16d
/*
The MIT License
Copyright (c) 2011, Dominik Bartholdi, Olivier Lamy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package
hudson.maven.settings
;
/**
* @since 1.426
*/
public
interface
MavenSettingsProvider
{
// no op only a marker interface
}
maven-plugin/src/main/java/hudson/maven/settings/SettingsProviderUtils.java
浏览文件 @
fff55f85
...
...
@@ -15,15 +15,13 @@
*/
package
hudson.maven.settings
;
import
hudson.ExtensionList
;
import
hudson.FilePath
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.List
;
import
org.apache.commons.io.FileUtils
;
import
org.jenkinsci.lib.configprovider.ConfigProvider
;
import
org.jenkinsci.lib.configprovider.model.Config
;
/**
* @author Olivier Lamy
...
...
@@ -32,89 +30,54 @@ import org.jenkinsci.lib.configprovider.model.Config;
*/
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
<?>...
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
);
}
}
private
static
ConfigProviderFacade
configProvider
=
new
ConfigProviderDelegate
();
}
}
}
return
null
;
}
private
SettingsProviderUtils
()
{
}
/**
*
* @param config
* @param workspace
*/
public
static
FilePath
copyConfigContentToFilePath
(
Config
config
,
FilePath
workspace
)
throws
IOException
,
InterruptedException
{
return
workspace
.
createTextTempFile
(
"config"
,
".tmp"
,
config
.
content
,
false
);
}
/**
* @since 1.426
* @return
*/
public
static
List
<
SettingConfig
>
getAllMavenSettingsConfigs
()
{
return
configProvider
.
getAllMavenSettingsConfigs
();
}
/**
*
* @return a temp file which must be deleted after use
*/
public
static
File
copyConfigContentToFile
(
Config
config
)
throws
IOException
{
/**
* @since 1.426
* @return
*/
public
static
List
<
SettingConfig
>
getAllGlobalMavenSettingsConfigs
()
{
return
configProvider
.
getAllGlobalMavenSettingsConfigs
();
}
File
tmpContentFile
=
File
.
createTempFile
(
"config"
,
"tmp"
);
FileUtils
.
writeStringToFile
(
tmpContentFile
,
config
.
content
);
return
tmpContentFile
;
}
/**
* utility method to retrieve Config of type (MavenSettingsProvider etc..)
*
* @param settingsConfigId
* @param type
* @return SettingConfig
*/
public
static
SettingConfig
findSettings
(
String
settingsConfigId
)
{
return
configProvider
.
findConfig
(
settingsConfigId
);
}
/**
* 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
;
}
/**
*
* @param config
* @param workspace
*/
public
static
FilePath
copyConfigContentToFilePath
(
SettingConfig
config
,
FilePath
workspace
)
throws
IOException
,
InterruptedException
{
return
workspace
.
createTextTempFile
(
"config"
,
".tmp"
,
config
.
content
,
false
);
}
/**
* 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
;
}
/**
* @return a temp file which must be deleted after use
*/
public
static
File
copyConfigContentToFile
(
SettingConfig
config
)
throws
IOException
{
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录