From 066f15e1ee0e0475c07e631f8dd30692b279167a Mon Sep 17 00:00:00 2001 From: Rob ten Hove Date: Wed, 10 Jul 2019 17:02:52 +0200 Subject: [PATCH] Fix #112. Remove check for artifact type/extension match, as the extension as defined by the ArtifactHandler should always prevail. --- .../DefaultGavCoordinateHelper.java | 18 ++---------- src/test/resources/project-stub/pom.xml | 29 ++++++++++++++++++- .../src/build/resources/my-text-file.txt | 1 + 3 files changed, 31 insertions(+), 17 deletions(-) create mode 100644 src/test/resources/project-stub/src/build/resources/my-text-file.txt diff --git a/src/main/java/com/e_gineering/maven/gitflowhelper/DefaultGavCoordinateHelper.java b/src/main/java/com/e_gineering/maven/gitflowhelper/DefaultGavCoordinateHelper.java index ae9c75c..cf040c8 100644 --- a/src/main/java/com/e_gineering/maven/gitflowhelper/DefaultGavCoordinateHelper.java +++ b/src/main/java/com/e_gineering/maven/gitflowhelper/DefaultGavCoordinateHelper.java @@ -2,6 +2,7 @@ import com.google.common.base.Joiner; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.logging.Logger; import org.eclipse.aether.RepositorySystemSession; @@ -59,22 +60,7 @@ public String getCoordinates(Artifact artifact) { log.debug(" Encoding Coordinates For: " + artifact); // Get the extension according to the artifact type. - String extension = session.getArtifactTypeRegistry().get(artifact.getType()).getExtension(); - - // assert that the file extension matches the artifact packaging extension type, if there is an artifact file. - if (artifact.getFile() != null && !artifact.getFile().getName().toLowerCase().endsWith(extension.toLowerCase())) { - String filename = artifact.getFile().getName(); - String fileExtension = filename.substring(filename.lastIndexOf('.') + 1); - log.warn( - " Artifact file name: " + artifact.getFile().getName() + " of type " - + artifact.getType() + " does not match the extension for the ArtifactType: " - + extension + ". " - + "This is likely an issue with the packaging definition for '" + artifact.getType() - + "' artifacts, which may be missing an extension definition. " - + "The gitflow helper catalog will use the actual file extension: " + fileExtension - ); - extension = fileExtension; - } + String extension = artifact.getArtifactHandler().getExtension(); return getCoordinates( artifact.getGroupId(), diff --git a/src/test/resources/project-stub/pom.xml b/src/test/resources/project-stub/pom.xml index 5a47f8a..e31411f 100644 --- a/src/test/resources/project-stub/pom.xml +++ b/src/test/resources/project-stub/pom.xml @@ -6,7 +6,7 @@ gitflow-helper-maven-plugin-test-stub ${stub.project.version} - jar + bundle @@ -91,6 +91,33 @@ + + org.codehaus.mojo + build-helper-maven-plugin + 3.0.0 + + + attach-text-file + + attach-artifact + + + + + src/build/resources/my-text-file.txt + text-file + + + + + + + + org.apache.felix + maven-bundle-plugin + 4.2.0 + true + diff --git a/src/test/resources/project-stub/src/build/resources/my-text-file.txt b/src/test/resources/project-stub/src/build/resources/my-text-file.txt new file mode 100644 index 0000000..0c759a4 --- /dev/null +++ b/src/test/resources/project-stub/src/build/resources/my-text-file.txt @@ -0,0 +1 @@ +test123 \ No newline at end of file