提交 4d51a3ea 编写于 作者: I imod

remove whole unused package hudons.maven.settings (was only used to integrate...

remove whole unused package hudons.maven.settings (was only used to integrate old config-file-provider implementation)
上级 5eabce8d
...@@ -36,8 +36,6 @@ import hudson.Util; ...@@ -36,8 +36,6 @@ import hudson.Util;
import hudson.maven.local_repo.DefaultLocalRepositoryLocator; import hudson.maven.local_repo.DefaultLocalRepositoryLocator;
import hudson.maven.local_repo.LocalRepositoryLocator; import hudson.maven.local_repo.LocalRepositoryLocator;
import hudson.maven.local_repo.PerJobLocalRepositoryLocator; import hudson.maven.local_repo.PerJobLocalRepositoryLocator;
import hudson.maven.settings.SettingConfig;
import hudson.maven.settings.SettingsProviderUtils;
import hudson.model.AbstractProject; import hudson.model.AbstractProject;
import hudson.model.Action; import hudson.model.Action;
import hudson.model.BuildableItemWithBuildWrappers; import hudson.model.BuildableItemWithBuildWrappers;
...@@ -1023,22 +1021,6 @@ public class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenMod ...@@ -1023,22 +1021,6 @@ public class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenMod
} }
} }
/**
* @since 1.426
* @return
*/
public List<SettingConfig> getAllMavenSettingsConfigs() {
return SettingsProviderUtils.getAllMavenSettingsConfigs();
}
/**
* @since 1.426
* @return
*/
public List<SettingConfig> getAllGlobalMavenSettingsConfigs() {
return SettingsProviderUtils.getAllGlobalMavenSettingsConfigs();
}
/** /**
* Set mavenOpts. * Set mavenOpts.
*/ */
......
/*
The MIT License
Copyright (c) 2012, Dominik Bartholdi
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;
import java.util.Collections;
import java.util.List;
import java.util.logging.Logger;
import jenkins.model.Jenkins;
public class ConfigProviderDelegate implements ConfigProviderFacade {
private static final Logger LOGGER = Logger.getLogger(ConfigProviderDelegate.class.getName());
private final ConfigProviderFacade cpf;
public ConfigProviderDelegate() {
if (Jenkins.getInstance().getPlugin("config-file-provider") != null) {
cpf = new ConfigProviderMediator();
} else {
LOGGER.warning("'config-file-provider' plugin not installed..., administration of setting.xml will not be available!");
cpf = new DefaultConfigProviderFacade();
}
}
@Override
public List<SettingConfig> getAllGlobalMavenSettingsConfigs() {
return cpf.getAllGlobalMavenSettingsConfigs();
}
@Override
public List<SettingConfig> getAllMavenSettingsConfigs() {
return cpf.getAllMavenSettingsConfigs();
}
@Override
public SettingConfig findConfig(String settingsConfigId) {
return cpf.findConfig(settingsConfigId);
}
private static final class DefaultConfigProviderFacade implements ConfigProviderFacade {
@Override
public List<SettingConfig> getAllGlobalMavenSettingsConfigs() {
return Collections.emptyList();
}
@Override
public List<SettingConfig> getAllMavenSettingsConfigs() {
return Collections.emptyList();
}
@Override
public SettingConfig findConfig(String settingsConfigId) {
return null;
}
}
}
/*
The MIT License
Copyright (c) 2012, Dominik Bartholdi
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;
import java.util.List;
public interface ConfigProviderFacade {
/**
* Gets all maven (non global) settings available
*
* @since 1.426
* @return list of all settings
*/
public List<SettingConfig> getAllMavenSettingsConfigs();
/**
* Gets all global maven settings
*
* @since 1.426
* @return list of all global settings
*/
public List<SettingConfig> getAllGlobalMavenSettingsConfigs();
/**
* Gets a settings config by its id.
*
* @param settingsConfigId
* the id of the config to get
* @return the settings config
*/
public SettingConfig findConfig(String settingsConfigId);
}
\ No newline at end of file
/*
The MIT License
Copyright (c) 2012, Dominik Bartholdi
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;
import hudson.ExtensionList;
import java.util.ArrayList;
import java.util.List;
import jenkins.model.Jenkins;
import org.jenkinsci.lib.configprovider.ConfigProvider;
import org.jenkinsci.lib.configprovider.model.Config;
import org.jenkinsci.plugins.configfiles.maven.GlobalMavenSettingsConfig.GlobalMavenSettingsConfigProvider;
import org.jenkinsci.plugins.configfiles.maven.MavenSettingsConfig.MavenSettingsConfigProvider;
public class ConfigProviderMediator implements ConfigProviderFacade {
/**
* @see hudson.maven.settings.ConfigProviderFacade#getAllMavenSettingsConfigs()
*/
@Override
public List<SettingConfig> getAllMavenSettingsConfigs() {
final ExtensionList<MavenSettingsConfigProvider> configProviders = Jenkins.getInstance().getExtensionList(MavenSettingsConfigProvider.class);
List<SettingConfig> mavenSettingsConfigs = new ArrayList<SettingConfig>();
if (configProviders.size() > 0) {
for (ConfigProvider configProvider : configProviders) {
for (Config config : configProvider.getAllConfigs()) {
mavenSettingsConfigs.add(new SettingConfig(config.id, config.name, config.comment, config.content));
}
}
}
return mavenSettingsConfigs;
}
/**
* @see hudson.maven.settings.ConfigProviderFacade#getAllGlobalMavenSettingsConfigs()
*/
@Override
public List<SettingConfig> getAllGlobalMavenSettingsConfigs() {
final ExtensionList<GlobalMavenSettingsConfigProvider> configProviders = Jenkins.getInstance()
.getExtensionList(GlobalMavenSettingsConfigProvider.class);
List<SettingConfig> globalMavenSettingsConfigs = new ArrayList<SettingConfig>();
if (configProviders.size() > 0) {
for (ConfigProvider configProvider : configProviders) {
for (Config config : configProvider.getAllConfigs()) {
globalMavenSettingsConfigs.add(new SettingConfig(config.id, config.name, config.comment, config.content));
}
}
}
return globalMavenSettingsConfigs;
}
/**
* Utility method to retrieve SettingConfig
*
* @param settingsConfigId
* the id to get the config for
* @return SettingConfig the config
*/
public SettingConfig findConfig(String settingsConfigId) {
ExtensionList<ConfigProvider> configProviders = ConfigProvider.all();
if (configProviders.size() > 0) {
for (ConfigProvider configProvider : configProviders) {
if (configProvider.isResponsibleFor(settingsConfigId)) {
final Config config = configProvider.getConfigById(settingsConfigId);
return new SettingConfig(config.id, config.name, config.comment, config.content);
}
}
}
return null;
}
}
/*
The MIT License
Copyright (c) 2012, Dominik Bartholdi
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;
import java.io.Serializable;
/**
* Represents a particular settings file and its content - actually its a shadow object to hold the config data coming from a ConfigProvider of the 'config-provider' plugin.
*
* @author domi
*/
public class SettingConfig implements Serializable {
private static final long serialVersionUID = 1L;
/**
* a unique id along all providers!
*/
public final String id;
public final String name;
/**
* Any note that the author of this configuration wants to associate with this.
*/
public final String comment;
/**
* Content of the file as-is.
*/
public final String content;
public SettingConfig(String id, String name, String comment, String content) {
this.id = id == null ? String.valueOf(System.currentTimeMillis()) : id;
this.name = name;
this.comment = comment;
this.content = content;
}
@Override
public String toString() {
return "[SettingConfig: id=" + id + ", name=" + name + "]";
}
}
/*
* Copyright 20011 Talend, 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;
import hudson.FilePath;
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.apache.commons.io.FileUtils;
/**
* @author Olivier Lamy
* @author Dominik Bartholdi (imod)
* @since 1.426
*/
public class SettingsProviderUtils {
private static ConfigProviderFacade configProvider = new ConfigProviderDelegate();
private SettingsProviderUtils() {
}
/**
* @since 1.426
* @return
*/
public static List<SettingConfig> getAllMavenSettingsConfigs() {
return configProvider.getAllMavenSettingsConfigs();
}
/**
* @since 1.426
* @return
*/
public static List<SettingConfig> getAllGlobalMavenSettingsConfigs() {
return configProvider.getAllGlobalMavenSettingsConfigs();
}
/**
* 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);
}
/**
*
* @param config
* @param workspace
*/
public static FilePath copyConfigContentToFilePath(SettingConfig config, FilePath workspace) throws IOException, InterruptedException {
return workspace.createTextTempFile("config", ".tmp", config.content, 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.
先完成此消息的编辑!
想要评论请 注册