Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -381,20 +381,16 @@ RemoteRepository getDeploymentRepository(
+ "\" instead.");
repo = getRemoteRepository(id, url);
} else {
throw new MojoExecutionException(
altDeploymentRepo,
"Invalid legacy syntax and layout for repository.",
"Invalid legacy syntax and layout for alternative repository. Use \"" + id + "::" + url
+ "\" instead, and only default layout is supported.");
throw new MojoExecutionException("Invalid legacy syntax and layout for alternative repository: \""
+ altDeploymentRepo + "\". Use \"" + id + "::" + url
+ "\" instead, and only default layout is supported.");
}
} else {
matcher = ALT_REPO_SYNTAX_PATTERN.matcher(altDeploymentRepo);

if (!matcher.matches()) {
throw new MojoExecutionException(
altDeploymentRepo,
"Invalid syntax for repository.",
"Invalid syntax for alternative repository. Use \"id::url\".");
throw new MojoExecutionException("Invalid syntax for alternative repository: \"" + altDeploymentRepo
+ "\". Use \"id::url\".");
} else {
String id = matcher.group(1).trim();
String url = matcher.group(2).trim();
Expand Down
37 changes: 18 additions & 19 deletions src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -711,17 +711,18 @@ public void testLegacyAltDeploymentRepositoryWithLegacyLayout() throws Exception

setVariableValueToObject(mojo, "project", project);
setVariableValueToObject(mojo, "session", session);
setVariableValueToObject(mojo, "altDeploymentRepository", "altDeploymentRepository::legacy::http://localhost");
String altDeploymentRepository = "altDeploymentRepository::legacy::http://localhost";
setVariableValueToObject(mojo, "altDeploymentRepository", altDeploymentRepository);

project.setVersion("1.0-SNAPSHOT");
try {
mojo.getDeploymentRepository(project, null, null, "altDeploymentRepository::legacy::http://localhost");
mojo.getDeploymentRepository(project, null, null, altDeploymentRepository);
fail("Should throw: Invalid legacy syntax and layout for repository.");
} catch (MojoExecutionException e) {
assertEquals(e.getMessage(), "Invalid legacy syntax and layout for repository.");
assertEquals(
e.getLongMessage(),
"Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::http://localhost\" instead, and only default layout is supported.");
e.getMessage(),
"Invalid legacy syntax and layout for alternative repository: \"" + altDeploymentRepository
+ "\". Use \"altDeploymentRepository::http://localhost\" instead, and only default layout is supported.");
}
}

Expand All @@ -730,19 +731,18 @@ public void testInsaneAltDeploymentRepository() throws Exception {

setVariableValueToObject(mojo, "project", project);
setVariableValueToObject(mojo, "session", session);
setVariableValueToObject(
mojo, "altDeploymentRepository", "altDeploymentRepository::hey::wow::foo::http://localhost");
String altDeploymentRepository = "altDeploymentRepository::hey::wow::foo::http://localhost";
setVariableValueToObject(mojo, "altDeploymentRepository", altDeploymentRepository);

project.setVersion("1.0-SNAPSHOT");
try {
mojo.getDeploymentRepository(
project, null, null, "altDeploymentRepository::hey::wow::foo::http://localhost");
mojo.getDeploymentRepository(project, null, null, altDeploymentRepository);
fail("Should throw: Invalid legacy syntax and layout for repository.");
} catch (MojoExecutionException e) {
assertEquals(e.getMessage(), "Invalid legacy syntax and layout for repository.");
assertEquals(
e.getLongMessage(),
"Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::wow::foo::http://localhost\" instead, and only default layout is supported.");
e.getMessage(),
"Invalid legacy syntax and layout for alternative repository: \"" + altDeploymentRepository
+ "\". Use \"altDeploymentRepository::wow::foo::http://localhost\" instead, and only default layout is supported.");
}
}

Expand All @@ -766,19 +766,18 @@ public void testLegacyScmSvnAltDeploymentRepository() throws Exception {
mojo = new DeployMojo();

setVariableValueToObject(mojo, "project", project);
setVariableValueToObject(
mojo, "altDeploymentRepository", "altDeploymentRepository::legacy::scm:svn:http://localhost");
String altDeploymentRepository = "altDeploymentRepository::legacy::scm:svn:http://localhost";
setVariableValueToObject(mojo, "altDeploymentRepository", altDeploymentRepository);

project.setVersion("1.0-SNAPSHOT");
try {
mojo.getDeploymentRepository(
project, null, null, "altDeploymentRepository::legacy::scm:svn:http://localhost");
mojo.getDeploymentRepository(project, null, null, altDeploymentRepository);
fail("Should throw: Invalid legacy syntax and layout for repository.");
} catch (MojoExecutionException e) {
assertEquals(e.getMessage(), "Invalid legacy syntax and layout for repository.");
assertEquals(
e.getLongMessage(),
"Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::scm:svn:http://localhost\" instead, and only default layout is supported.");
e.getMessage(),
"Invalid legacy syntax and layout for alternative repository: \"" + altDeploymentRepository
+ "\". Use \"altDeploymentRepository::scm:svn:http://localhost\" instead, and only default layout is supported.");
}
}

Expand Down