I have a webapp that I need to copy the Java files into my output Quarkus application because I display the code snippets as help in the web pages. Currently the only way I could figure it out is by always calling compile
when running mvn compile quarkus:dev
goal. However this is not standard as most Quakrus apps just work with mvn quarkus:dev
out of the box!
My question is how to I attach to the Quarkus lifecycle of plugins?
My current copy-resources only works in compile
phase which does not seem to run in quarkus:dev
mode.
Copy Resources Plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>copy-java-files</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<propertiesEncoding>UTF-8</propertiesEncoding>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<resources>
<resource>
<directory>src/main/java</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
Current Quarkus Plugin:
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
</goals>
</execution>
</executions>
</plugin>
Any help our guidance would be appreciated!
I have tried many different <phase>
attributes for my plugin but none of them seem to execute in the Quarkus lifecycle and I could not find any documentation on Quakrus site how to do so?
CodePudding user response:
Reported as an enhancement to Quarkus: https://github.com/quarkusio/quarkus/issues/30166
A good workaround suggested by user "famod" is to create a profile and then just call mvn -Pqdev
with the following profile.
<profile>
<id>qdev</id>
<properties>
<quarkus.test.continuous-testing>paused</quarkus.test.continuous-testing>
</properties>
<build>
<!-- note: test-compile to prevent quarkus:dev from invoking compiler-plugin etc. on its own
because that would trigger unwanted recompiles (for yet unknown reasons) which also causes issues when using ECJ (which we do )-->
<defaultGoal>test-compile quarkus:dev</defaultGoal>
</build>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.loggingmanager</groupId>
<artifactId>quarkus-logging-manager</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
</profile>