elharo commented on code in PR #642:
URL: https://github.com/apache/maven-war-plugin/pull/642#discussion_r3668283570
##########
src/main/java/org/apache/maven/plugins/war/AbstractWarMojo.java:
##########
@@ -682,6 +704,47 @@ protected boolean checkAllPathsForOutdated() {
return outdatedCheckPath.equals("/");
}
+ /**
+ * Returns the set of expected target filenames for runtime-scope
artifacts.
+ * Used to avoid marking files placed by other plugins (e.g.,
maven-dependency-plugin)
+ * as outdated and subsequently deleting them (MWAR-443).
+ */
+ private Set<String> getRuntimeArtifactFileNames() {
+ Set<String> fileNames = new HashSet<>();
+ ScopeArtifactFilter filter = new
ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
+ if (project.getArtifacts() != null) {
+ for (Artifact artifact : project.getArtifacts()) {
+ if (!artifact.isOptional()
+ && filter.include(artifact)
+ &&
AbstractWarPackagingTask.isLibraryType(artifact.getType())) {
+ try {
+ String targetFileName;
+ if (getOutputFileNameMapping() != null) {
+ targetFileName =
+
MappingUtils.evaluateFileNameMapping(getOutputFileNameMapping(), artifact);
+ } else {
+ String classifier = artifact.getClassifier();
+ if (classifier != null &&
!classifier.trim().isEmpty()) {
+ targetFileName =
MappingUtils.evaluateFileNameMapping(
+
MappingUtils.DEFAULT_FILE_NAME_MAPPING_CLASSIFIER, artifact);
+ } else {
+ targetFileName =
MappingUtils.evaluateFileNameMapping(
+
MappingUtils.DEFAULT_FILE_NAME_MAPPING, artifact);
+ }
+ }
+ if ("par".equals(artifact.getType())) {
+ targetFileName = targetFileName.substring(0,
targetFileName.lastIndexOf('.')) + ".jar";
+ }
+ fileNames.add(targetFileName);
+ } catch (Exception e) {
Review Comment:
shouldn't need to catch a raw java.lang.Exception here. be more specific
about the exception type
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]