I am trying to build this project https://github.com/goldmansachs/gs-collections .
Built with: ant -buildfile build.xml
However I get the following error:
[javadoc] javadoc: error - Illegal package name: "/home/bionix/Desktop/gs-collections/collections-api/target/generated-sources/java/com/gs/collections/api/block/function/primitive/CharFunction.java.crc"
[javadoc] javadoc: error - Illegal package name: "/home/bionix/Desktop/gs-collections/collections-api/target/generated-sources/java/com/gs/collections/api/block/function/primitive/CharFunction0.java.crc
and then here is the result:
[javadoc] 100 errors
javadoc-jar:
BUILD FAILED
/home/bionix/Desktop/gs-collections/build.xml:33: The following error occurred while executing this line:
/home/bionix/Desktop/gs-collections/common-build.xml:280: /home/elmaakoul/Desktop/gs-collections/collections-api/target/javadoc does not exist.
I don't know the source of the problem in here. Can someone help me. Thank you
This is the common-build.xml:
<target name="javadoc" depends="-deploy-properties, -ivy-init">
<ivy:cachepath pathid="runtime.classpath" conf="runtime" />
<javadoc
destdir="target/javadoc"
author="true"
version="true"
use="true"
useexternalfile="true"
windowtitle="${javadoc.title} - ${build.version.full}">
<sourcefiles>
<resources refid="all-sources" />
</sourcefiles>
<classpath refid="runtime.classpath" />
<doctitle>${javadoc.title} - ${build.version.full}</doctitle>
<link href="http://java.sun.com/j2se/1.5.0/docs/api/" />
</javadoc>
</target>
<target name="javadoc-jar"
depends="-deploy-properties, javadoc"
description="Builds the javadoc jar for the application">
<jar
jarfile="${javadoc.jar.name}"
compress="true"
index="false"
basedir="target/javadoc" />
</target>
If you take a look on their build you will see that they use maven.
They skip javadoc generation.
And it builds correctly.
Related
I want to integrate Checkstyle and PMD plug-ins in Jenkins for checking quality code automatically.
I followed the instructions from: http://www.treselle.com/blog/static-code-analysis-jenkins/
My build.xml in workspace was appended those codes:
<taskdef name="checkstyle" classpath="WEB-INF/libs/checkstyle-5.6.jar" classname="com.puppycrawl.tools.checkstyle.CheckStyleTask" />
<target name="checkstyle" description="Generates a report of code convention violations.">
<checkstyle config="sun_checks.xml" failOnViolation="false">
<formatter type="xml" tofile="checkstyle_report.xml" />
<fileset dir="WEB-INF/src" includes="**/*.java" />
</checkstyle>
</target>
<taskdef name="pmd" classpath="WEB-INF/libs/pmd.jar" classname="net.sourceforge.pmd.ant.PMDTask" />
<target name="pmd" depends="compress">
<pmd rulesetfiles="java-imports">
<formatter type="xml" toFile="pmd_report.x.ml" />
<fileset dir="WEB-INF/src">
<include name="**/*.java" />
</fileset>
</pmd>
</target>
I also added enough library, but when I builded Jobs, I got a exception:
taskdef class com.puppycrawl.tools.checkstyle.CheckStyleTask cannot be found using the classloader AntClassLoader[]
Why is there such error? And How do I integrate them correctly?
Thanks a lot!
Try later version of check style as checkstyle-8.0-all.jar.
See example
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask" />
taskdef class com.puppycrawl.tools.checkstyle.CheckStyleTask cannot be found
The class is named CheckstyleAntTask.
See https://github.com/checkstyle/checkstyle/blob/master/config/ant-phase-verify.xml on an example on how to use CheckstyleAntTask.
checkstyle-5.6.jar
I recommend upgrading to a newer version. Checkstyle is currently on version 8.
When I run groovyc without the fork option, it works fine. But with fork="true" it fails with an error message:
Error: Could not find or load main class org.codehaus.groovy.ant.FileSystemCompilerFacade
What is wrong here?
Ant task:
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="test.path" />
<groovyc fork="true" srcdir="../myproject/src-test" destdir="${build.test.dir}">
<javac debug="true" source="1.7" target="1.7" >
<compilerarg value="-XX:-UseSplitVerifier"/>
</javac>
</groovyc>
EDIT:
test.path contains a groovy jar:
(...):/home/pkalinow/(..)/groovy-all-1.8.6.jar:(...)
The classpathref="test.path" must be specified in both <taskdef> and <groovyc> invocations when groovyc is forked.
I cannot find any confirmation in the documentation, but it seems, that only non-forking groovyc is inheriting classpath from taskdef.
I have ant build script that compiles and generates the compilation logs(in file compileLog.xml) of my project. I use jdtCompileLogPublisher to publish these results the RTC.
Now the situation is when i have the sources in the project its working fine. When i don't have any sources in the project(this is a one of the requirement that there will be an empty project with out sources), compilation step is skipped as there are no sources,and jdtCompileLogPublisher is failing because, the file compileLog.xml which is an input for this step is not created as compilation itself has been skipped.
I tried creating a new compileLog.xml if it is not available. As a result of this I'm encountering new issues as file is empty.
Why javac is skipped when there are no java files to compile?
Is there any possibility to make the compiler to execute javac in build.xml
Version ant: 1.7.1.
snippet of my code related to :
<target name="compile" depends="prepare" description="Compile the source code">
<mkdir dir="${nameBuild}/${dir.build}/bin" />
<!-- Add target ${label.jdkversion} to make it possible to build with a certain jdk version-->
<javac compiler="org.eclipse.jdt.core.JDTCompilerAdapter" destdir="${nameBuild}/${dir.build}/bin" debug="true" deprecation="on" encoding="ISO-8859-1" source="${buildInfo.jdkVersion}" target="${buildInfo.jdkVersion}" debuglevel="lines,source" failonerror="false" errorProperty="buildFailed">
<compilerarg line="-warn:+raw" />
<compilerarg line="-warn:-serial" />
<compilerarg line="-enableJavadoc" />
<compilerarg line="-log source/${name}/compileLog.xml" />
<src path="${name}/${dir.src}" />
<classpath refid="application.classpath" />
</javac>
<jdtCompileLogPublisher buildResultUUID="${buildInfo.buildResultUUID}" repositoryAddress="${repositoryAddress}" userId="${userId}" passwordFile="${psFile}" filePath="compileLog.xml" />
<fail if="buildFailed" message="Compile ${name} failed." />
</target>
I modified the tag
<jdtCompileLogPublisher buildResultUUID="${buildInfo.buildResultUUID}" repositoryAddress="${repositoryAddress}" userId="${userId}" passwordFile="${psFile}" filePath="compileLog.xml" />
to
<jdtCompileLogPublisher buildResultUUID="${buildInfo.buildResultUUID}" repositoryAddress="${repositoryAddress}" userId="${userId}" passwordFile="${psFile}" filePath="compileLog.xml" failonerror="false" />
Which solved my problem
I have the antcontrib.jar in my lib folder of Ant. I set my ant home as "C/Prog Files/apache-ant".
But still when I run my build.xml, i get the warning "could not load antlib.xml and antcontrib.prop".
Because of this, I am not able to do any "regex" operations.
I properly loaded the antcontrib.jar in the lib folder of the ant.
Where I am wrong here?
Provide resource and classpath in your taskdef correctly as follows
<typedef resource="net/sf/antcontrib/antlib.xml" classpath="<path to ant-contrib.jar>"/>
Here's an example of an Ant script that uses Ant-Contrib's <propertyregex> task:
build.xml
<project name="ant-propregex-simple" default="run">
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<target name="run">
<property name="line.to.test" value="First Second" />
<property name="the.regex" value="^([^ ]*) ([^ ]*)$" />
<propertyregex
input="${line.to.test}"
regexp="${the.regex}"
select="\2"
property="the.match"
/>
<echo>${the.match}</echo>
</target>
</project>
The key is the <taskdef ...> line.
Output
run:
[echo] Second
BUILD SUCCESSFUL
I have the following Sonar Ant target defined:
<target name='sonar'>
<property name='sonar.sources' value='${src.dir}'/>
<property name='sonar.tests' value='${test.src.dir}'/>
<property name='sonar.binaries' value='build/classes'/>
<path id='jars'>
<fileset dir='${env.JAVA_HOME}/jre/lib' includes='*.jar'/>
<fileset dir='build/lib/test' includes='*.jar'/>
</path>
<pathconvert property='sonar.libraries' refid='jars' pathsep=','/>
<exec executable='p4' outputproperty='p4.P4CLIENT'>
<arg value='set'/>
<arg value='P4CLIENT'/>
</exec>
<propertyregex
property='p4client'
input='${p4.P4CLIENT}'
regexp='P4CLIENT=([^ ]+) *.*'
replace='\1'/>
<propertyregex
property='sonar.timestamp'
input='${build.time}'
regexp='_'
replace='T'/>
<sonar:sonar key='com.netflix:${module.name}' version='${p4client}#${sonar.timestamp}' xmlns:sonar='antlib:org.sonar.ant'/>
<property name='sonar.dynamicAnalysis' value='reuseReports'/>
<property name='sonar.emma.reportPath' value='${coverage.dir}'/>
</target>
When I run 'ant sonar' and bring up Sonar in my browser, I see info about the classes in the src directory, but nothing about the stuff in the test directory.
If I add ${test.src.dir} to sonar.sources and not set sonar.tests, I see some info about the test classes, but Sonar still reports 0 Test Successes.
How do I get it so I can drill down to each test method and their stats?
For anyone else that runs across this issue, I finally got Sonar to report on our Emma Code coverage. The first problem was that the Emma plugin did not come with the version of Sonar I was using (3.1.1). I had to download it and install it to the extensions/plugins directory of Sonar and restart it.
Then I had to set the following properties in my build.xml:
<property name="sonar.core.codeCoveragePlugin" value="emma" />
<property name="sonar.emma.reportPath" value="${coverage.dir}" />
After this, I atleast saw the following output after running the Sonar ant task:
[sonar:sonar] 13:41:49.705 WARN org.sonar.INFO - No coverage (*.ec) file found in /my/local/path
[sonar:sonar] 13:41:49.708 WARN org.sonar.INFO - No metadata (*.em) file found in /my/local/path
After some digging, I found that inside of the Sonar Emma plugin, it is hard-coded to look for a .ec (coverage) file and a .em (metadata) file. Unfortunately, my coverage file had a .emma extension as did my metadata file and I was unable to rename them as it would break other functionality. So I wrote the following Ant task to copy the files to match the naming standard that the Sonar Emma plugin expects.
<target name="createEmmaFilesWithSonarNamingStandard" depends="defineAntContribTasks">
<if>
<available file="${coverage.dir}/metadata.emma" />
<then>
<copyfile src="${coverage.dir}/metadata.emma" dest="${coverage.dir}/metadata.em" />
</then>
</if>
<if>
<available file="${coverage.dir}/coverage.emma" />
<then>
<copyfile src="${coverage.dir}/coverage.emma" dest="${coverage.dir}/coverage.ec" />
</then>
</if>
</target>
After running this again, I came across a new problem:
org.sonar.api.utils.SonarException: java.io.IOException: cannot read [/my/local/path/build/coverage/metadata.em]: created by another EMMA version [2.0.5312]
After some more digging, I found that the Sonar Emma 1.0.1 plugin was compiled against Emma 2.0.5312 and the Sonar Emma 1.1 and 1.2.x against Emma version 2.1.5320 as stated on the Sonar Emma plugin page.
I downloaded the 2.1.5320 version of Emma, replaced both emma.jar as well as emma_ant.jar in my Ant lib directory. After a clean re-compile and test, I was able to re-run the Sonar Ant task and have my code coverage reflected on Sonar.
The property 'sonar.surefire.reportsPath' needs to be defined before the definition of the sonar target.
The following definition gets the test info exported (although it's still not exporting coverage info):
<property name='sonar.surefire.reportsPath' value='${test.dir}'/>
<property name='sonar.dynamicAnalysis' value='reuseReports'/>
<property name='sonar.emma.reportPath' value='${coverage.report.dir}'/>
<target name='sonar'>
<property name='sonar.sources' value='${src.dir}'/>
<property name='sonar.tests' value='${test.src.dir}'/>
<property name='sonar.binaries' value='${build.dir}'/>
<path id='jars'>
<fileset dir='${env.JAVA_HOME}/jre/lib' includes='*.jar'/>
<fileset dir='${ivy.lib.dir}/test' includes='*.jar'/>
</path>
<pathconvert property='sonar.libraries' refid='jars' pathsep=','/>
<exec executable='p4' outputproperty='p4.P4CLIENT'>
<arg value='set'/>
<arg value='P4CLIENT'/>
</exec>
<propertyregex
property='p4client'
input='${p4.P4CLIENT}'
regexp='P4CLIENT=([^ ]+) *.*'
replace='\1'/>
<propertyregex
property='sonar.timestamp'
input='${build.time}'
regexp='_'
replace='T'/>
<sonar:sonar key='com.netflix:${module.name}' version='${p4client}#${sonar.timestamp}' xmlns:sonar='antlib:org.sonar.ant'/>
</target>