Skip to content

Commit

Permalink
[MDEPLOY-320] Simplify and unify message
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cstamas committed Aug 15, 2024
1 parent 14cc4c3 commit 0130bf0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/it/gav-validation/invoker.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
invoker.goals = org.apache.maven.plugins:maven-deploy-plugin:${project.version}:deploy-file
invoker.buildResult = failure

invoker.systemPropertiesFile.1 = test-invalid.properties
invoker.systemPropertiesFile.2 = test-missing.properties
invoker.userPropertiesFile.1 = test-invalid.properties
invoker.userPropertiesFile.2 = test-missing.properties
Original file line number Diff line number Diff line change
Expand Up @@ -383,19 +383,14 @@ RemoteRepository getDeploymentRepository(
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.");
}
} 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. Use \"id::url\".");
} else {
String id = matcher.group(1).trim();
String url = matcher.group(2).trim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,8 @@ public void testLegacyAltDeploymentRepositoryWithLegacyLayout() throws Exception
mojo.getDeploymentRepository(project, null, null, "altDeploymentRepository::legacy::http://localhost");
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(),
e.getMessage(),
"Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::http://localhost\" instead, and only default layout is supported.");
}
}
Expand All @@ -739,9 +738,8 @@ public void testInsaneAltDeploymentRepository() throws Exception {
project, null, null, "altDeploymentRepository::hey::wow::foo::http://localhost");
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(),
e.getMessage(),
"Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::wow::foo::http://localhost\" instead, and only default layout is supported.");
}
}
Expand Down Expand Up @@ -775,9 +773,8 @@ public void testLegacyScmSvnAltDeploymentRepository() throws Exception {
project, null, null, "altDeploymentRepository::legacy::scm:svn:http://localhost");
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(),
e.getMessage(),
"Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::scm:svn:http://localhost\" instead, and only default layout is supported.");
}
}
Expand Down

0 comments on commit 0130bf0

Please sign in to comment.