13 Replies Latest reply on Mar 2, 2010 8:40 PM by Sav007

    Maven : Configuration ruleSet

    igreek Level 1

      Hi all!

       

      When we launch flexpmd from the plugin maven, how could we indicate our xml rule file?


      Indeed actually I run the plugin FlexPMD declared in my pom like this:

                  <plugin>
                      <groupId>com.adobe.ac</groupId>
                      <artifactId>flex-pmd-maven-plugin</artifactId>
                      <version>1.0.RC4</version>
                  </plugin>

       

      But it takes by defaults all the rules. I have tried to configure my pom (like it did with ant) bya adding a configuration section where i specify my xml rule file.

                  <plugin>
                      <groupId>com.adobe.ac</groupId>
                      <artifactId>flex-pmd-maven-plugin</artifactId>
                      <version>1.0.RC4</version>
                      <configuration>
                          <ruleSet>pluginConfig/flexpmd.xml</ruleSet>
                      </configuration>
                  </plugin>

       

      This fails unfortunatly

       

      igreek

        • 1. Re: Maven : Configuration ruleSet
          Xavier Agnetti Adobe Employee

          Can you send the console log, please?

           

          Xavier

          • 2. Re: Maven : Configuration ruleSet
            igreek Level 1

            Hi Xavier,

             

            Here is the log of the error encountered:

             

             

            [INFO] Generating "Flex PMD Report" report.
            5 oct. 2009 13:56:57 com.adobe.ac.pmd.maven.AbstractFlexPmdMojo executeReport
            INFO: FlexPmdMojo starts
            5 oct. 2009 13:56:57 com.adobe.ac.pmd.engines.AbstractFlexPmdEngine <init>
            ATTENTION: E:\TestFlexPMD\UnitedRetail_Product\ProductCodification\pluginConfig\
            flexpmd.xml
            (Le chemin d'accÞs spÚcifiÚ est introuvable) at java.io.FileInputStr
            eam.open(Native Method)
            java.io.FileInputStream.<init>(FileInputStream.java:106)
            com.adobe.ac.pmd.engines.AbstractFlexPmdEngine.loadRuleset(AbstractFlexPmdEngine
            .java:180)
            [INFO] ------------------------------------------------------------------------
            [ERROR] BUILD ERROR
            [INFO] ------------------------------------------------------------------------
            [INFO] Error during page generation

             

            Embedded error: Error rendering Maven report: A system exception has been thrown

             

             

            FlexPMD is trying to search the ruleSet configuration file flexpmd.xml in the wrong directory.

             

            I'm using a relative path for the location of the ruleSet file by incorporing this file in a project build-tools (which is specified in the parent pom of my project as an extension). Itworks with my other quality tools (checkstyle, pmd java, etc.).

             

            I tried to change the relative path by an absolute path and it works fine (but it is not what I really want).

             

                        <plugin>
                            <groupId>com.adobe.ac</groupId>
                            <artifactId>flex-pmd-maven-plugin</artifactId>
                            <version>1.0.RC4</version>
                            <configuration>
                                <ruleSet>E:/pmd_all_rules.xml</ruleSet>       
                            </configuration>
                        </plugin>

             

            Thanks for your reply

            • 3. Re: Maven : Configuration ruleSet
              Xavier Agnetti Adobe Employee

              Hi,

               

              Can you try to use ${baseDir}/custom_ruleset.xml ?

               

              Xavier

              • 4. Re: Maven : Configuration ruleSet
                igreek Level 1

                Xavier,

                T tried what you said but it does works.

                Now, my ruleSet configuration lokks like this:

                 

                <ruleSet>${basedir}/pluginConfig/pmd_all_rules.xml</ruleSet>

                 

                and it logs me the same message:

                 

                ATTENTION: E:\TestFlexPMD\UnitedRetail_Product\ProductCodification\pluginConfig\
                pmd_all_rules.xml (Le chemin d'accÞs spÚcifiÚ est introuvable) at java.io.FileIn
                putStream.open(Native Method)
                java.io.FileInputStream.<init>(FileInputStream.java:106)
                com.adobe.ac.pmd.engines.AbstractFlexPmdEngine.loadRuleset(AbstractFlexPmdEngine
                .java:180)
                [INFO] ------------------------------------------------------------------------
                [ERROR] BUILD ERROR
                [INFO] ------------------------------------------------------------------------
                [INFO] Error during page generation

                • 5. Re: Maven : Configuration ruleSet
                  igreek Level 1

                  I add precision. My custom_rules.xlm is not located in the same project I'am analysing. It is located on another project which is shared with an extension section in the parent pom of my project. I don't know if I'm clear enough...

                  • 6. Re: Maven : Configuration ruleSet
                    Xavier Agnetti Adobe Employee

                    Can you:

                    - post your folder structure?

                    - specify where the flexPMD definition is declared in?

                     

                    With this information, we will figure out how to work around this issue.

                     

                    Xavier

                    • 7. Re: Maven : Configuration ruleSet
                      igreek Level 1

                      xxxParentModule _____xxxFlexModule_____src

                                                |                              _____pom.xml (1)

                                                |_____pom.xml(2)

                       


                      In the pom of my flex module (1) , I defined the flexPMD plugin.

                      In the pom of my parent module (2), it is defined an extension section in the build where I put my custom_ruleset.xml

                       

                      This jar is added to the classpath.

                      • 8. Re: Maven : Configuration ruleSet
                        Xavier Agnetti Adobe Employee

                        In that case, can't you have something like:

                         

                        <ruleSet>${baseDir}/../pluginConf/custom_rules.xml ?

                         

                        Xavier

                        • 9. Re: Maven : Configuration ruleSet
                          doxumd_dox Level 1

                          Hi Xavier ,

                           

                          igreek use other plugins (like java checkstyle..) and he put all configuration files (rule set) in one shared zip file. He include the latter file in the classpath by using the <extension> tags in the pom file of the parent project.

                           

                          He can configure the java checkstyle to use a configuration file (rule set) stored in that zip file.

                           

                          He want to do the same thing with the flex pmd plugin.

                           

                          Java CheckStyle plugin is based on a RessourceManager class that locates the rules config file in the classpath :

                           

                          org.codehaus.plexus.resource.ResourceManager;

                           

                          ResourceManager locator;

                           

                          /* @parameter */

                          private String configLocation;

                           

                          File configFile = locator.getResourceAsFile( configLocation, "" );

                           

                           

                          However it doesn't seems to be the case in your flex pmd plugin.

                           

                          Thanks for listening !

                          • 10. Re: Maven : Configuration ruleSet
                            doxumd_dox Level 1

                            Ok we have fix this problem. We modified the source code to work like the java checkstyle (see my previous message) ...

                             

                            Also I would like to mention that in many cases the sourceDirectory propertie can change (for example when we generate automatically the source code from models -- MDA approach -- In that case we can put these files in a target "generated-sources" directory).

                            So it would be great if you delete the annotation "@readOnly" of the sourceDirectory parameter, so that we can configure the path to the source directory at the plugin declaration level (in the pom file).

                             

                            Thanks !

                            • 11. Re: Maven : Configuration ruleSet
                              doxumd_dox Level 1

                              Hi,

                              I want also to avoid modifying your source code directly. To do that I wanted to extends your classes in the "flex-pmd-maven-plugin" and override methods with my specific needs. Unfortunately, you used the "Final" key word that disable the possibility of override. I find that we loose the flexibility, specially when it is an open source project.

                               

                              regards,

                              • 12. Re: Maven : Configuration ruleSet
                                Xavier Agnetti Adobe Employee

                                Hi!

                                 

                                First of all, thanks for spotting this one down. Feel free to create a new defect and attach the patch to it. I will integrate it in the next release candidate.

                                About the final keyword, I see your point. I am not sure which one you are talking about, but final makes sense in a lot of places.

                                 

                                It may makes sense to remove it for specific methods.

                                 

                                Best

                                 

                                Xavier

                                • 13. Re: Maven : Configuration ruleSet
                                  Sav007 Level 1

                                  Hi everyone

                                  I faced with the same problem.

                                  My FlexPmd.xml file is part of another project (myxxx-build-tools).

                                   

                                  Project that I'm trying to launch has dependecy to the project with FlexPmd.xml:

                                  <dependency>

                                              <groupId>com.xxx.xx</groupId>

                                              <artifactId>myxxx-build-tools</artifactId>

                                              <version>1.0-SNAPSHOT</version>

                                          </dependency>

                                   

                                  Also from tutorial I put:

                                   

                                  <reporting>

                                          <plugins>

                                              <plugin>

                                                  <groupId>com.adobe.ac</groupId>

                                                  <artifactId>flex-pmd-maven-plugin</artifactId>

                                                  <version>1.0.RC5</version>

                                                  <configuration>

                                                      <ruleSet>myxxx-build-tools/FlexPmd.xml</ruleSet>

                                                  </configuration>

                                                  <reportSets>

                                                  </reportSets>

                                              </plugin>

                                          </plugins>

                                      </reporting>

                                   

                                  When I'm trying to run mvn site plugin can't resolve path to my custom ruleset.

                                  What I'm doing wrong, or could anyone give me some example of pom.xml files when custom ruleset belong to another project.

                                  Thanks.