0

I have a maven project and I would like maven to place or copy the final jar into a directory other than the project dir, in this case ${user.home}/.dir/, but I get following error:

[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/Users/edgelord/.dir/target). 
Please verify you invoked Maven from the correct directory. -> [Help 1]

I tried it by modifying the maven-jar-plugin, the required section of my pom looks like this:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
        <finalName>e80</finalName>
        <outputDirectory>${user.home}/.dir</outputDirectory>
        <archive>
            <manifest>
            <mainClass>de.edgelord.edgyscript.e80.main.Main</mainClass>
            </manifest>
        </archive>
     </configuration>
</plugin>

As you may have noticed, I also want to have the final jar to be called e80.jar

edgelord
  • 43
  • 4
  • @Sambit I sure saw and read that, but the provided solution doesn't work. Thanks for the suggestion though – edgelord Aug 06 '19 at 18:46
  • one way is by using the ant-plugin, see https://www.baeldung.com/maven-ant-task and https://ant.apache.org/manual/Tasks/copy.html – Daniele Aug 06 '19 at 19:05

2 Answers2

0

I wouldn't do that.

Instead I would allow Maven to build the artifact as Maven likes it (aka into target) and afterwards rename and copy it.

For the second step, the maven-antrun-plugin is a good approach, as described in the comment of @Daniele.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
0

Apparently everything was fine and working, I was just invoking maven from the wrong directory, sorry :(

edgelord
  • 43
  • 4