Maven - Using initialized at antrun parameter at plugin configuration

21 Views Asked by At

I need to initialize a parameter via antrun/gmaven in the parent project and use its value in the configuration of the plugin in the child module. For clarity, in the example the plugin id is configured, in the real case I need to configure the phase.Is it possible to do this "directly"? Full code of simple project is here - https://github.com/chemist22888/example.

Parent antrun plugin:


                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <exportAntProperties>true</exportAntProperties>
                            <target>
                                <property name="test.id" value="testId"/>
                                <property name="test.phase" value="generate-sources"/>

                                <echo message="parent phase ${test.id}"/>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Child antrun plugin:

   <plugin>

                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <id>${test.phase}</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <echo message="child ${test.phase}"/>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

After execution the correct value of parameter is displayed at console, but id of plugin is ${test.phase} instead of generate-sources. Is there any possibility to fix this?

Also tried using gmaven plugin, but had the same issue

0

There are 0 best solutions below