5

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?

Melloware
  • 10,435
  • 2
  • 32
  • 62
  • 2
    Thing is that we call a plugin goal directly (`quarkus:dev`), hence no mave lifecycles are actually executed. The only way I can think of is to get into the `quarkus:dev`execution. This would mean to write a quarkus extension. I am, however, not entirely sure if it is possible to do what you want within a quarkus extension. – Turing85 Dec 31 '22 at 15:18
  • This can be supported. Could you please create a github issue, @Melloware? – Alexey Loubyansky Jan 03 '23 at 09:12
  • @AlexeyLoubyansky done! https://github.com/quarkusio/quarkus/issues/30166 – Melloware Jan 03 '23 at 22:55

1 Answers1

0

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>
   <build>
      <defaultGoal>compile quarkus:dev</defaultGoal>
   </build>
</profile>

Edit 06/01/2023: Quarkus 3.2.0.Final will include this finally so you can just do normal compile phase etc. Fixed with this PR: https://github.com/quarkusio/quarkus/pull/33617

Melloware
  • 10,435
  • 2
  • 32
  • 62