Search in sources :

Example 1 with GlobalMavenConfig

use of jenkins.mvn.GlobalMavenConfig in project configuration-as-code-plugin by jenkinsci.

the class MavenConfiguratorTest method configure_maven_global_config_specific_files.

@Test
@ConfiguredWithReadme("maven/README.md#2")
public void configure_maven_global_config_specific_files() {
    final GlobalMavenConfig descriptor = ExtensionList.lookupSingleton(GlobalMavenConfig.class);
    assertThat(descriptor.getGlobalSettingsProvider(), instanceOf(FilePathGlobalSettingsProvider.class));
    FilePathGlobalSettingsProvider globalProvider = (FilePathGlobalSettingsProvider) descriptor.getGlobalSettingsProvider();
    assertThat(globalProvider.getPath(), is("/conf/maven/global-settings.xml"));
    assertThat(descriptor.getSettingsProvider(), instanceOf(FilePathSettingsProvider.class));
    FilePathSettingsProvider provider = (FilePathSettingsProvider) descriptor.getSettingsProvider();
    assertThat(provider.getPath(), is("/conf/maven/settings.xml"));
}
Also used : GlobalMavenConfig(jenkins.mvn.GlobalMavenConfig) FilePathGlobalSettingsProvider(jenkins.mvn.FilePathGlobalSettingsProvider) FilePathSettingsProvider(jenkins.mvn.FilePathSettingsProvider) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 2 with GlobalMavenConfig

use of jenkins.mvn.GlobalMavenConfig in project configuration-as-code-plugin by jenkinsci.

the class MavenConfiguratorTest method configure_maven_global_config.

@Test
@ConfiguredWithReadme("maven/README.md#1")
public void configure_maven_global_config() {
    final GlobalMavenConfig descriptor = ExtensionList.lookupSingleton(GlobalMavenConfig.class);
    assertThat(descriptor.getGlobalSettingsProvider(), instanceOf(DefaultGlobalSettingsProvider.class));
    assertThat(descriptor.getSettingsProvider(), instanceOf(DefaultSettingsProvider.class));
}
Also used : GlobalMavenConfig(jenkins.mvn.GlobalMavenConfig) DefaultGlobalSettingsProvider(jenkins.mvn.DefaultGlobalSettingsProvider) DefaultSettingsProvider(jenkins.mvn.DefaultSettingsProvider) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 3 with GlobalMavenConfig

use of jenkins.mvn.GlobalMavenConfig in project configuration-as-code-plugin by jenkinsci.

the class MavenConfigurator method describe.

@NonNull
@Override
public Set<Attribute<GlobalMavenConfig, ?>> describe() {
    final Set<Attribute<GlobalMavenConfig, ?>> attributes = super.describe();
    final Descriptor descriptor = Jenkins.get().getDescriptorOrDie(Maven.class);
    final Configurator<Descriptor> task = new DescriptorConfigurator(descriptor);
    for (Attribute attribute : task.describe()) {
        attributes.add(new Attribute<GlobalMavenConfig, Object>(attribute.getName(), attribute.getType()).multiple(attribute.isMultiple()).getter(g -> attribute.getValue(descriptor)).setter((g, v) -> attribute.setValue(descriptor, v)));
    }
    return attributes;
}
Also used : Restricted(org.kohsuke.accmod.Restricted) Maven(hudson.tasks.Maven) Descriptor(hudson.model.Descriptor) ConfigurationContext(io.jenkins.plugins.casc.ConfigurationContext) Jenkins(jenkins.model.Jenkins) Configurator(io.jenkins.plugins.casc.Configurator) Set(java.util.Set) GlobalMavenConfig(jenkins.mvn.GlobalMavenConfig) NoExternalUse(org.kohsuke.accmod.restrictions.NoExternalUse) CNode(io.jenkins.plugins.casc.model.CNode) Mapping(io.jenkins.plugins.casc.model.Mapping) BaseConfigurator(io.jenkins.plugins.casc.BaseConfigurator) DescriptorConfigurator(io.jenkins.plugins.casc.impl.configurators.DescriptorConfigurator) NonNull(edu.umd.cs.findbugs.annotations.NonNull) Attribute(io.jenkins.plugins.casc.Attribute) Extension(hudson.Extension) CheckForNull(edu.umd.cs.findbugs.annotations.CheckForNull) GlobalConfiguration(jenkins.model.GlobalConfiguration) Attribute(io.jenkins.plugins.casc.Attribute) DescriptorConfigurator(io.jenkins.plugins.casc.impl.configurators.DescriptorConfigurator) Descriptor(hudson.model.Descriptor) NonNull(edu.umd.cs.findbugs.annotations.NonNull)

Aggregations

GlobalMavenConfig (jenkins.mvn.GlobalMavenConfig)3 ConfiguredWithReadme (io.jenkins.plugins.casc.misc.ConfiguredWithReadme)2 Test (org.junit.Test)2 CheckForNull (edu.umd.cs.findbugs.annotations.CheckForNull)1 NonNull (edu.umd.cs.findbugs.annotations.NonNull)1 Extension (hudson.Extension)1 Descriptor (hudson.model.Descriptor)1 Maven (hudson.tasks.Maven)1 Attribute (io.jenkins.plugins.casc.Attribute)1 BaseConfigurator (io.jenkins.plugins.casc.BaseConfigurator)1 ConfigurationContext (io.jenkins.plugins.casc.ConfigurationContext)1 Configurator (io.jenkins.plugins.casc.Configurator)1 DescriptorConfigurator (io.jenkins.plugins.casc.impl.configurators.DescriptorConfigurator)1 CNode (io.jenkins.plugins.casc.model.CNode)1 Mapping (io.jenkins.plugins.casc.model.Mapping)1 Set (java.util.Set)1 GlobalConfiguration (jenkins.model.GlobalConfiguration)1 Jenkins (jenkins.model.Jenkins)1 DefaultGlobalSettingsProvider (jenkins.mvn.DefaultGlobalSettingsProvider)1 DefaultSettingsProvider (jenkins.mvn.DefaultSettingsProvider)1