From 4d51a3ea32bf699f3758f91eab2d2f2b19c821db Mon Sep 17 00:00:00 2001 From: imod Date: Wed, 26 Sep 2012 20:37:38 +0200 Subject: [PATCH] remove whole unused package hudons.maven.settings (was only used to integrate old config-file-provider implementation) --- .../java/hudson/maven/MavenModuleSet.java | 18 ---- .../settings/ConfigProviderDelegate.java | 76 --------------- .../maven/settings/ConfigProviderFacade.java | 55 ----------- .../settings/ConfigProviderMediator.java | 95 ------------------- .../hudson/maven/settings/SettingConfig.java | 65 ------------- .../maven/settings/SettingsProviderUtils.java | 83 ---------------- 6 files changed, 392 deletions(-) delete mode 100644 maven-plugin/src/main/java/hudson/maven/settings/ConfigProviderDelegate.java delete mode 100644 maven-plugin/src/main/java/hudson/maven/settings/ConfigProviderFacade.java delete mode 100644 maven-plugin/src/main/java/hudson/maven/settings/ConfigProviderMediator.java delete mode 100644 maven-plugin/src/main/java/hudson/maven/settings/SettingConfig.java delete mode 100644 maven-plugin/src/main/java/hudson/maven/settings/SettingsProviderUtils.java diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java index df210f4a03..2d8e93ccf4 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java @@ -36,8 +36,6 @@ 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; import hudson.model.BuildableItemWithBuildWrappers; @@ -1023,22 +1021,6 @@ public class MavenModuleSet extends AbstractMavenProject getAllMavenSettingsConfigs() { - return SettingsProviderUtils.getAllMavenSettingsConfigs(); - } - - /** - * @since 1.426 - * @return - */ - public List getAllGlobalMavenSettingsConfigs() { - return SettingsProviderUtils.getAllGlobalMavenSettingsConfigs(); - } - /** * Set mavenOpts. */ diff --git a/maven-plugin/src/main/java/hudson/maven/settings/ConfigProviderDelegate.java b/maven-plugin/src/main/java/hudson/maven/settings/ConfigProviderDelegate.java deleted file mode 100644 index a64809382a..0000000000 --- a/maven-plugin/src/main/java/hudson/maven/settings/ConfigProviderDelegate.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - 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 getAllGlobalMavenSettingsConfigs() { - return cpf.getAllGlobalMavenSettingsConfigs(); - } - - @Override - public List getAllMavenSettingsConfigs() { - return cpf.getAllMavenSettingsConfigs(); - } - - @Override - public SettingConfig findConfig(String settingsConfigId) { - return cpf.findConfig(settingsConfigId); - } - - private static final class DefaultConfigProviderFacade implements ConfigProviderFacade { - @Override - public List getAllGlobalMavenSettingsConfigs() { - return Collections.emptyList(); - } - - @Override - public List getAllMavenSettingsConfigs() { - return Collections.emptyList(); - } - - @Override - public SettingConfig findConfig(String settingsConfigId) { - return null; - } - } -} diff --git a/maven-plugin/src/main/java/hudson/maven/settings/ConfigProviderFacade.java b/maven-plugin/src/main/java/hudson/maven/settings/ConfigProviderFacade.java deleted file mode 100644 index dbe5609feb..0000000000 --- a/maven-plugin/src/main/java/hudson/maven/settings/ConfigProviderFacade.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - 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 getAllMavenSettingsConfigs(); - - /** - * Gets all global maven settings - * - * @since 1.426 - * @return list of all global settings - */ - public List 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 diff --git a/maven-plugin/src/main/java/hudson/maven/settings/ConfigProviderMediator.java b/maven-plugin/src/main/java/hudson/maven/settings/ConfigProviderMediator.java deleted file mode 100644 index f059ab28c0..0000000000 --- a/maven-plugin/src/main/java/hudson/maven/settings/ConfigProviderMediator.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - 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 getAllMavenSettingsConfigs() { - final ExtensionList configProviders = Jenkins.getInstance().getExtensionList(MavenSettingsConfigProvider.class); - List mavenSettingsConfigs = new ArrayList(); - 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 getAllGlobalMavenSettingsConfigs() { - final ExtensionList configProviders = Jenkins.getInstance() - .getExtensionList(GlobalMavenSettingsConfigProvider.class); - List globalMavenSettingsConfigs = new ArrayList(); - 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 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; - } - -} diff --git a/maven-plugin/src/main/java/hudson/maven/settings/SettingConfig.java b/maven-plugin/src/main/java/hudson/maven/settings/SettingConfig.java deleted file mode 100644 index 3d9c67861c..0000000000 --- a/maven-plugin/src/main/java/hudson/maven/settings/SettingConfig.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - 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 + "]"; - } -} diff --git a/maven-plugin/src/main/java/hudson/maven/settings/SettingsProviderUtils.java b/maven-plugin/src/main/java/hudson/maven/settings/SettingsProviderUtils.java deleted file mode 100644 index 18aa841ef7..0000000000 --- a/maven-plugin/src/main/java/hudson/maven/settings/SettingsProviderUtils.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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 getAllMavenSettingsConfigs() { - return configProvider.getAllMavenSettingsConfigs(); - } - - /** - * @since 1.426 - * @return - */ - public static List 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; - } - -}