Skip to content

Commit 07948ea

Browse files
authored
[MDEPLOY-320] Simplify and unify message (#64)
This plugin used old ctor for MojoExecutionException that uses "message", "long message" and "source". The source is fully unused in Maven Core, while long message just complicates things. Just unify message, use one "standard" exception message. --- https://issues.apache.org/jira/browse/MDEPLOY-320
1 parent 14cc4c3 commit 07948ea

File tree

2 files changed

+23
-28
lines changed

2 files changed

+23
-28
lines changed

src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java

+5-9
Original file line numberDiff line numberDiff line change
@@ -382,20 +382,16 @@ RemoteRepository getDeploymentRepository(
382382
+ "\" instead.");
383383
repo = getRemoteRepository(id, url);
384384
} else {
385-
throw new MojoExecutionException(
386-
altDeploymentRepo,
387-
"Invalid legacy syntax and layout for repository.",
388-
"Invalid legacy syntax and layout for alternative repository. Use \"" + id + "::" + url
389-
+ "\" instead, and only default layout is supported.");
385+
throw new MojoExecutionException("Invalid legacy syntax and layout for alternative repository: \""
386+
+ altDeploymentRepo + "\". Use \"" + id + "::" + url
387+
+ "\" instead, and only default layout is supported.");
390388
}
391389
} else {
392390
matcher = ALT_REPO_SYNTAX_PATTERN.matcher(altDeploymentRepo);
393391

394392
if (!matcher.matches()) {
395-
throw new MojoExecutionException(
396-
altDeploymentRepo,
397-
"Invalid syntax for repository.",
398-
"Invalid syntax for alternative repository. Use \"id::url\".");
393+
throw new MojoExecutionException("Invalid syntax for alternative repository: \"" + altDeploymentRepo
394+
+ "\". Use \"id::url\".");
399395
} else {
400396
String id = matcher.group(1).trim();
401397
String url = matcher.group(2).trim();

src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java

+18-19
Original file line numberDiff line numberDiff line change
@@ -711,17 +711,18 @@ public void testLegacyAltDeploymentRepositoryWithLegacyLayout() throws Exception
711711

712712
setVariableValueToObject(mojo, "project", project);
713713
setVariableValueToObject(mojo, "session", session);
714-
setVariableValueToObject(mojo, "altDeploymentRepository", "altDeploymentRepository::legacy::http://localhost");
714+
String altDeploymentRepository = "altDeploymentRepository::legacy::http://localhost";
715+
setVariableValueToObject(mojo, "altDeploymentRepository", altDeploymentRepository);
715716

716717
project.setVersion("1.0-SNAPSHOT");
717718
try {
718-
mojo.getDeploymentRepository(project, null, null, "altDeploymentRepository::legacy::http://localhost");
719+
mojo.getDeploymentRepository(project, null, null, altDeploymentRepository);
719720
fail("Should throw: Invalid legacy syntax and layout for repository.");
720721
} catch (MojoExecutionException e) {
721-
assertEquals(e.getMessage(), "Invalid legacy syntax and layout for repository.");
722722
assertEquals(
723-
e.getLongMessage(),
724-
"Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::http://localhost\" instead, and only default layout is supported.");
723+
e.getMessage(),
724+
"Invalid legacy syntax and layout for alternative repository: \"" + altDeploymentRepository
725+
+ "\". Use \"altDeploymentRepository::http://localhost\" instead, and only default layout is supported.");
725726
}
726727
}
727728

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

731732
setVariableValueToObject(mojo, "project", project);
732733
setVariableValueToObject(mojo, "session", session);
733-
setVariableValueToObject(
734-
mojo, "altDeploymentRepository", "altDeploymentRepository::hey::wow::foo::http://localhost");
734+
String altDeploymentRepository = "altDeploymentRepository::hey::wow::foo::http://localhost";
735+
setVariableValueToObject(mojo, "altDeploymentRepository", altDeploymentRepository);
735736

736737
project.setVersion("1.0-SNAPSHOT");
737738
try {
738-
mojo.getDeploymentRepository(
739-
project, null, null, "altDeploymentRepository::hey::wow::foo::http://localhost");
739+
mojo.getDeploymentRepository(project, null, null, altDeploymentRepository);
740740
fail("Should throw: Invalid legacy syntax and layout for repository.");
741741
} catch (MojoExecutionException e) {
742-
assertEquals(e.getMessage(), "Invalid legacy syntax and layout for repository.");
743742
assertEquals(
744-
e.getLongMessage(),
745-
"Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::wow::foo::http://localhost\" instead, and only default layout is supported.");
743+
e.getMessage(),
744+
"Invalid legacy syntax and layout for alternative repository: \"" + altDeploymentRepository
745+
+ "\". Use \"altDeploymentRepository::wow::foo::http://localhost\" instead, and only default layout is supported.");
746746
}
747747
}
748748

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

768768
setVariableValueToObject(mojo, "project", project);
769-
setVariableValueToObject(
770-
mojo, "altDeploymentRepository", "altDeploymentRepository::legacy::scm:svn:http://localhost");
769+
String altDeploymentRepository = "altDeploymentRepository::legacy::scm:svn:http://localhost";
770+
setVariableValueToObject(mojo, "altDeploymentRepository", altDeploymentRepository);
771771

772772
project.setVersion("1.0-SNAPSHOT");
773773
try {
774-
mojo.getDeploymentRepository(
775-
project, null, null, "altDeploymentRepository::legacy::scm:svn:http://localhost");
774+
mojo.getDeploymentRepository(project, null, null, altDeploymentRepository);
776775
fail("Should throw: Invalid legacy syntax and layout for repository.");
777776
} catch (MojoExecutionException e) {
778-
assertEquals(e.getMessage(), "Invalid legacy syntax and layout for repository.");
779777
assertEquals(
780-
e.getLongMessage(),
781-
"Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::scm:svn:http://localhost\" instead, and only default layout is supported.");
778+
e.getMessage(),
779+
"Invalid legacy syntax and layout for alternative repository: \"" + altDeploymentRepository
780+
+ "\". Use \"altDeploymentRepository::scm:svn:http://localhost\" instead, and only default layout is supported.");
782781
}
783782
}
784783

0 commit comments

Comments
 (0)