diff --git a/src/main/java/liquibase/sdk/github/GitHubClient.java b/src/main/java/liquibase/sdk/github/GitHubClient.java index d406408..c2d3a79 100644 --- a/src/main/java/liquibase/sdk/github/GitHubClient.java +++ b/src/main/java/liquibase/sdk/github/GitHubClient.java @@ -24,6 +24,10 @@ public class GitHubClient { private final GitHub github; private final Logger log; private final String githubToken; + private static final String CORE_REPOSITORY = "liquibase"; + private static final String CORE_ARTIFACT = "liquibase-core"; + private static final String PRO_REPOSITORY = "liquibase-pro"; + private static final String PRO_ARTIFACT = "liquibase-commercial"; /** * Creates testing client @@ -82,7 +86,7 @@ public String findMatchingBranch(String repo, String... branches) throws IOExcep Map pullRequests = getAllOpenPullRequests(repository); for (String branch : branches) { - branch = this.simplifyBranch(branch); + branch = simplifyBranch(branch); Set branchVariations = new LinkedHashSet<>(); branchVariations.add(branch); @@ -326,10 +330,13 @@ public void setCommitStatus(String repo, String sha1, GHCommitState statusState, repository.createCommitStatus(sha1, statusState, statusUrl, statusDescription, statusContext); } - public Properties getInstalledBuildProperties() throws IOException { - File libraryJar = new File(System.getProperty("user.home") + "/.m2/repository/org/liquibase/liquibase-core/0-SNAPSHOT/liquibase-core-0-SNAPSHOT.jar"); + public Properties getInstalledBuildProperties(String repo) throws IOException { + GHRepository ghRepository = getRepository(repo); + String artifactName = handleArtifactName(ghRepository.getName()); + String m2Location = String.format("/.m2/repository/org/%s/%s/0-SNAPSHOT/%s-0-SNAPSHOT.jar", ghRepository.getOwner().getName(), artifactName, artifactName); + File libraryJar = new File(System.getProperty("user.home") + m2Location); if (!libraryJar.exists()) { - throw new IOException("Could not find jar for liquibase-core at " + libraryJar.getAbsolutePath()); + throw new IOException(String.format("Could not find jar for %s at %s", artifactName, libraryJar.getAbsolutePath())); } try (final FileInputStream fileInputStream = new FileInputStream(libraryJar); @@ -475,4 +482,14 @@ public String getFork() { public enum BuildStatusFilter { SUCCESS; } + + public String handleArtifactName(String repositoryName) { + String artifact = null; + if (repositoryName.equalsIgnoreCase(PRO_REPOSITORY)) { + artifact = PRO_ARTIFACT; + } else if (repositoryName.equalsIgnoreCase(CORE_REPOSITORY)) { + artifact = CORE_ARTIFACT; + } + return artifact != null ? artifact : repositoryName; + } } diff --git a/src/main/java/liquibase/sdk/maven/plugins/GetBuildInfoMojo.java b/src/main/java/liquibase/sdk/maven/plugins/GetBuildInfoMojo.java index f293b8d..b689435 100644 --- a/src/main/java/liquibase/sdk/maven/plugins/GetBuildInfoMojo.java +++ b/src/main/java/liquibase/sdk/maven/plugins/GetBuildInfoMojo.java @@ -26,7 +26,7 @@ public void execute() throws MojoExecutionException { try { GitHubClient github = createGitHubClient(); - final Properties buildInfo = github.getInstalledBuildProperties(); + final Properties buildInfo = github.getInstalledBuildProperties(getRepo()); buildInfo.put("overview", "OSS: " + buildInfo.get("build.branch") + "::" + buildInfo.get("build.commit") + " @ " + buildInfo.get("build.timestamp") + " " + "Pro: " + buildInfo.get("build.pro.branch") + "::" + buildInfo.get("build.pro.commit") + " @ " + buildInfo.get("build.pro.timestamp")) diff --git a/src/main/java/liquibase/sdk/maven/plugins/SetCommitStatusMojo.java b/src/main/java/liquibase/sdk/maven/plugins/SetCommitStatusMojo.java index 5b0b0dc..6316383 100644 --- a/src/main/java/liquibase/sdk/maven/plugins/SetCommitStatusMojo.java +++ b/src/main/java/liquibase/sdk/maven/plugins/SetCommitStatusMojo.java @@ -46,7 +46,7 @@ public void execute() throws MojoExecutionException { String commit; if (StringUtils.trimToNull(statusCommit).equals("installed")) { - final Properties buildInfo = github.getInstalledBuildProperties(); + final Properties buildInfo = github.getInstalledBuildProperties(getRepo()); if (repo.equals("liquibase/liquibase")) { commit = (String) buildInfo.get("build.commit");