0

After a deep research on internet I haven't found the option to install a new artifact into a Maven repository without a file extension.

Up to version 2.5.2 of the Maven Install Plugin it would just get the "packaging" as the artifact file extension, but then I found this on the Apache issues portal: https://issues.apache.org/jira/browse/MINSTALL-121. It actually makes a lot of sense not to use the "packaging" as the file extension, but then I thought I could probably install a new artifact without any extension as my aftifact is actually a binary executable file, and the following is what I got.

I'm generating a file with the following name in my POM file:

<resultFolder>${project.build.directory}${file.separator}bin${file.separator}mac</resultFolder>
<resultName>${project.build.finalName}</resultName>

This file is basically:

/Users/rafaelruizpalacios/go/src/github.com/MidVision/rd/go/bin/mac/rdcli-1.2-SNAPSHOT

Then I have the following in my POM file to install the file into the repository:

<execution>
    <id>install-mac</id>
    <phase>install</phase>
    <goals>
        <goal>install-file</goal>
    </goals>
    <configuration>
        <file>${project.build.directory}${file.separator}bin${file.separator}mac${file.separator}${project.build.finalName}</file>
        <groupId>${project.groupId}</groupId>
        <artifactId>${project.artifactId}-mac</artifactId>
        <version>${project.version}</version>
        <packaging>bin</packaging>
    </configuration>
</execution>

With the version 2.5.2 of the Maven Install Plugin I would get the file:

/Users/rafaelruizpalacios/.m2/repository/com/midvision/plugins/rdcli-mac/1.2-SNAPSHOT/rdcli-mac-1.2-SNAPSHOT.bin

With the "bin" extension, but now that I'm trying to use the latest version 3.0.1, and considering MINSTALL-121, what I get is:

/Users/rafaelruizpalacios/.m2/repository/com/midvision/plugins/rdcli-mac/1.2-SNAPSHOT/rdcli-mac-1.2-SNAPSHOT.2-SNAPSHOT

It is basically getting the substring after the last dot of the file name, "2-SNAPSHOT", as the file extension.

My question is then: is it just not feasible or recommendable to install artifacts without file extension or is this possibly another issue in the plugin?

Thanks! :-)

1 Answers1

0

Generally a maven repository is not meant to contain arbitrary files - in particular not random binary files. If you really need that, put those files in the resources folder of a maven project (src/main/resources). If that is too limiting for you configure a folder in your pom.xml

<project>
   ...
   <resources>
     <resource>
       <directory>src/my-resources</directory>
     </resource>
   </resources>
   ...
</project>

(from https://maven.apache.org/plugins/maven-resources-plugin/examples/resource-directory.html)

If you want to go down the file road build-helper:attach-artifact should be able to achieve what you want (see also: Deploy maven tar.gz artifact as build output without assembly plugin)

Eisenknurr
  • 374
  • 1
  • 13
  • Hi Eisenknurr, thanks for your answer, but I probably didn't explain myself well, the binary file is not a random file I want to include into the repository folder, it is in fact the resulting file of the build, what I want to know is if I can install this file into the repository without a file extension. Right now I couldn't achieve this but I don't know if this is just a not recommended practice anyway. Thanks! – Rafael Ruiz Palacios Sep 19 '22 at 10:52