Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-users] Invoke plugin execution when files in src/main/resources change

The plugin has to implement one of incremental build APIs for this to work.  There are currently three: the legacy BuildContext (provided by org.sonatype.plexus:plexus-build-api), and couple of separate APIs provided by takari incrementalbuild [1] project. Personally I think @Builder annotation-based API [2] is the most promising, but it's also the most recent one still has some teething problems.

[1] https://github.com/takari/io.takari.incrementalbuild
[2] https://github.com/takari/io.takari.incrementalbuild/blob/master/DOCUMENTATION.md

--
Regards,
Igor


On Thu, Jan 4, 2018, at 1:40 PM, Ben Emery-Honzal wrote:

Hello,

 

I’m trying to invoke my custom plugin “i18nMessageCompiler” whenever a properties file in the src/main/resources directory changes (e.g. when a new property is added). How do I configure the pom.xml or m2e to invoke the plugin whenever the properties file changes?

 

In the lifecycle-mapping, I configured the plugin to run on incremental build. One issue might be that Eclipse does not trigger an incremental build when files in src/main/resources change. However, even if I change a Java class in src/main/java (which should invoke an incremental build), the i18nMessageCompiler plugin execution does not get invoked.

 

Only a full project rebuild via Eclipse’s > Project > Clean (with “Start a build immediately” checked) will invoke the plugin execution.

 

 

Excerpt from the project’s pom.xml:

 

<build>

   <finalName>rts</finalName>

   <plugins>

 

      <plugin>

         <groupId>org.apache.maven.plugins</groupId>

         <artifactId>maven-war-plugin</artifactId>

         <version>2.3</version>

         <configuration>

            <warSourceExcludes>node_modules/**</warSourceExcludes>

         </configuration>

      </plugin>

 

      <plugin>

         <groupId>org.apache.maven.plugins</groupId>

         <artifactId>maven-compiler-plugin</artifactId>

         <version>3.1</version>

         <configuration>

            <source>1.8</source>

            <target>1.8</target>

         </configuration>

      </plugin>

 

      <plugin>

         <groupId>com.rfxcel.rts</groupId>

         <artifactId>i18nMessageCompiler</artifactId>

         <version>1.0.0</version>

         <configuration>

            <fullyQualifiedClassName>com.rfxcel.rts.ui.messages.MessageIds</fullyQualifiedClassName>

            <propertiesFileName>messages.properties</propertiesFileName>

            <messageIdFormat>RTSUI\d{5}(I|W|E)</messageIdFormat>

         </configuration>

         <executions>

            <execution>

               <phase>generate-sources</phase>

               <goals>

                  <goal>compileMessages</goal>

               </goals>

            </execution>

         </executions>

      </plugin>

   </plugins>

 

   <pluginManagement>

      <plugins>

         <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->

         <plugin>

            <groupId>org.eclipse.m2e</groupId>

            <artifactId>lifecycle-mapping</artifactId>

            <version>1.0.0</version>

            <configuration>

               <lifecycleMappingMetadata>

                  <pluginExecutions>

                     <pluginExecution>

                        <pluginExecutionFilter>

                           <groupId>com.rfxcel.rts</groupId>

                           <artifactId>i18nMessageCompiler</artifactId>

                           <versionRange>[1.0.0,)</versionRange>

                           <goals>

                              <goal>compileMessages</goal>

                           </goals>

                        </pluginExecutionFilter>

                        <action>

                           <execute>

                              <runOnIncremental>true</runOnIncremental>

                              <runOnConfiguration>true</runOnConfiguration>

                           </execute>

                        </action>

                     </pluginExecution>

                  </pluginExecutions>

               </lifecycleMappingMetadata>

            </configuration>

         </plugin>

      </plugins>

   </pluginManagement>

</build>

 

 

Thank you,

 

Ben Emery-Honzal

_______________________________________________
m2e-users mailing list
m2e-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/m2e-users


Back to the top