diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-01-28 13:16:11 +0300 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-01-28 13:16:11 +0300 |
commit | 1c2189b45f0a81436fcaab886b7072aea77a7d01 (patch) | |
tree | d6ea4464ef3999b6eb9580dddec4c2f805bd2e0f /sonar-batch | |
parent | 9dca07758ff17e8eeca9fa18dd6a0727f26b3bd9 (diff) | |
download | sonarqube-1c2189b45f0a81436fcaab886b7072aea77a7d01.tar.gz sonarqube-1c2189b45f0a81436fcaab886b7072aea77a7d01.zip |
SONAR-2151: Add new property to manage source encoding
Diffstat (limited to 'sonar-batch')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/MavenProjectBuilder.java | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/MavenProjectBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/MavenProjectBuilder.java index d10a4b35516..7fde1c352b7 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/MavenProjectBuilder.java +++ b/sonar-batch/src/main/java/org/sonar/batch/MavenProjectBuilder.java @@ -20,6 +20,7 @@ package org.sonar.batch; import org.apache.commons.configuration.*; +import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.time.DateUtils; import org.apache.maven.project.MavenProject; import org.sonar.api.CoreProperties; @@ -79,18 +80,23 @@ public class MavenProjectBuilder { MavenProject pom = project.getPom(); if (pom != null) { /* - * TODO actually this is a dirty hack to get Java source and target versions from maven-compiler-plugin + * TODO actually this is a dirty hack * See http://jira.codehaus.org/browse/SONAR-2148 - * In fact we should try to get rid of it and use concept of configurator, - * which would be active only in Maven environment - * and would be responsible for setting values from corresponding maven-plugin. + * Get Java source and target versions from maven-compiler-plugin. */ - if (projectConfiguration.getProperty(JavaUtils.JAVA_SOURCE_PROPERTY) == null) { + if (StringUtils.isBlank(projectConfiguration.getString(JavaUtils.JAVA_SOURCE_PROPERTY))) { projectConfiguration.setProperty(JavaUtils.JAVA_SOURCE_PROPERTY, MavenUtils.getJavaSourceVersion(pom)); } - if (projectConfiguration.getProperty(JavaUtils.JAVA_TARGET_PROPERTY) == null) { + if (StringUtils.isBlank(projectConfiguration.getString(JavaUtils.JAVA_TARGET_PROPERTY))) { projectConfiguration.setProperty(JavaUtils.JAVA_TARGET_PROPERTY, MavenUtils.getJavaVersion(pom)); } + /* + * See http://jira.codehaus.org/browse/SONAR-2151 + * Get source encoding from POM + */ + if (StringUtils.isBlank(projectConfiguration.getString(CoreProperties.ENCODING_PROPERTY))) { + projectConfiguration.setProperty(CoreProperties.ENCODING_PROPERTY, MavenUtils.getSourceEncoding(pom)); + } } project.setConfiguration(projectConfiguration) .setExclusionPatterns(loadExclusionPatterns(projectConfiguration)) |