diff options
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/resources/Library.java | 4 | ||||
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Library.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Library.java index 785937126fc..da5cc35681b 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Library.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Library.java @@ -87,6 +87,10 @@ public final class Library extends Resource { return false; } + public static Library createFromMavenIds(String groupId, String artifactId, String version) { + return new Library(String.format(Project.MAVEN_KEY_FORMAT, groupId, artifactId), version); + } + @Override public boolean equals(Object o) { if (this == o) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java index 65f6dc39d45..bc866693f9b 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java @@ -26,6 +26,8 @@ import org.sonar.api.CoreProperties; import org.sonar.api.component.Component; import org.sonar.api.config.Settings; +import javax.annotation.Nullable; + import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -47,7 +49,7 @@ public class Project extends Resource implements Component { } }; - private static final String MAVEN_KEY_FORMAT = "%s:%s"; + static final String MAVEN_KEY_FORMAT = "%s:%s"; private static final String BRANCH_KEY_FORMAT = "%s:%s"; public static final String SCOPE = Scopes.PROJECT; @@ -414,7 +416,11 @@ public class Project extends Resource implements Component { } public static Project createFromMavenIds(String groupId, String artifactId) { - return new Project(String.format(MAVEN_KEY_FORMAT, groupId, artifactId)); + return createFromMavenIds(groupId, artifactId, null); + } + + public static Project createFromMavenIds(String groupId, String artifactId, @Nullable String branch) { + return new Project(String.format(MAVEN_KEY_FORMAT, groupId, artifactId), branch, ""); } @Override |