Java 如何在Eclipse中的antbuildfile中添加sonar

Java 如何在Eclipse中的antbuildfile中添加sonar,java,xml,eclipse,ant,sonarqube,Java,Xml,Eclipse,Ant,Sonarqube,我不懂XML, 但是看看教程,我在Eclipse(GWT)的web应用程序项目中创建了ant builfile->projecBuilder.xml 在projectBuilder.xml的帮助下,我为客户机、共享服务器中的所有java文件创建了一个jar文件 <!-- list of mandatories Sonar properties --> <sources>

我不懂XML, 但是看看教程,我在Eclipse(GWT)的web应用程序项目中创建了ant builfile->projecBuilder.xml 在projectBuilder.xml的帮助下,我为客户机、共享服务器中的所有java文件创建了一个jar文件

                <!-- list of mandatories Sonar properties -->
                <sources>
                     <path location="${src}" />
                </sources>

                <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
                <binaries>
                     <path location="${classes.dir}" />
                </binaries>
            </sonar:sonar>

        </target>
现在我想在projectbuilder.xml中添加Sonar作为目标

                <!-- list of mandatories Sonar properties -->
                <sources>
                     <path location="${src}" />
                </sources>

                <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
                <binaries>
                     <path location="${classes.dir}" />
                </binaries>
            </sonar:sonar>

        </target>
我已经加载了声纳2.12, 声纳蚂蚁任务。两者都位于驱动器D中:/

                <!-- list of mandatories Sonar properties -->
                <sources>
                     <path location="${src}" />
                </sources>

                <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
                <binaries>
                     <path location="${classes.dir}" />
                </binaries>
            </sonar:sonar>

        </target>
我所做的:

  <?xml version="1.0" encoding="UTF-8"?>
                <!-- list of mandatories Sonar properties -->
                <sources>
                     <path location="${src}" />
                </sources>

                <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
                <binaries>
                     <path location="${classes.dir}" />
                </binaries>
            </sonar:sonar>

        </target>

                <!-- list of mandatories Sonar properties -->
                <sources>
                     <path location="${src}" />
                </sources>

                <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
                <binaries>
                     <path location="${classes.dir}" />
                </binaries>
            </sonar:sonar>

        </target>

                <!-- list of mandatories Sonar properties -->
                <sources>
                     <path location="${src}" />
                </sources>

                <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
                <binaries>
                     <path location="${classes.dir}" />
                </binaries>
            </sonar:sonar>

        </target>
我用上面的链接来进一步解决这个问题

                <!-- list of mandatories Sonar properties -->
                <sources>
                     <path location="${src}" />
                </sources>

                <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
                <binaries>
                     <path location="${classes.dir}" />
                </binaries>
            </sonar:sonar>

        </target>
我复制了粘贴代码,但它显示了错误。 请告诉我有什么需要改变的

                <!-- list of mandatories Sonar properties -->
                <sources>
                     <path location="${src}" />
                </sources>

                <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
                <binaries>
                     <path location="${classes.dir}" />
                </binaries>
            </sonar:sonar>

        </target>

请任何人告诉我如何用一种非常简单的语言使用ant构建文件来分析sonar中的代码。

最后,我在许多博客的帮助下解决了这个问题,并希望与大家分享

                <!-- list of mandatories Sonar properties -->
                <sources>
                     <path location="${src}" />
                </sources>

                <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
                <binaries>
                     <path location="${classes.dir}" />
                </binaries>
            </sonar:sonar>

        </target>
1.下载Ant 2.将其解压缩并重命名为ant 3.设置环境变量,以便在命令提示符下执行此操作(假设Ant安装在D:\Ant中)

                <!-- list of mandatories Sonar properties -->
                <sources>
                     <path location="${src}" />
                </sources>

                <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
                <binaries>
                     <path location="${classes.dir}" />
                </binaries>
            </sonar:sonar>

        </target>
  • 检查ANT是否正常工作。在命令提示下,键入:

                ant -version
    
                    <!-- list of mandatories Sonar properties -->
                    <sources>
                         <path location="${src}" />
                    </sources>
    
                    <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
                    <binaries>
                         <path location="${classes.dir}" />
                    </binaries>
                </sonar:sonar>
    
            </target>
    
  • 5.不要关闭命令提示符

                    <!-- list of mandatories Sonar properties -->
                    <sources>
                         <path location="${src}" />
                    </sources>
    
                    <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
                    <binaries>
                         <path location="${classes.dir}" />
                    </binaries>
                </sonar:sonar>
    
            </target>
    
    加声纳

                    <!-- list of mandatories Sonar properties -->
                    <sources>
                         <path location="${src}" />
                    </sources>
    
                    <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
                    <binaries>
                         <path location="${classes.dir}" />
                    </binaries>
                </sonar:sonar>
    
            </target>
    
    1.从链接下载Sonar 2.12 2.解压下载。 3.在windows命令提示符下,执行bin\windows-x86-64\StartSonar.bat 4.浏览至 5.对于管理功能,默认登录/密码为admin/admin

                    <!-- list of mandatories Sonar properties -->
                    <sources>
                         <path location="${src}" />
                    </sources>
    
                    <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
                    <binaries>
                         <path location="${classes.dir}" />
                    </binaries>
                </sonar:sonar>
    
            </target>
    
    用于使用Ant进行分析

                    <!-- list of mandatories Sonar properties -->
                    <sources>
                         <path location="${src}" />
                    </sources>
    
                    <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
                    <binaries>
                         <path location="${classes.dir}" />
                    </binaries>
                </sonar:sonar>
    
            </target>
    
    1.从链接下载声纳蚂蚁任务 2.将此jar文件sonar-ant-task-1.3复制到ant文件夹的lib中(D:\ant\lib)。 3.将jar文件复制到eclipse\plugins\org.apache.ant_1.8.2.v20110505-1300

                    <!-- list of mandatories Sonar properties -->
                    <sources>
                         <path location="${src}" />
                    </sources>
    
                    <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
                    <binaries>
                         <path location="${classes.dir}" />
                    </binaries>
                </sonar:sonar>
    
            </target>
    
    Eclipse中项目的Ant文件

                    <!-- list of mandatories Sonar properties -->
                    <sources>
                         <path location="${src}" />
                    </sources>
    
                    <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
                    <binaries>
                         <path location="${classes.dir}" />
                    </binaries>
                </sonar:sonar>
    
            </target>
    
    1.用于在eclipse检查链接中创建Ant文件

                    <!-- list of mandatories Sonar properties -->
                    <sources>
                         <path location="${src}" />
                    </sources>
    
                    <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
                    <binaries>
                         <path location="${classes.dir}" />
                    </binaries>
                </sonar:sonar>
    
            </target>
    
    2.在buid.xml中 编写代码

                    <!-- list of mandatories Sonar properties -->
                    <sources>
                         <path location="${src}" />
                    </sources>
    
                    <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
                    <binaries>
                         <path location="${classes.dir}" />
                    </binaries>
                </sonar:sonar>
    
            </target>
    
    
    

                    <!-- list of mandatories Sonar properties -->
                    <sources>
                         <path location="${src}" />
                    </sources>
    
                    <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
                    <binaries>
                         <path location="${classes.dir}" />
                    </binaries>
                </sonar:sonar>
    
            </target>
    

    您似乎需要阅读声纳蚂蚁文档: