<path id="checkstyle.classpath">
<fileset dir="${basedir}/lib/">
<include name="checkstyle-6.12.1-all.jar" />
</fileset>
</path>
<target name="checkstyle">
<!-- CheckStyle -->
<taskdef resource="checkstyle.properties" classpath="C:\Users\Pil\Desktop\Workspace2\Cs376bDemoApp\lib
\checkstyle-6.12.1-all.jar" />
<checkstyle config="DsrJavaFormattingProfile.xml" classpath="C:\Users\Pil\Desktop\Workspace2\Cs376bDemoApp\lib
\checkstyle-6.12.1-all.jar" />
<fileset dir="${src}" includes="**/*.java" />
</target>
This is my checkstyle target in my build.xml file. I have spent the past 6 hours debugging this before resorting to StackOverFlow but my best efforts proved fruitless. I am consistently met with the error report [taskdef] Could not load definitions from resource checkstyle.properties. It could not be found.
BUILD FAILED
C:\Users\Pil\Desktop\Workspace2\Cs376bDemoApp\build.xml:86:
Problem: failed to create task or type checkstyle
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
My intention for this code is for it to use my DsrJavaFormattingProfile.xml on the .java files in my src directory. I have tried replacing the class path with the relative path "lib/" and with the checkstyle.classpath path above aswell as every possible other solution I could think of.
<taskdef resource="checkstyle.properties" classpathref="checkstyle.classpath" />
<checkstyle config="DsrJavaFormattingProfile.xml" classpathref="checkstyle.classpath" />
also resulted in the same error. Please save me StackOverFlow, I need a hero.
https://www.youtube.com/watch?v=OBwS66EBUcY
Update: Solved by CAustin
`
<target name="checkinit">
<path id="checkstyle.lib.path">
<fileset dir="lib" includes="checkstyle8.8all.jar" />
</path>
<taskdef resource="com/puppycrawl/
tools/checkstyle/ant/checkstyle-ant-task.properties" classpathref="checkstyle.classpath" />
</target>
<target name="checkstyle" depends="checkinit">
<!-- CheckStyle -->
<checkstyle config="${basedir}\DsrCheckStyleConfig.xml" classpathref="checkstyle.lib.path">
<path refid="project.sourcepath" />
</checkstyle>
</target>`
Related
I'm trying to create an ant script to run pitest to be able to automate my mutation testing. I am getting the error:
Could not find or load main class org.pitest.mutationtest.commandline.MutationCoverageReport
This is my MutationTest.xml ant script
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="mutationCoverage" name="PhoneBook">
<property name="ECLIPSE_HOME" value="C:/Program Files/eclipse/"/>
<path id="JUnit 4.libraryclasspath">
<pathelement location="${ECLIPSE_HOME}plugins/org.junit_4.11.0.v201303080030/junit.jar"/>
<pathelement location="${ECLIPSE_HOME}plugins/org.hamcrest.core_1.3.0.v201303031735.jar"/>
</path>
<path id="PhoneBook.classpath">
<pathelement location="bin"/>
<path refid="JUnit 4.libraryclasspath"/>
</path>
<path id="pit.path">
<pathelement location="lib/pitest-1.1.4.jar" />
<pathelement location="lib/pitest-ant-1.1.4.jar" />
</path>
<taskdef name="pitest" classname="org.pitest.ant.PitestTask" classpathref="pit.path" />
<target name="mutationCoverage">
<pitest
pitClasspath="PhoneBook.path"
classPath="PhoneBook.path"
targetClasses="pbook.*"
targetTests="pbook.*"
reportDir="MutationReports"
sourceDir="src"/>
</target>
</project>
What is causing this error, and how can I fix it?
Edit: I changed pitClasspath="PhoneBook.path" to pitClasspath="pit.path" and now I have a new error:
[pitest] Exception in thread "main" org.pitest.util.PitError: Unable to load class content for org.pitest.boot.HotSwapAgent
[pitest] Please copy and paste the information and the complete stacktrace below when reporting an issue
[pitest] VM : Java HotSpot(TM) 64-Bit Server VM
[pitest] Vendor : Oracle Corporation
[pitest] Version : 25.25-b02
[pitest] Uptime : 370
[pitest] Input ->
[pitest] BootClassPathSupported : true
[pitest] at org.pitest.mutationtest.tooling.JarCreatingJarFinder.classBytes(JarCreatingJarFinder.java:124)
[pitest] at org.pitest.mutationtest.tooling.JarCreatingJarFinder.addClass(JarCreatingJarFinder.java:113)
[pitest] at org.pitest.mutationtest.tooling.JarCreatingJarFinder.createJarFromClassPathResources(JarCreatingJarFinder.java:98)
[pitest] at org.pitest.mutationtest.tooling.JarCreatingJarFinder.createJar(JarCreatingJarFinder.java:74)
[pitest] at org.pitest.mutationtest.tooling.JarCreatingJarFinder.getJarLocation(JarCreatingJarFinder.java:63)
[pitest] at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:70)
[pitest] at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:43)
[pitest] at org.pitest.mutationtest.commandline.MutationCoverageReport.runReport(MutationCoverageReport.java:72)
[pitest] at org.pitest.mutationtest.commandline.MutationCoverageReport.main(MutationCoverageReport.java:43)
I don't know if that is better or worse, but hopefully it will be helpful in finding the problem.
A working example of a pitest ant build is provided at
https://github.com/hcoles/pitest-ant-example
I suggest you start with this and edit it until you have a working build for your codebase.
One difference I can see is that you have not included junit on the pitest path.
Your build looks a little strange as it seems to be tied to eclipse. If you are running from the IDE why not use the eclipse plugin?
Also, if you are not tied to Ant, you might want to consider maven as an alternative.
I believe much of your problem is that you're trying to use the Eclipse generated build.xml file, which doesn't contain the mutation testing target, and the target which you've added to remedy this has some errors.
I would suggest starting with the project here and attempting to understand how it works, and then changing their build.xml file to fit your needs.
However if this doesn't work, judging from your other question, the following build.xml should work if:
You divide your files into two source directories "src" and "test"
Both src and test folders contain the package "pbook"
You change the name of your tests to end in "Test" rather than begin in it
<?xml version="1.0" encoding="UTF-8"?>
<project name="Phonebook">
<property name="classOutputDir" value="build" />
<!-- classpath for pitest and any plugins -->
<path id="pitest.path">
<!-- must currently include the test library on the tool classpath. this will be fixed in a future version-->
<pathelement location="lib/junit-4.9.jar" />
<pathelement location="lib/pitest-0.33.jar" />
<pathelement location="lib/pitest-ant-0.33.jar" />
</path>
<taskdef name="pitest" classname="org.pitest.ant.PitestTask" classpathref="pitest.path" />
<target name="clean">
<delete dir="${classOutputDir}" />
</target>
<target name="compile" depends="clean">
<mkdir dir="${classOutputDir}/classes" />
<!-- Essential that line numbers and filenames are included in order for PIT to work -->
<javac srcdir="src" includeantruntime="false" debug="true" debuglevel="source,lines" destdir="${classOutputDir}/classes" />
</target>
<!-- classpath for compiling and testing the code. Note it does not include pitest and it's dependencies -->
<path id="test.path">
<pathelement location="${classOutputDir}/classes" />
<pathelement location="${classOutputDir}/test-classes" />
<pathelement location="lib/junit-4.9.jar" />
</path>
<target name="test" depends="compile">
<mkdir dir="${classOutputDir}/test-result" />
<mkdir dir="${classOutputDir}/test-classes" />
<javac includeantruntime="false" srcdir="test" destdir="${classOutputDir}/test-classes">
<classpath refid="test.path" />
</javac>
<junit>
<classpath refid="test.path" />
<batchtest todir="${classOutputDir}/test-result">
<!-- set test classes -->
<fileset dir="test">
<include name="**/*Test.java" />
</fileset>
<formatter type="xml" />
</batchtest>
</junit>
<junitreport todir="${classOutputDir}/test-result">
<fileset dir="${classOutputDir}/test-result">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${classOutputDir}/test-result/report" />
</junitreport>
</target>
<!-- run pitest. note that the filters for tests and classes refer to package/class names, not source file named -->
<target name="pit" depends="test">
<path id="mutation.path">
<path refid="pitest.path"/>
<path refid="test.path"/>
</path>
<pitest pitClasspath="pitest.path" threads="2" classPath="mutation.path" targetTests="pbook.*" targetClasses="pbook.*" reportDir="pitReports" sourceDir="src" />
</target>
</project>
I am trying to convert a web service from using the version of ant that comes with weblogic (OFM 11G Release 1 (10.3.6)) to a newer, standalone version of ant (1.8.4). During the build with 1.8.4 I am receiving the following warnings which I would like to eliminated if possible. The warning occurs with all exception classes in the project. Can anyone provide a suggestion? I am new to weblogic web services.
[jwsc] [WARNING] skipping exception constructor for ca.bc.gov.webade.WebADEException: could not find property corresponding to ctor param 'arg0' on public WebADEException(java.lang.String,java.lang.Exception)
Here is the JWSC portion of the build file. The task is defined using the same paths as part of the build classpath below. The weblogic paths correspond to to WLS_HOME and MODULES_DIR environment variables as set by weblogic.
<target name="jwsc" depends="compile">
<path id="JWSCclasspath">
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${webade.lib.dir}" includes="*.jar" />
<!-- Reference compiled classes rather than jar file due to issue deleting the jar file at the end of the build -->
<pathelement path="${build.bus.dir}"/>
<pathelement path="{weblogic.dir}"/>
<fileset dir="${weblogic.dir}" >
<include name="*.jar" />
</fileset>
<pathelement path="${weblogic.modules}" />
<fileset dir="${weblogic.modules}" >
<include name="*.jar"/>
</fileset>
</path>
<jwsc srcdir="${src.dir}" destdir="${deploy.dir}" classpathref="JWSCclasspath">
<jws file="${war.path}/MapViewerServicesPortTypeImpl.java" type="JAXRPC">
<WLHttpTransport contextPath="mapViewer" serviceUri="MapViewerWS" portName="MapViewerServicesPort"></WLHttpTransport>
</jws>
</jwsc>
</target>
Following the example given at http://www.jooq.org/doc/2.4/manual/META/Configuration/#N10607 on how to run the jooq code-generation I ran into the problem that the build fails with the message:
codegen.xml:7: taskdef class org.jooq.util.GenerationTask cannot be found
For a reference, here is codegen.xml
<project name="..." default="generate-test-classes"
basedir=".">
<property name="path.to.jooq.distribution" value="${basedir}/libs"/>
<property name="path.to.mysql.driver" value="${basedir}/libs"/>
<property name="mysql.driver" value="mysqlcon"/>
<!-- Task definition -->
<taskdef name="generate-classes" classname="org.jooq.util.GenerationTask">
<classpath>
<fileset dir="${path.to.jooq.distribution}">
<include name="jooq.jar" />
<include name="jooqmeta.jar" />
<include name="jooqcodegen.jar" />
</fileset>
<fileset dir="${path.to.mysql.driver}">
<include name="${mysql.driver}.jar" />
</fileset>
</classpath>
</taskdef>
<!-- Run the code generation task -->
<target name="generate-test-classes">
<generate-classes jdbcurl="jdbc:mysql://localhost:3306/crawler"
jdbcuser="..." jdbcpassword="..." generatordatabaseinputschema="..."
generatortargetpackage="model.persistence.jooq"
generatortargetdirectory="${basedir}/src" />
</target>
</project>
I triple checked the definition of the classpath and every file listed exists under the given location. So what would be the problem? Am I missing something? Do I need to configure ant somewhere to recognize the task?
Since I already checked ant: failed to create task or type, I tried to move the taskdef inside the target, but to no avail.
The ant task was an example implementation in jOOQ 2.x. It has been deprecated a long time ago and removed from jOOQ 3.0:
http://www.jooq.org/notes.php?version=3.0
https://github.com/jOOQ/jOOQ/issues/1118
http://www.jooq.org/doc/3.1/manual/code-generation/codegen-configuration/#N12E23
The version of the manual that you've linked is quite outdated.
I have an ant build script that has the following targets:
<target name="_initLiveProps">
<property file="buildscripts/live.properties"/>
</target>
<target name="buildLive" depends="_initLiveProps">
<property file="buildscripts/live.properties"/>
</target>
Within the build script i have several pathelements declared as shown below:
<path id="project.class.path">
<pathelement location="./../lib/log4j-1.2.16.jar" />
<pathelement location="${product-def.jar}"/>
</path>
The product-def.jar definition is defined in the buildscripts/live.properties file as
product-def.jar=./../lib/product-def/live/product-def.jar
When i build the project (using ant buildLive) i get compilation errors and mainly because it cannot find classes defined within product-def.jar.
I tried to print out the classpath as shown below
<property name="myclasspath" refid="project.class.path"/>
<echo message="${myclasspath}" />
And the output comes out as c:\product\lib\log4j-1.2.16.jar;c:\product\${product-def.jar}
The above suggests that the following definition is not correct
<pathelement location="${product-def.jar}"/>
What is the correct way of defining a path element that is defined in a properties file?
Edit
I think the issue is that the definition for project.class.path is initialised before the properties file is loaded in the buildLive target.
Is there a way to delay the initialisation of project.class.path until after buildLive target has completed?
Is there a way to delay the initialisation of project.class.path until after buildLive target has completed?
Put the <path> definition inside the <target>
<target name="_initLiveProps">
<property file="buildscripts/live.properties"/>
<path id="project.class.path">
<pathelement location="./../lib/log4j-1.2.16.jar" />
<pathelement location="${product-def.jar}"/>
</path>
</target>
The <path> will be visible to all targets that depend (directly or indirectly) on this one.
If you have several different targets that load different properties, e.g. _initLiveProps, _initDevProps, etc. then you could put the <path> definition into a common target as follows
<target name="classpath">
<path id="project.class.path">
<pathelement location="./../lib/log4j-1.2.16.jar" />
<pathelement location="${product-def.jar}"/>
</path>
</target>
<target name="_loadLiveProps">
<property file="buildscripts/live.properties"/>
</target>
<target name="_initLiveProps" depends="_loadLiveProps, classpath" />
<target name="_loadDevProps">
<property file="buildscripts/dev.properties"/>
</target>
<target name="_initDevProps" depends="_loadDevProps, classpath" />
I tried to get Cobertura running inside my ant script, but I'm stuck right at the beginning. When I try to insert the cobertura taskdef I'm missing the Log4J libraries.
Ant properties & classpath
<property name="cobertura.dir" location="/full/path/to/cobertura-1.9.3" />
<path id="cobertura.classpath">
<fileset dir="${cobertura.dir}">
<include name="cobertura.jar" />
<include name="lib/**/*.jar" />
</fileset>
</path>
<taskdef classpathref="cobertura.classpath" resource="tasks.properties" />
My ant target
<!-- =================================
target: cobertura
================================= -->
<target name="cobertura" depends="clean, init" description="Generates cobertura coverage reports">
<cobertura-instrument todir="${dir.build.instrumented}">
<fileset dir="${dir.build}">
<include name="**/*.class" />
</fileset>
</cobertura-instrument>
</target>
I think I did everything like it is described in the Cobertura documentation but I get this
Ant build error
BUILD FAILED
build.xml:95: java.lang.NoClassDefFoundError: org/apache/log4j/Logger
Inside the ${cobertura.dir} there is the lib directory with all files. I unzipped it from the cobertura distribution ZIP directly into that directory.
Am I missing a step? Something wrong with my configuration so far?
I also encountered this problem today and solved it by specifying the location of all the required libraries as part of the class path provided to my taskDef task.
<path id="cobertura.class.path">
<pathelement location="${common.dir}/../tools/cobertura/cobertura.jar" />
<pathelement location="${common.dir}/../tools/cobertura/lib/asm-3.0.jar" />
<pathelement location="${common.dir}/../tools/cobertura/lib/asm-tree-3.0.jar" />
<pathelement location="${common.dir}/../tools/cobertura/lib/log4j-1.2.9.jar" />
<pathelement location="${common.dir}/../tools/cobertura/lib/jakarta-oro-2.0.8.jar" />
</path>
<taskdef classpathref="cobertura.class.path" resource="tasks.properties" />
Go to your ant/lib dir and make sure there is NO file cobertura.jar there. If it's there - remove it and try again.
Change this
<include name="lib/**/*.jar" />
to
<include name="*.jar" />
Hope this helps!
I just upgraded to the latest cobertura and mine works fine. Is it possible that something else is on the CLASSPATH with a different version of log4j so it is picking up wrong one?
Make sure that classpath used in taskdef and cobertura-instrument are the same. This helped me with the same issue.
I too faced this problem, I just added all jars given with cobertura in the classpath to resolve this issue