|
3 | 3 | import org.apache.maven.artifact.repository.ArtifactRepository; |
4 | 4 | import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; |
5 | 5 | import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; |
| 6 | +import org.apache.maven.model.Repository; |
6 | 7 | import org.apache.maven.plugin.MojoExecutionException; |
7 | 8 | import org.apache.maven.plugin.MojoFailureException; |
8 | 9 | import org.apache.maven.plugins.annotations.Component; |
@@ -87,23 +88,38 @@ public abstract class AbstractGitflowBasedRepositoryMojo extends AbstractGitflow |
87 | 88 | */ |
88 | 89 | protected ArtifactRepository getDeploymentRepository(final String altRepository) throws MojoExecutionException, MojoFailureException { |
89 | 90 | Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher(altRepository); |
| 91 | + Repository candidate = null; |
90 | 92 | if (!matcher.matches()) { |
91 | | - throw new MojoFailureException(altRepository, "Invalid syntax for repository.", |
92 | | - "Invalid syntax for repository. Use \"id::layout::url::unique\"."); |
| 93 | + for (int i = 0; i < project.getRepositories().size(); i++) { |
| 94 | + candidate = project.getRepositories().get(i); |
| 95 | + if (candidate.getId().equals(altRepository)) { |
| 96 | + break; |
| 97 | + } |
| 98 | + candidate = null; |
| 99 | + } |
| 100 | + |
| 101 | + if (candidate == null) { |
| 102 | + throw new MojoFailureException(altRepository, "Invalid syntax for repository or repository id not resolved..", |
| 103 | + "Invalid syntax for repository. Use \"id::layout::url::unique\" or only specify the \"id\"."); |
| 104 | + } |
93 | 105 | } |
94 | 106 |
|
95 | 107 | if (getLog().isDebugEnabled()) { |
96 | 108 | getLog().debug("Getting maven deployment repository (to target artifacts) for: " + altRepository); |
97 | 109 | } |
98 | 110 |
|
99 | | - String id = matcher.group(1).trim(); |
100 | | - String layout = matcher.group(2).trim(); |
101 | | - String url = matcher.group(3).trim(); |
102 | | - boolean unique = Boolean.parseBoolean(matcher.group(4).trim()); |
| 111 | + if (candidate == null) { |
| 112 | + String id = matcher.group(1).trim(); |
| 113 | + String layout = matcher.group(2).trim(); |
| 114 | + String url = matcher.group(3).trim(); |
| 115 | + boolean unique = Boolean.parseBoolean(matcher.group(4).trim()); |
103 | 116 |
|
104 | | - ArtifactRepositoryLayout repoLayout = getLayout(layout); |
| 117 | + ArtifactRepositoryLayout repoLayout = getLayout(layout); |
105 | 118 |
|
106 | | - return repositoryFactory.createDeploymentArtifactRepository(id, url, repoLayout, unique); |
| 119 | + return repositoryFactory.createDeploymentArtifactRepository(id, url, repoLayout, unique); |
| 120 | + } else { |
| 121 | + return repositoryFactory.createDeploymentArtifactRepository(candidate.getId(), candidate.getUrl(), getLayout(candidate.getLayout()), candidate.getSnapshots().isEnabled()); |
| 122 | + } |
107 | 123 | } |
108 | 124 |
|
109 | 125 | /** |
|
0 commit comments