aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2019-01-16 14:19:36 +0100
committersonartech <sonartech@sonarsource.com>2019-02-11 09:11:46 +0100
commit47ebff25c379b9162943121a49278553967f2dfe (patch)
tree4d5bf3e095021ce397261f97c5d9113c76225bc9 /sonar-plugin-api
parent3373e5778af7c9e5b02aa23b07c7c2c8592e5da5 (diff)
downloadsonarqube-47ebff25c379b9162943121a49278553967f2dfe.tar.gz
sonarqube-47ebff25c379b9162943121a49278553967f2dfe.zip
SONAR-11631 replace Component.version by Metadata.projectVersion
in scanner report
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java23
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/AbstractProjectOrModule.java13
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectBuilderTest.java2
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectDefinitionTest.java4
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputProjectTest.java7
5 files changed, 24 insertions, 25 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
index a846b206bc1..cad32b8d980 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
@@ -48,8 +48,6 @@ public class ProjectDefinition {
public static final String TESTS_PROPERTY = "sonar.tests";
- public static final String BUILD_DIR_PROPERTY = "sonar.buildDir";
-
private static final char SEPARATOR = ',';
private File baseDir;
@@ -149,7 +147,7 @@ public class ProjectDefinition {
return this;
}
- public ProjectDefinition setVersion(String s) {
+ public ProjectDefinition setProjectVersion(String s) {
properties.put(CoreProperties.PROJECT_VERSION_PROPERTY, StringUtils.defaultString(s));
return this;
}
@@ -191,12 +189,29 @@ public class ProjectDefinition {
return null;
}
+ /**
+ * @deprecated since 7.7, use {@link #getOriginalProjectVersion()} instead
+ */
+ @Deprecated
@CheckForNull
public String getOriginalVersion() {
- return properties.get(CoreProperties.PROJECT_VERSION_PROPERTY);
+ return getOriginalProjectVersion();
}
+ /**
+ * @deprecated since 7.7, use {@link #getProjectVersion()} instead
+ */
+ @Deprecated
public String getVersion() {
+ return getProjectVersion();
+ }
+
+ @CheckForNull
+ public String getOriginalProjectVersion() {
+ return properties.get(CoreProperties.PROJECT_VERSION_PROPERTY);
+ }
+
+ public String getProjectVersion() {
String version = properties.get(CoreProperties.PROJECT_VERSION_PROPERTY);
if (StringUtils.isBlank(version)) {
version = "not provided";
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/AbstractProjectOrModule.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/AbstractProjectOrModule.java
index 8bdb040b0f0..caae97c3494 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/AbstractProjectOrModule.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/AbstractProjectOrModule.java
@@ -43,9 +43,7 @@ public abstract class AbstractProjectOrModule extends DefaultInputComponent {
private final Path baseDir;
private final Path workDir;
private final String name;
- private final String version;
private final String originalName;
- private final String originalVersion;
private final String description;
private final String keyWithBranch;
private final String branch;
@@ -61,8 +59,6 @@ public abstract class AbstractProjectOrModule extends DefaultInputComponent {
this.workDir = initWorkingDir(definition);
this.name = definition.getName();
this.originalName = definition.getOriginalName();
- this.version = definition.getVersion();
- this.originalVersion = definition.getOriginalVersion();
this.description = definition.getDescription();
this.keyWithBranch = definition.getKeyWithBranch();
this.branch = definition.getBranch();
@@ -146,15 +142,6 @@ public abstract class AbstractProjectOrModule extends DefaultInputComponent {
}
@CheckForNull
- public String getOriginalVersion() {
- return originalVersion;
- }
-
- public String getVersion() {
- return version;
- }
-
- @CheckForNull
public String getOriginalName() {
return originalName;
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectBuilderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectBuilderTest.java
index 2272df4a304..48f3746bd35 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectBuilderTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectBuilderTest.java
@@ -66,7 +66,7 @@ public class ProjectBuilderTest {
subProject.setBaseDir(baseDir);
subProject.setWorkDir(new File(baseDir, "target/.sonar"));
subProject.setKey("groupId:parentProjectId");
- subProject.setVersion(root.getOriginalVersion());
+ subProject.setProjectVersion(root.getOriginalVersion());
subProject.setName("Sub Project");
subProject.setSources("src");
root.addSubProject(subProject);
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectDefinitionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectDefinitionTest.java
index 7120ff49d47..a69dad61ada 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectDefinitionTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectDefinitionTest.java
@@ -37,14 +37,14 @@ public class ProjectDefinitionTest {
@Test
public void shouldSetVersion() {
ProjectDefinition def = ProjectDefinition.create();
- def.setVersion("2.0-SNAPSHOT");
+ def.setProjectVersion("2.0-SNAPSHOT");
assertThat(def.getVersion()).isEqualTo("2.0-SNAPSHOT");
}
@Test
public void shouldSupportNoVersion() {
ProjectDefinition def = ProjectDefinition.create();
- def.setVersion(null);
+ def.setProjectVersion(null);
assertThat(def.getVersion()).isEqualTo("not provided");
assertThat(def.getOriginalVersion()).isEqualTo("");
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputProjectTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputProjectTest.java
index 33751cd6151..8a4a33bdce3 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputProjectTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputProjectTest.java
@@ -42,7 +42,6 @@ public class DefaultInputProjectTest {
def.setName("projectName");
File baseDir = temp.newFolder();
def.setBaseDir(baseDir);
- def.setVersion("version");
def.setDescription("desc");
File workDir = temp.newFolder();
def.setWorkDir(workDir);
@@ -57,13 +56,11 @@ public class DefaultInputProjectTest {
assertThat(project.getBranch()).isNull();
assertThat(project.getBaseDir()).isEqualTo(baseDir.toPath());
assertThat(project.getKeyWithBranch()).isEqualTo("projectKey");
- assertThat(project.getVersion()).isEqualTo("version");
- assertThat(project.getOriginalVersion()).isEqualTo("version");
assertThat(project.getDescription()).isEqualTo("desc");
assertThat(project.getWorkDir()).isEqualTo(workDir.toPath());
assertThat(project.getEncoding()).isEqualTo(Charset.defaultCharset());
- assertThat(project.properties()).hasSize(6);
+ assertThat(project.properties()).hasSize(5);
assertThat(project.isFile()).isFalse();
}
@@ -75,7 +72,7 @@ public class DefaultInputProjectTest {
def.setName("projectName");
File baseDir = temp.newFolder();
def.setBaseDir(baseDir);
- def.setVersion("version");
+ def.setProjectVersion("version");
def.setDescription("desc");
File workDir = temp.newFolder();
def.setWorkDir(workDir);