By default JHipster generate 2 wars during the package phase (your_project_version.war & your_project_version.war.original). The first one is the executable jar and the second is the war you can use in a servlet container.
Is there a way to only generate the 'original' war. The executable is not required for my project and I would like to deploy the war to Nexus.
jhipster generated project will make use of spring-boot, and in particular of the spring-boot-maven-plugin, which by default binds the repackage goal to the package lifecycle phase. If you want to disable the repackaging, it should be enough to edit your pomfile, so that no execution is present for the repackage goal (by setting the bound phase to none):
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<phase>none</phase>
</execution>
</executions>
</plugin>
If you need so, you will then be able to run the goal directly, as:
mvn package spring-boot:repackage
In SpringBoot 2, removing executions did not work for me. I needed to set goal to package :
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
<phase>none</phase>
</execution>
</executions>
Related
I have an app built with Spring Boot 3.0.0-M5, Spring Cloud 2022.0.0-M4, Java 17. Its GitHub repo is https://github.com/wenqiglantz/springboot3-webclient/tree/metadata. I am trying to achieve the following:
Enable metadataRepository configuration in native-maven-plugin in my app to assist in my native image build as this plugin automatically searches for GraalVM reachability metadata repo.
Need to create a custom runtime (in a zip format) using maven-assembly-plugin as I need to deploy my app to AWS Lambda since Lambda doesn't yet support Java 17 runtime.
I was able to generate the custom runtime in a zip file with maven-assembly-plugin and a few config files in my source code and deploy to Lambda (my github actions workflow run https://github.com/wenqiglantz/springboot3-webclient/actions/runs/3146602388/jobs/5115233455). However, after adding native-maven-plugin to enable metadataRepository, my custom runtime build broke, it no longer generates the zip file (github actions workflow run https://github.com/wenqiglantz/springboot3-webclient/actions/runs/3151692666/jobs/5125968700). Also see attached the comparison screenshot. The maven command I use in my workflow is mvn -ntp clean package -Pnative -e -X. In my root pom. Unfortunately I have not been able to find any good documentation on either GraalVM side or Spring Boot side on how to configure such plugins to achieve what I want. I have the plugins configured as the following, let me know what's the best way to handle configuring both maven-assembly-plugin and native-maven-plugin so I can accomplish my two goals listed above.
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>native-zip</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<inherited>false</inherited>
</execution>
</executions>
<configuration>
<descriptors>
<descriptor>src/assembly/native.xml</descriptor>
</descriptors>
</configuration>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.9.14</version>
<extensions>true</extensions>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>compile-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<configuration>
<metadataRepository>
<enabled>true</enabled>
</metadataRepository>
</configuration>
</plugin>
</plugins>
</build>
I am trying to use module as a dependency in another project by deploying it to our nexus repository.
The problem is that maven tries to deploy the jar twice and our policy forbids to overwrite a release version.
The module is packaged as a war.
Here is my configuration.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>build-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
<configuration>
<attachClasses>true</attachClasses>
<failOnMissingWebXml>true</failOnMissingWebXml>
</configuration>
</plugin>
When I set attachClasses to false, everything goes fine and the war gets deployed, but the jar doesn't.
When I set it to true, the jar gets deployed but maven tries to deploy a second time and then the build fails.
Any idea why maven tries to deploy it twice.
(The module has a parent module, but it does not depend on any other module from the project).
The problem is probably that you defined your own execution.
Try to remove the block
<executions>
<execution>
<id>build-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
I would like a plugin to only be run during a new phase. Mainly, I don't want the plugin to run during the build lifecycle.
Something like install:
maven clean build custom:meOnly
GC
Note: I am attempting to call this plug-in:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>runbatchfile</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>deploy.bat</executable>
</configuration>
</plugin>
Plugins consist of goals. If you don't bind a goal to a lifecycle phase, it will not be executed during build. You can, though, start it as plugin:goal from the command line.
There is no need to create an additional phase, a goal will do just fine.
I am still in a phase to create a POM.xml file. The basic is to start jetty plugin during the build life cycle. So far I have to enter
mvn package
mvn jetty:run-war
I do not want to do it manually. I prefer the way where a war file is created and jetty plugin started using the one command.
Here is my POM.xml
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.11.v20150529</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<contextPath>/hellojavaworld</contextPath>
</webApp>
<war>c:\apache-tomcat-7.0.64\webapps\hellojavaworld.war</war>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<!--configuration>
<daemon>true</daemon>
</configuration-->
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
Why the jetty plugin is not started when inserted the following command?
mvn pre-integrate-test
What is the problem? The jetty plugin starts only when used the command
mvn jetty:run-war
From parent : mvn jetty:run-war -pl module
Solved.
The property of the jetty plugin for multimodule project si mentioned here: Multi-module Maven project and jetty:run
I had to specify the plugin and lifecycle configuration in the child pom.xml file. In the parent it was not working.
---Hellojavaworld-pom.xml (parent)
----app-pom.xml (child)
----jjav-pom.xml (child)
I have some modules like:
|-business jar
|-dal jar
|-model jar
|-webApp war
I need to build all jar before liferay:deploy the war.
I also have a parent pom module that allow to build all modules but it doesn't deploy my war after that.
thanks
If you have defined all modules as dependencies then maven will take care that the modules build in the proper order.
By default the Liferay deploy goal is not executed. You need execute it or add some configuration to run tit automatically. e.g.
<plugin>
<groupId>com.liferay.maven.plugins</groupId>
<artifactId>liferay-maven-plugin</artifactId>
<configuration>
<pluginType>portlet</pluginType>
</configuration>
<executions>
<execution>
<id>deploy-package</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
Does your parent pom contains all the modules in the
<modules>
<module>business-jar</module>
<module>dal-jar</module>
<module>model-jar</module>
<module>portlet</module>
<module>theme</module>
</modules>
and then make sure that your portlet/webapp war does contain
<plugin>
<groupId>com.liferay.maven.plugins</groupId>
<artifactId>liferay-maven-plugin</artifactId>
<executions>
<execution>
<id>deploy-package</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</executions>
</plugin>