Created
June 28, 2019 20:19
-
-
Save fabioebner/c9ad6415b67ca40d16dca87637c24bac to your computer and use it in GitHub Desktop.
Build maven com propriedade no application.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Adicione essa entrada no pom.xml: | |
<dependency> | |
<groupId>org.codehaus.mojo</groupId> | |
<artifactId>properties-maven-plugin</artifactId> | |
<version>1.0.0</version> | |
</dependency> | |
Dentro do contexto do build do seu pom.xml, configure o plugin com a seguinte entrada: | |
<build> | |
<plugin> | |
<groupId>org.codehaus.mojo</groupId> | |
<artifactId>properties-maven-plugin</artifactId> | |
<version>1.0.0</version> | |
<executions> | |
<execution> | |
<phase>initialize</phase> | |
<goals> | |
<goal>read-project-properties</goal> | |
</goals> | |
<configuration> | |
<files> | |
<file>${basedir}/src/main/resources/application.yml</file> | |
</files> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
</build> | |
Dentro do seu arquivo application.yml, se hipoteticamente a variável se chama myversion: | |
myversion=2.1 | |
Dentro do pom, substitua o valor da tag version, pela variável filtrada ${myversion}: | |
<groupId>com.foo.app</groupId> | |
<artifactId>foo-app</artifactId> | |
<version>${myversion}</version> <!-- Essa versao aqui --> | |
<packaging>war</packaging> | |
Quando compilar, o artefato gerado será: | |
foo-app-2.1.war |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment