How to generate the jar file by Maven?

Asked

Viewed 315 times

-1

I need to generate a file jar in the project folder as shown in the image below; inserir a descrição da imagem aqui

I don’t want to be depending on the bash command mvn clean install, i would love to put the settings in the pom.xml file so when the application runs it automatically generates the file. jar in web project folder.

This is a Spring Boot project, but the settings I put below did not work and I need to know how to hit the code;

<build>
<finalName>dockerTest</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
         <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>
  • 2

    Maven is for managing dependencies and packaging settings, so you have the jar Maven will be responsible for generating it. There is no way you can use Maven and not run the artifact-generating Goal. I suggest reading the documentation of the tool, because I believe your understanding of how it works is mistaken.

1 answer

1

A fix: not a command bash, is a command. Simple as that. It could run on Bourne Shell, Dash, Ash, Csh, Zsh, Cmd, Powershell, even be called inside Ruby using`tics`.

On the other hand, Eclipse provides you with an ease to run Maven commands. An alternative is:

  • right click on your project
  • select "Debug As" (I prefer "debug" because it is more likely to call the JDK than the JRE)
  • then select "Maven build..."
  • put your goals desired

botão direito sobre o projeto

selecione "maven build"

coloque seus "goals"

After doing this, the shortcut is in the last "runs":

acesso rápido ao debug

note that using the previously available options shown by the Eclipse context menu, such as "Maven install" or "Maven clean", does not leave the shortcut available

Other Ides also allow you to make calls of this type, but I advise you to learn more about Maven’s command line options; in CI/CD environments, you will have access to the raw command line normally in a YAML, and in projects that grow enough these options become more useful.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.