Search in sources :

Example 1 with Maven

use of hudson.tasks.Maven in project sonar-scanner-jenkins by SonarSource.

the class SonarTestCase method configureDefaultMaven.

/**
 * Returns Fake Maven Installation.
 *
 * @return Fake Maven Installation
 * @throws Exception if something is wrong
 */
protected Maven.MavenInstallation configureDefaultMaven() throws Exception {
    File mvn = new File(getClass().getResource("SonarTestCase/maven/bin/mvn").toURI().getPath());
    if (!Functions.isWindows()) {
        // noinspection OctalInteger
        GNUCLibrary.LIBC.chmod(mvn.getPath(), 0755);
    }
    String home = mvn.getParentFile().getParentFile().getAbsolutePath();
    Maven.MavenInstallation mavenInstallation = new Maven.MavenInstallation("default", home, JenkinsRule.NO_PROPERTIES);
    j.jenkins.getDescriptorByType(Maven.DescriptorImpl.class).setInstallations(mavenInstallation);
    return mavenInstallation;
}
Also used : Maven(hudson.tasks.Maven) File(java.io.File)

Example 2 with Maven

use of hudson.tasks.Maven in project configuration-as-code-plugin by jenkinsci.

the class MavenConfiguratorTest method configure_maven_tool.

@Test
@ConfiguredWithReadme("maven/README.md#0")
public void configure_maven_tool() {
    final Maven.DescriptorImpl descriptor = ExtensionList.lookupSingleton(Maven.DescriptorImpl.class);
    assertEquals(1, descriptor.getInstallations().length);
    Maven.MavenInstallation maven = descriptor.getInstallations()[0];
    assertEquals("maven3", maven.getName());
    assertEquals("/maven3", maven.getHome());
    InstallSourceProperty installSourceProperty = maven.getProperties().get(InstallSourceProperty.class);
    assertEquals(1, installSourceProperty.installers.size());
    MavenInstaller installer = installSourceProperty.installers.get(MavenInstaller.class);
    assertEquals("3.8.4", installer.id);
}
Also used : Maven(hudson.tasks.Maven) InstallSourceProperty(hudson.tools.InstallSourceProperty) MavenInstaller(hudson.tasks.Maven.MavenInstaller) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 3 with Maven

use of hudson.tasks.Maven in project configuration-as-code-plugin by jenkinsci.

the class MavenConfiguratorTest method should_configure_maven_tools_and_global_config.

@Test
@ConfiguredWithCode("MavenConfiguratorTest.yml")
public void should_configure_maven_tools_and_global_config() {
    final Maven.DescriptorImpl descriptor = (Maven.DescriptorImpl) j.jenkins.getDescriptorOrDie(Maven.class);
    Assert.assertEquals(1, descriptor.getInstallations().length);
    Assert.assertEquals("/usr/share/maven", descriptor.getInstallations()[0].getHome());
    InstallSourceProperty installSourceProperty = descriptor.getInstallations()[0].getProperties().get(InstallSourceProperty.class);
    Assert.assertEquals("3.5.0", installSourceProperty.installers.get(Maven.MavenInstaller.class).id);
    final SettingsProvider provider = GlobalMavenConfig.get().getSettingsProvider();
    Assert.assertTrue(provider instanceof FilePathSettingsProvider);
    Assert.assertEquals("/usr/share/maven-settings.xml", ((FilePathSettingsProvider) provider).getPath());
}
Also used : SettingsProvider(jenkins.mvn.SettingsProvider) FilePathSettingsProvider(jenkins.mvn.FilePathSettingsProvider) Maven(hudson.tasks.Maven) InstallSourceProperty(hudson.tools.InstallSourceProperty) FilePathSettingsProvider(jenkins.mvn.FilePathSettingsProvider) Test(org.junit.Test) ConfiguredWithCode(io.jenkins.plugins.casc.misc.ConfiguredWithCode)

Aggregations

Maven (hudson.tasks.Maven)3 InstallSourceProperty (hudson.tools.InstallSourceProperty)2 Test (org.junit.Test)2 MavenInstaller (hudson.tasks.Maven.MavenInstaller)1 ConfiguredWithCode (io.jenkins.plugins.casc.misc.ConfiguredWithCode)1 ConfiguredWithReadme (io.jenkins.plugins.casc.misc.ConfiguredWithReadme)1 File (java.io.File)1 FilePathSettingsProvider (jenkins.mvn.FilePathSettingsProvider)1 SettingsProvider (jenkins.mvn.SettingsProvider)1