Maven Release Plugin with custom repository layout, instead of default

96 views Asked by At

I'm trying to set up Maven's Release plugin but my "repository" is just a directory on a Windows network share.

There is a specific path to which the artifact must be copied, and I cannot change this (or use a real repository like Artifactory):

\\server\path\to\smb\share\@{project.version}\@{custom_name}.war

I can't use Maven's default layout, which includes the groupId and artifactId as part of the directory structure (com/my/company/my_team/artifact_id/version/artifact_id-version.war).

How can I make the release:perform goal copy the file to the specified folder, perhaps using the goals optional parameter?

Is there a way to configure an <execution> or <configuration> to do this instead of passing the parameter on the CLI every time?

I don't care about any other files other than the .war, but having the checksums is nice.

The file copying part works, I can find the directory tree and files at the destination.

2

There are 2 answers

0
J Fabian Meier On

I would just use your CI server (like Jenkins, GitLab CI, whatever you use) to copy the file from the target dir to the directory you specified. Maven does not support this. You could also write a Maven plugin to do the task.

0
Mr__Steel On

The maven release plugin might not be the right tool for your use case. If you just want to copy a file, the maven resources plugin might be better suited:

<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <version>3.3.0</version>
    <executions>
        <execution>
            <id>copy-resource-one</id>
            <phase>install</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>

            <configuration>
                <outputDirectory>destination-folder</outputDirectory>
                <resources>
                    <resource>
                        <directory>/target-folder</directory>
                        <includes>
                            <include>file.war</include>
                        </includes>
                    </resource>
                </resources>
            </configuration>
        </execution>
   </executions>
</plugin>