You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by kw...@apache.org on 2025/01/25 11:06:47 UTC
(jackrabbit-filevault-package-maven-plugin) branch bugfix/JCRVLT-777-derive-embedded-dest-file-name-from-artifact-coords created (now 022a83b)
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a change to branch bugfix/JCRVLT-777-derive-embedded-dest-file-name-from-artifact-coords
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault-package-maven-plugin.git
at 022a83b JCRVLT-777 Always derive default destFileName of an embedded file from the Maven coordinates
This branch includes the following new commits:
new 022a83b JCRVLT-777 Always derive default destFileName of an embedded file from the Maven coordinates
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(jackrabbit-filevault-package-maven-plugin) 01/01: JCRVLT-777 Always derive default destFileName of an embedded file from the Maven coordinates
Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch bugfix/JCRVLT-777-derive-embedded-dest-file-name-from-artifact-coords
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault-package-maven-plugin.git
commit 022a83bb021d332edaf9a56e02bba4ab6749edc3
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Sat Jan 25 12:06:35 2025 +0100
JCRVLT-777 Always derive default destFileName of an embedded file from
the Maven coordinates
Disregard any final name settings if the artifact is part of the
reactor.
Throw in case destFileName is set but multiple artifacts match embedded
filter.
---
.../maven/packaging/mojo/GenerateMetadataMojo.java | 31 +++-------------------
.../expected-filter.xml | 2 +-
2 files changed, 4 insertions(+), 29 deletions(-)
diff --git a/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/GenerateMetadataMojo.java b/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/GenerateMetadataMojo.java
index cef79e5..42358b6 100644
--- a/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/GenerateMetadataMojo.java
+++ b/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/GenerateMetadataMojo.java
@@ -1024,7 +1024,7 @@ public class GenerateMetadataMojo extends AbstractMetadataPackageMojo {
}
}
if (emb.getDestFileName() != null && artifacts.size() > 1) {
- getLog().warn("destFileName defined but several artifacts match for " + emb);
+ throw new MojoFailureException("destFileName defined but several artifacts match for " + emb);
}
String targetPath = emb.getTarget();
@@ -1051,34 +1051,9 @@ public class GenerateMetadataMojo extends AbstractMetadataPackageMojo {
final File source = artifact.getFile();
String destFileName = emb.getDestFileName();
- // todo: add support for patterns
if (destFileName == null) {
- // If the <destFileName> param is not specified...
- if (!source.isDirectory()) {
- // If the artifact file is not a directory, defer to File.getName().
- destFileName = source.getName();
- } else {
- // If the dependency file is a directory, the final artifact file has not yet been packaged.
- // Construct a fallback file name from the artifact coordinates.
- final String layoutBaseName = Text.getName(embedArtifactLayout.pathOf(artifact));
- // Look for a peer module in the session that the artifact is attached to.
- final MavenProject peerModule = findModuleForArtifact(artifact);
- if (peerModule != null) {
- // determine the finalName of the artifact, which is ${artifactId}-${version} by default.
- final Artifact attached = peerModule.getArtifact();
- final String defaultFinalName = attached.getArtifactId() + "-" + attached.getVersion();
- final String peerFinalName = peerModule.getBuild().getFinalName();
- if (peerFinalName != null) {
- // remove the default finalName from the beginning of the layout basename, and
- // prepend the specified finalName to create the destFileName.
- destFileName = peerFinalName + layoutBaseName.substring(defaultFinalName.length());
- }
- }
- // If destFileName is still null, fallback to layoutBaseName.
- if (destFileName == null) {
- destFileName = layoutBaseName;
- }
- }
+ // construct final name from artifact coordinates
+ destFileName = Text.getName(embedArtifactLayout.pathOf(artifact));
}
final String targetPathName = targetPath + destFileName;
final String targetNodePathName = targetPathName.substring(Constants.ROOT_DIR.length());
diff --git a/src/test/resources/test-projects/generate-metadata-multimodule/expected-filter.xml b/src/test/resources/test-projects/generate-metadata-multimodule/expected-filter.xml
index f045c99..631ad9d 100644
--- a/src/test/resources/test-projects/generate-metadata-multimodule/expected-filter.xml
+++ b/src/test/resources/test-projects/generate-metadata-multimodule/expected-filter.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
- <filter root="/apps/bundles/install/bundle1.jar"/>
+ <filter root="/apps/bundles/install/package-plugin-test-pkg-bundle1-1.0.0-SNAPSHOT.jar"/>
<filter root="/apps/bundles/install/package-plugin-test-pkg-bundle2-1.0.0-SNAPSHOT.jar"/>
<filter root="/apps/bundles/install/bundle3-core.jar"/>
<filter root="/etc/packages/test/package-plugin-test-pkg-sub1-1.0.0-SNAPSHOT.zip"/>