Skip to content

Commit 1a03854

Browse files
authored
Merge pull request #46 from egineering-llc/hotfix/1.5.1
Hotfix/1.5.1
2 parents 8888dc7 + 4d909fe commit 1a03854

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<groupId>com.e-gineering</groupId>
1010
<artifactId>gitflow-helper-maven-plugin</artifactId>
1111

12-
<version>1.5.0</version>
12+
<version>1.5.1</version>
1313
<packaging>maven-plugin</packaging>
1414

1515
<name>gitflow-helper-maven-plugin</name>
@@ -104,6 +104,11 @@
104104
<version>3.1.0</version>
105105
<scope>provided</scope>
106106
</dependency>
107+
<dependency>
108+
<groupId>org.eclipse.aether</groupId>
109+
<artifactId>aether-util</artifactId>
110+
<version>0.9.0.M2</version>
111+
</dependency>
107112
<dependency>
108113
<groupId>junit</groupId>
109114
<artifactId>junit</artifactId>

src/main/java/com/e_gineering/maven/gitflowhelper/AbstractGitflowBasedRepositoryMojo.java

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.eclipse.aether.resolution.ArtifactRequest;
1818
import org.eclipse.aether.resolution.ArtifactResolutionException;
1919
import org.eclipse.aether.resolution.ArtifactResult;
20+
import org.eclipse.aether.util.repository.AuthenticationBuilder;
2021

2122
import java.io.BufferedReader;
2223
import java.io.File;
@@ -86,6 +87,10 @@ protected ArtifactRepository getDeploymentRepository(final String altRepository)
8687
"Invalid syntax for repository. Use \"id::layout::url::unique\".");
8788
}
8889

90+
if (getLog().isDebugEnabled()) {
91+
getLog().debug("Getting maven deployment repository (to target artifacts) for: " + altRepository);
92+
}
93+
8994
String id = matcher.group(1).trim();
9095
String layout = matcher.group(2).trim();
9196
String url = matcher.group(3).trim();
@@ -105,20 +110,30 @@ protected ArtifactRepository getDeploymentRepository(final String altRepository)
105110
* @throws MojoFailureException
106111
*/
107112
private RemoteRepository getRepository(final String altRepository) throws MojoExecutionException, MojoFailureException {
108-
Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher(altRepository);
109-
if (!matcher.matches()) {
110-
throw new MojoFailureException(altRepository, "Invalid syntax for repository.",
111-
"Invalid syntax for repository. Use \"id::layout::url::unique\".");
113+
if (getLog().isDebugEnabled()) {
114+
getLog().debug("Creating remote Aether repository (to resolve remote artifacts) for: " + altRepository);
112115
}
116+
// Get an appropriate injected ArtifactRepository. (This resolves authentication in the 'normal' manner from Maven)
117+
ArtifactRepository remoteArtifactRepo = getDeploymentRepository(altRepository);
113118

114-
String id = matcher.group(1).trim();
115-
String layout = matcher.group(2).trim();
116-
String url = matcher.group(3).trim();
117-
boolean unique = Boolean.parseBoolean(matcher.group(4).trim());
119+
if (getLog().isDebugEnabled()) {
120+
getLog().debug("Resolved maven deployment repository. Transcribing to Aether Repository...");
121+
}
118122

119-
ArtifactRepositoryLayout repoLayout = getLayout(layout);
123+
RemoteRepository.Builder remoteRepoBuilder = new RemoteRepository.Builder(remoteArtifactRepo.getId(), remoteArtifactRepo.getLayout().getId(), remoteArtifactRepo.getUrl());
124+
125+
// Add authentication.
126+
if (remoteArtifactRepo.getAuthentication() != null) {
127+
if (getLog().isDebugEnabled()) {
128+
getLog().debug("Maven deployment repsoitory has Authentication. Transcribing to Aether Authentication...");
129+
}
130+
remoteRepoBuilder.setAuthentication(new AuthenticationBuilder().addUsername(remoteArtifactRepo.getAuthentication().getUsername())
131+
.addPassword(remoteArtifactRepo.getAuthentication().getPassword())
132+
.addPrivateKey(remoteArtifactRepo.getAuthentication().getPrivateKey(), remoteArtifactRepo.getAuthentication().getPassphrase())
133+
.build());
134+
}
120135

121-
return new RemoteRepository.Builder(id, layout, url).build();
136+
return remoteRepoBuilder.build();
122137
}
123138

124139
private String getCoordinates(ArtifactResult result) {

0 commit comments

Comments
 (0)