Pretty much what the title says. I'm building Minecraft Spigot plugins for servers running under BungeeCord and running the mvn package plugin in IntelliJ results in the generated JAR file being located in the project's "target" folder. Instead, I need to output multiple copies of the generated JAR into multiple "plugin" folders for various servers. I'm not sure how or if this is possible to do with Maven, but I would like to know if there is a way to do that in pom.xml. Having to copy the JAR every time I build it slows down the development process. Any help would be greatly appreciated!
-
Does this answer your question? [Maven: how to copy artifact to specific directory?](https://stackoverflow.com/questions/7063475/maven-how-to-copy-artifact-to-specific-directory) – tgdavies Dec 29 '20 at 00:50
-
Re "_multiple copies_ [...] _into multiple "plugin" folders for various servers_" – Is this a local copy or an upload to the servers? – Gerold Broser Dec 29 '20 at 02:47
-
Maven is a build tool not a deployment tool... Write a scripte to copy/deploy the resulting artifacts... – khmarbaise Dec 29 '20 at 10:24
-
@khmarbaise Well, it has a `deploy` phase and plugin. :) – Gerold Broser Dec 29 '20 at 10:59
-
Yes I know that very well.. but deploy is intended to deploy artifacts to a repository/repository manager ... – khmarbaise Dec 29 '20 at 11:04
-
1@khmarbaise Yes, I know that you know that very well and I do, too. Please note the „[:)](https://en.wikipedia.org/wiki/Smiley)“ – Gerold Broser Dec 29 '20 at 18:21
1 Answers
You should be able achieve the same thing with symlinks (symbolic link). It allows the file system a way to have a reference to another file location without actually making an explicit copy (kind of like a shortcut). This is also more in the spirit of maven's philosophy that each project should build only one artifact.
How you make symlinks depends on your operating system. You would need to make a symlink for each separate location that you need to "copy" to.
Mac / Linux:
ln -s /project/target/my.jar /project/server/plugin1
Windows:
mklink /project/target/my.jar /project/server/plugin1
Other info about symlinks (e.g. if you need to delete):
https://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/ https://www.howtogeek.com/297721/how-to-create-and-use-symbolic-links-aka-symlinks-on-a-mac/
Building multiple jars is fairly tricky in maven. See this post for some additional details - it suggests using a maven ant plugin if this is what you really want, but I would recommend against this approach. Symlinks should be easier to work with.

- 148
- 10