Problem with maven exec plugin: Unable to access jarfile

0

I am generating a jar with maven and I would like to run it using maven but I get an error.

This is my plugin configuration in the pom :

<build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.3.2</version>
                <executions>
                    <execution>
                        <id>default-cli</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>java</executable>
                            <arguments>
                                <argument>-jar</argument>
                                <argument>target/farmacia-${project.version}-jar-with-depencencies.jar</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Which I learned from stackoverflow .

By running the command mvn install exec:exec -X I get the path of the jar while doing the install as

Building jar: C:\Users\ruslan.lopez\IdeaProjects\farmacia\target\farmacia-1.0-jar-with-dependencies.jar

And the execution of the exec gives me the trace:

[DEBUG]   (f) arguments = [-jar, target/farmacia-1.0-jar-with-depencencies.jar]
[DEBUG]   (f) basedir = C:\Users\ruslan.lopez\IdeaProjects\farmacia
[DEBUG]   (f) classpathScope = runtime
[DEBUG]   (f) executable = java
[DEBUG]   (f) failWithEmptyArgument = true
[DEBUG]   (f) failWithNullKeyOrValueInEnvironment = true
[DEBUG]   (f) longClasspath = false
[DEBUG]   (f) project = MavenProject: xoxefdp.github.com:farmacia:1.0 @ C:\Users\ruslan.lopez\IdeaProjects\farmacia\pom.xml
[DEBUG]   (f) skip = false
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@376e7531
[DEBUG] -- end configuration --
[DEBUG] Executing command line: [java, -jar, target/farmacia-1.0-jar-with-depencencies.jar]
  

Error: Unable to access jarfile target / pharmacy-1.0-jar-with-depencencies.jar

    
asked by Ruslan López 12.12.2018 в 09:47
source

1 answer

0

Foolish me, I was wrong writing the name of the jar

target/farmacia-${project.version}-jar-with-depencencies.jar

It should be

target/farmacia-${project.version}-jar-with-dependencies.jar
    
answered by 12.12.2018 / 09:58
source