I am using Maven in combination with Quarkus and Angular for my website.
In order to start and stop the Angular frontend with the quarkus backend I have the following plugin set up in my pom.xml:
<plugin>
<groupId>org.ple</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>frontend</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>sh</executable>
<arguments>
<argument>-c</argument>
<argument>npm run start && echo $! > ${project.build.directory}/frontend-server.pid</argument>
</arguments>
<workingDirectory>../../../../../../../frontend/foo/</workingDirectory>
</configuration>
</execution>
<execution>
<id>stop-frontend</id>
<phase>post-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>sh</executable>
<arguments>
<argument>-c</argument>
<argument>if [ -f ${project.build.directory}/frontend-server.pid ]; then kill $(cat ${project.build.directory}/frontend-server.pid); fi</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
During the validation phase the npm run start is executed to start the Angular frontend and the PID is saved to a file so I can later terminate it. The second execution should be called during the post integration phase and kill the process by reading the PID of the frontend process and then killing the process with that PID
The frontend does start but when I close maven using ctrl+c the frontend keeps running until I externally kill the process.
How can I have the frontend be terminated when I terminate maven/quarkus
pom.xml
and managing the integration of the two by hand.