Skip to content

Commit

Permalink
Merge pull request #113 from robth/feature/fix-112-rm-artifact-type-e…
Browse files Browse the repository at this point in the history
…xt-check

Fix #112 by removing artifact type/extension check
  • Loading branch information
bvarner committed Dec 19, 2019
2 parents 1fc2fdf + 066f15e commit 018a658
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
Expand Down
29 changes: 28 additions & 1 deletion src/test/resources/project-stub/pom.xml
Expand Up @@ -6,7 +6,7 @@
<artifactId>gitflow-helper-maven-plugin-test-stub</artifactId>
<version>${stub.project.version}</version>

<packaging>jar</packaging>
<packaging>bundle</packaging>

<repositories>
<repository>
Expand Down Expand Up @@ -91,6 +91,33 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>attach-text-file</id>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>src/build/resources/my-text-file.txt</file>
<type>text-file</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>4.2.0</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>

Expand Down
@@ -0,0 +1 @@
test123

0 comments on commit 018a658

Please sign in to comment.