在詹金斯使用Eclipse编译器让编译器警告/错误 [英] Using Eclipse Compiler in Jenkins to get compiler warnings/errors

查看:175
本文介绍了在詹金斯使用Eclipse编译器让编译器警告/错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我詹金斯作业显示Eclipse编译器警告。
我知道这是可能使用ant的javac适配器使用Eclipse编译器。
这样的Eclipse编译器警告使用蚂蚁时表示。
问题是,当我在詹金斯使用Ant脚本,他忽略了javac的设置,并只使用正常的编译器。

I want to have the eclipse compiler warnings shown in my Jenkins Job. I know that it is possible to use the Eclipse Compiler using the ant javac adapter. That way Eclipse compiler warnings are shown when using ant. Problem is that when i use an ant script in Jenkins he ignores the javac settings and just uses the normal compiler.

有没有人尝试使用Eclipse编译器在詹金斯和让编译器警告?甚至送编译器警告声纳?

Did anyone try to use the eclipse compiler in jenkins and get the compiler warnings? maybe even send the compiler warnings to Sonar?

推荐答案

具有Eclipse编译器<故障后href=\"http://help.eclipse.org/juno/index.jsp?topic=/org.eclipse.jdt.doc.user/tasks/task-ant_javac_adapter.htm&cp=1_3_8_1\">ant javac的适配器,我使用batch编译而不是生成的Eclipse警告一个单独的目标。然后,我使用警告插件在詹金斯解析生成的编译器警告。

After having trouble with the Eclipse compiler ant javac adapter, I use the batch compiler instead in a separate target for generating Eclipse warnings. I then use the Warnings Plugin to parse the generated compiler warnings in Jenkins.

批处理编译便利地封装在一个单独的罐子,在Eclipse项目的下载页面和公共Maven仓库为的 Eclipse的ECJ

The batch compiler is conveniently packaged in a separate jar, downloadable under the "JDT Core Batch Compiler" section on an Eclipse project download page and also available in public maven repositories as Eclipse ECJ.

只要你已经上演了欧洲法院罐子 ecj.dir ,下面的构建脚本可以被利用来产生Eclipse的警告,

Provided you've staged the ecj jar to ecj.dir, the following build script may be leveraged to generate Eclipse warnings,

<?xml version="1.0" encoding="UTF-8" ?>
<project name="some-project" default="eclipse-warnings" basedir=".">
    <target name="eclipse-warnings" depends="init">        
        <property name="ecj.log.dir" value="${build.dir}/ecj" />
        <property name="ecj.warnings.file" value="${ecj.log.dir}\eclipse_compiler_out.txt"/>
        <delete dir="${ecj.log.dir}" />
        <mkdir  dir="${ecj.log.dir}" />

        <property name="ecj.properties" value="${basedir}\etc\ecj\eclipse_compiler.properties" />                

        <!-- Redirect output to tempfile if you don't want results also on console -->
        <tempfile property="ecj.output.tempfile" suffix=".log" deleteonexit="true" />

        <echo message="Generating Eclipse warnings to ${ecj.warnings.file}" />        
        <java 
            jar="${ecj.dir}/ecj.jar"
            fork="true"
            maxmemory="512m"
            output="${ecj.output.tempfile}">

            <arg value="-cp" />
            <arg value="${toString:compile.classpath}" />
            <arg value="-d" />
            <arg value="none" />
            <arg value="-enableJavadoc" />
            <arg value="-log" />
            <arg value="${ecj.warnings.file}" />            
            <arg value="-${javac.source.version}" />
            <arg value="-properties" />
            <arg value="${ecj.properties}" />
            <arg value="${src.dir}" />
            <arg value="${test.dir}" />            
        </java>

        <!-- Echo number of warnings found -->
        <loadfile srcfile="${ecj.warnings.file}" property="ecj.warnings.file.summary">
            <filterchain>
                <tailfilter lines="1" />
            </filterchain>
        </loadfile>
       <echo message="${ecj.warnings.file.summary}" />
    </target>    
</project>

eclipse_compiler.properties 包含编译器警告/错误的设置,可以从一个项目的 .settings / org.eclipse.jdt.core复制。 preFS 文件或中定义的<一个href=\"http://grep$c$c.com/file/repo1.maven.org/maven2/org.eclipse.jdt.core.compiler/ecj/4.2.1/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java#CompilerOptions\"><$c$c>CompilerOptions类。

eclipse_compiler.properties contains the compiler warn/error settings and may be copied from a project's .settings/org.eclipse.jdt.core.prefs file or defined in the CompilerOptions class.

#Eclipse compiler warnings and errors
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning

这篇关于在詹金斯使用Eclipse编译器让编译器警告/错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆