How to execute Google Codepro analytix from command line?

一个人想着一个人 提交于 2019-11-30 22:54:17

问题


Is it possible to run Google CodePro analytix from Command Line.

What I am looking for is to run this from a shell script passing the file name as a parameter and get all the metrics generated on file level for the filename I passed in as parameter.

Is it possible to do so? and How?

Are there any other tools that can give same metrics for a Java file and be executed from a shell script?


回答1:


There is a set of codepro ant tasks that can be used for auditing as well as report generation.

As to other tools, there is also a set of ant tasks for PMD as well as a PMD plugin for maven. Both can be run from command line.

Similar for Findbugs : the instructions for the ant task can be found here, and the maven plugin here

EDIT: It seems to me that google purchased this beatiful tool just to let it die of obscurity. There seems to be no ongoig development and no release to open source. The ant tasks are not released (and I have found no usable examples). there is no maven plugin. We were unable to integrate it in our build and are back to using PMD, Findbugs and Sonar. It's a shame.




回答2:


Google CodePro Analytix should have an Ant task, it should be the place where a command-line utility would do the desired action.




回答3:


CodePro Analytix does have ant tasks and they are functional. Please see the documentation here.

https://developers.google.com/java-dev-tools/codepro/doc/features/ant/headless - It works even though the first line says the tasks are deprecated.

Both ant tasks codepro.audit and codepro.metrics works fine with Eclipse Juno. I was able to run both audit and metrics tasks on an existing workspace project by editing headless.xml and run_headless.bat files from https://developers.google.com/java-dev-tools/codepro/doc/features/ant/example/headless_existing_workspace_33.zip

I edited the default headless.xml to use a specific rule/metric set and to export the results in xml format.

<?xml version="1.0" encoding="UTF-8"?>
<project name="Ant Test" basedir="." default="main">
    <target name="main">        
        <!-- the project source directory to be analyzed -->
        <property name="projSrc" location="<full path to your project source folder>"/>

        <!-- test codepro.audit -->
        <codepro.audit auditRuleSetName="CodePro Default"  
            resultFile="headless_audit_out.txt">
            <fileSet dir="${projSrc}"/>
            <report file="audit_result.xml" format="xml">
            </report>
        </codepro.audit>

        <!-- test codepro.metrics -->
        <codepro.metrics metricSetName="CodePro Default"
            resultFile="headless_metrics_out.txt">
            <fileSet dir="${projSrc}"/>
            <report file="metrics_result.xml" format="xml">
            </report>
        </codepro.metrics>

        <echo message="It works!"/>
    </target>   
</project>


来源:https://stackoverflow.com/questions/5632930/how-to-execute-google-codepro-analytix-from-command-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!