5 Replies Latest reply on May 24, 2013 1:53 AM by tadayosi

    Maven resource filtering doesn't work in a SwitchYard project

    tadayosi

      Hello,

       

      I'm trying to use Maven's resource filtering in my project's pom.xml like this:

       

          <build>
              ...
              <resources>
                  <resource>
                      <directory>src/main/resources</directory>
                      <filtering>true</filtering>
                  </resource>
              </resources>
              ...
      

       

      to modify my switchyard.xml below at build time.

       

               <sca:reference name="routerToFile" promote="FirstServiceESB/FileRouterListener" multiplicity="1..1">
                  <file:binding.file>
                      <file:directory>${project.build.directory}/output</file:directory>
                      <file:autoCreate>true</file:autoCreate>
                      <file:fileName>results.log</file:fileName>
                  </file:binding.file>
              </sca:reference>
      

       

      However, the filtering doesn't happen. I'm also using switchyard-plugin in my pom.xml to utilise the bean scanner, and suspect it may be because this plugin takes switchyard.xml away before Maven's filtering it during packaging.

       

      Attached my project for your reference.

       

      Do you have any ideas how to make it work?  Any advices would be much appreciated!

       

      Best regards,

      Tadayoshi

        • 1. Re: Maven resource filtering doesn't work in a SwitchYard project
          rcernich

          Hey Tadayoshi,

           

          Unforutunately, the SwitchYard configure mojo manipulates the switchyard.xml file directly, which as you've discovered does not apply any filtering.

           

          You may be able to workaround the issue by configuring the configure mojo to create its output switchyard.xml file in a different folder that can then be picked up by the resources mojo copying it into the target folder, applying any filtering.  The "orders" demo in SwitchYard quickstarts uses this approach to redirect the output into the appropriate war output directory and should give some guidance on how you might proceed.

           

          That said, I'm guessing there's an enhancement request in here that would allow the SwitchYard configure mojo to apply filtering.

           

          Hope that helps.

           

          Best,

          Rob

          1 of 1 people found this helpful
          • 2. Re: Maven resource filtering doesn't work in a SwitchYard project
            mageshbk

            Hi Tadayoshi,

             

            Maven filtering works, but our Mojo picks up the unfiltered resource when generating the config. You can overcome this by generating the filtered resource to another directory and then including that in the Mojo configuration.

            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                  <execution>
                    <id>copy-resources</id>
                    <phase>validate</phase>
                    <goals>
                      <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                      <outputDirectory>${basedir}/target/extra-resources</outputDirectory>
                      <resources>
                        <resource>
                          <directory>src/main/resources</directory>
                          <filtering>true</filtering>
                        </resource>
                      </resources>
                    </configuration>
                  </execution>
                </executions>
            </plugin>
            ...
            <plugin>
                <groupId>org.switchyard</groupId>
                <artifactId>switchyard-plugin</artifactId>
                <configuration>
                    <scannerClassNames>
                        <param>org.switchyard.component.bean.config.model.BeanSwitchYardScanner</param>
                        <param>org.switchyard.transform.config.model.TransformSwitchYardScanner</param>
                    </scannerClassNames>
                    <scanDirectories>
                        <param>${basedir}/target/extra-resources</param>
                    </scanDirectories>
                </configuration>
            ...
            
            

             

            You can also pass in system property in surefire plugin and the property will be substituted at runtime.

            • 3. Re: Maven resource filtering doesn't work in a SwitchYard project
              mageshbk

              Hi Rob,

               

              I just misssed your post

               

              cheers,

              Magesh

              • 4. Re: Maven resource filtering doesn't work in a SwitchYard project
                tadayosi

                Hi Rob and Magesh,

                 

                Thank you for the answers!  They both are accurate and insightful, and solved the problem. FYI, this simple addition to the Mojo configuration below is enough for my project.

                 

                             <plugin>
                                <groupId>org.switchyard</groupId>
                                <artifactId>switchyard-plugin</artifactId>
                                <configuration>
                                    ...
                                    <scanDirectories>
                                        <param>${project.build.outputDirectory}</param>
                                    </scanDirectories>
                                </configuration>
                                ...
                            </plugin>
                

                 

                While I already have a workaround, for posterity I'll create a feature request to the SY Mojo so that we won't need such an additional configuration. Thanks again.

                 

                Best regards,

                Tadayoshi

                • 5. Re: Maven resource filtering doesn't work in a SwitchYard project
                  tadayosi