use of jenkins.mvn.GlobalSettingsProvider in project sonar-scanner-jenkins by SonarSource.
the class SonarMaven method executeMaven.
public static boolean executeMaven(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener, String mavenName, String pom, SonarInstallation sonarInstallation, SonarPublisher sonarPublisher, JDK jdk, SettingsProvider settings, GlobalSettingsProvider globalSettings, boolean usesLocalRepository) throws IOException, InterruptedException {
MavenModuleSet mavenModuleProject = sonarPublisher.getMavenProject(build);
EnvVars envVars = build.getEnvironment(listener);
/**
* MAVEN_OPTS
*/
String mvnOptions = sonarPublisher.getMavenOpts();
if (StringUtils.isEmpty(mvnOptions) && mavenModuleProject != null && StringUtils.isNotEmpty(mavenModuleProject.getMavenOpts())) {
mvnOptions = mavenModuleProject.getMavenOpts();
}
// Private Repository and Alternate Settings
LocalRepositoryLocator locaRepositoryToUse = usesLocalRepository ? new PerJobLocalRepositoryLocator() : new DefaultLocalRepositoryLocator();
SettingsProvider settingsToUse = settings;
GlobalSettingsProvider globalSettingsToUse = globalSettings;
if (mavenModuleProject != null) {
// If we are on a Maven job then take values from the job itself
locaRepositoryToUse = mavenModuleProject.getLocalRepository();
settingsToUse = mavenModuleProject.getSettings();
globalSettingsToUse = mavenModuleProject.getGlobalSettings();
}
// Other properties
String additionalArguments = sonarInstallation.getAdditionalProperties();
String analysisProperties = StringUtils.join(sonarInstallation.getAdditionalAnalysisPropertiesUnix(), ' ');
String jobProperties = envVars.expand(sonarPublisher.getJobAdditionalProperties());
String additionalProperties = "" + (StringUtils.isNotBlank(additionalArguments) ? additionalArguments : "") + " " + (StringUtils.isNotBlank(analysisProperties) ? analysisProperties : "") + " " + (StringUtils.isNotBlank(jobProperties) ? jobProperties : "");
// Execute Maven
// SONARPLUGINS-487
String pomPath = build.getModuleRoot().child(pom).getRemote();
return new SonarMaven(additionalProperties, mavenName, pomPath, mvnOptions, locaRepositoryToUse, sonarPublisher, listener, jdk, settingsToUse, globalSettingsToUse).perform(build, launcher, listener);
}
Aggregations