What should the contents of emma_ant.properties be? - eclipse

I've been following this tutorial on 3. Getting Started (ANT), and it says <taskdef resource="emma_ant.properties" classpathref="emma.lib" /> but does not give any reference to the contents of emma_ant.properties. Any ideas?
Other websites such as 3.4. How do I change an EMMA property default setting? also leave things to be desired (and is based on the command prompt and not a digital file). I've found another website Using EMMA with ANT for JUnit test coverage reporting, but again it leaves the properties file to the imagination (doesn't even provide an example file).
Any ideas on how to manipulate the emma_ant.properties to Load and custom tasks for ANT?

but does not give any reference to the contents of emma_ant.properties. Any ideas?
Check for emma.jar & emma_ant.jar which you have placed in the path specified you will find emma_ant.properties
Any ideas on how to manipulate the emma_ant.properties to Load and custom tasks for ANT?
You need not to manipulate the properties file to use the tasks.
To use emma tasks you should
<!-- directory that contains emma.jar and emma_ant.jar -->
<property name="emma.dir" value="${YOUR_BASE_DIR}/lib/emma" />
<!-- Set emma.lib to refer to the list of EMMA jar files -->
<path id="emma.lib">
<fileset dir="${emma.dir}">
<include name="*.jar" />
</fileset>
</path>
and
<!-- Load <emma> custom tasks so that they can be used in ANT -->
<taskdef resource="emma_ant.properties" classpathref="emma.lib" />
and you should be able to use emma tasks.
Here are the contents of emma_ant.properties inside emma.jar
# -------------------------------------------------------------
emma: com.vladium.emma.emmaTask
emmajava: com.vladium.emma.emmajavaTask
# -------------------------------------------------------------
# end of file
Also Check out Emma Property Summary if it helps you...

Related

Checkstyle Error in eclipse: cannot initialize module FilesFilter - Unable to instantiate FilesFilter

I am using checkstyle 5.7
I have written a custom FilesFilter as explained in the checkstyle documentation below,
http://checkstyle.sourceforge.net/writingfilters.html
As suggested in the documentation, I have written a java file and added an entry for it under "Checker" module in my config xml file.
So, this custom filter is supposed to ignore all files containing string "Test" in it's file name.
<module name="com.mycompany.myproject.filters.FilesFilter">
<property name="files" value="Test" />
</module>
Due to this entry in the config file, the check style is not loading in eclipse and gives following error,
cannot initialize module FilesFilter - Unable to instantiate
FilesFilter
Please help.
I think there is no straight solution for this yet. Or may be there is, if you are prepared to invest hours of your time.
Here's what I did as a workaround.
In eclipse, to disable checkstyles for a package (e.g. Test package in my case),
Go to, Project -> Properties -> Checkstyle
On Checkstyle Main tab, there is section "Exclude from checking.." with a set of check boxes.
Select the check box "files from packages:".
Click the "Change.." button in the right hand corner or just double click on "files from packages:"
Select the package you want Checkstyle to ignore. In my case I selected com/myproject/test/ package, and that was it. Checkstyle ignores all files in the test package.
If you are using Checkstyle as an ANT task, you may use excludes option as explained in the following code,
<target name="applyCheckStyle" depends="build" description="--> apply check style to all java files, excluding test package.">
<checkstyle config="${checkstyle.config}">
<fileset dir="${src.dir}" includes="**/*.java" excludes="**/test/**" />
<formatter type="plain" />
<formatter type="xml" toFile="${build.dir}/checkstyle_errors.xml" />
</checkstyle>
</target>
This worked for me :)

NAnt: How to Load External NAnt Scripts Inside A Custom Task

In short, my problem is:
How to load an NAnt script in side a custom task, and execute it?
Detailed explanation:
In our current project build, we need to execute external programs. The external programs need to be located before the build kicks off. (coz it takes so looong time)
What I want is to have some NAnt module, like those FindXXX.cmake modules in CMake, so I can have modules like:
<?xml version="1.0"?>
<project name="FindSQLServerCore" default="FindSQLServer">
<target name="FindSQLServer">
<module>
<path>
<pathelement dir="C:\Program Files\Microsoft SQL Server\100\Tools\Binn" />
<pathelement dir="C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn" />
</path>
<files>
<file name="SQLCmd.exe" />
</files>
</module>
</target>
</project>
And when I need to include SQLServer in my build script, I can do:
<find module="SQLServer" required="true" />
My way to do it is by create 2 custom tasks: FindTask & ModuleTask.
FindTask is going to locate the FindXXX.include and loaded it into current NAnt project.
ModuleTask is going to find specified file under given path and return results.
But I cannot find ways to create & execute NAnt tasks by loading a build script in FindTask. The Project.CreateTask(XmlNode) only accepts node that is already loaded but not from newly loaded XML.
Is there a way to create task by loading a build script inside a custom task?
Or is my way doing this the NAnt style? Any better ways to achieve same goal?
PS. You might ask why not just use
<include file="FindSQLServer.include" />
The reason I'm not doing it this way is I want to pass the required parameter in, but not set it as a variable and pass it in.
You can get the NANT extension here:NAntFind#github
One way to load an NAnt script and execute it inside a custom task is to create a new project, and load the script using the project, then execute. Example:
var findProject = new Project(nantModule, Level.Info, Project.IndentationLevel);
findProject.Execute();
If the project fails, an exception should be thrown out.

NAnt - Including source files in a csc task outside of the base directory

I am just starting to pick up NAnt as a replacement for MSBuild in our CruiseControl project.
One of the things we do inside a set of projects is link in a single AssemblyInfo.cs file from outside of the project tree to make versioning easier (it lives in a directory above the project folders).
Is there an obvious way of achieving this in the <sources> section of the <csc> task?
From what I can tell, the <sources> section only supports a single <include> element, which must be underneath the basedir of the task.
I suppose another option would be to copy the single AssemblyInfo.cs file as part of the task prior to calling csc, but wondered whether there was a cleaner way of doing this.
You are not limited to a single <include/> in <sources/>. You can reference whatever you want if you don't specift the basedir property of <sources/>:
<csc target="exe" output="HelloWorld.exe" debug="true">
<sources>
<!-- Will use project dir as base dir -->
<include name="**/*.cs" />
<!-- Absolute path -->
<include name="/tmp/42/*.cs" />
<!-- Relative to project dir -->
<include name="../../Shared/*.cs" />
</sources>
<references>
<include name="System.dll" />
<include name="System.Data.dll" />
</references>
</csc>

Is it possible to override nant targets from included buildfile?

I have a generic common.xml file that holds a number of generic nant targets that are re-used among multiple builds. What I want to do is 'override' some of these nant targets and include additional steps either before or after the existing target is executed.
Are nant targets used from the current file first? ie. If i create a nant target in the current buildfile with the same name as a target in an included file does that one get called and the included one ignored? If that's the case I can just do and call the included target but it would seem like then that would be a recursive call rather then to an included task.
Thoughts?
I had the same question (and found the same results), but I also found a workaround. Allow me to illustrate with an example.
You have a ProjectFile.build and a CommonFile.build. Let's say you want to overwrite a target called "Clean".
You would need to create a new file (call it CommonFile_Clean.build) which contains:
<?xml version="1.0"?>
<project>
<target name="Clean">
<echo message="Do clean stuff here" />
</target>
</project>
In CommonFile.build, you conditionally include CommonFile_Clean.build:
<?xml version="1.0"?>
<project>
<echo message="checking Clean definition..." />
<if test="${not target::exists('Clean')}">
<echo message="Clean target not defined." />
<include buildfile="CommonFile_Clean.build" />
</if>
</project>
In ProjectFile.build, you can either define the Clean target (in which case CommonFile_Clean.build will not be used) or use the default implementation as defined in CommonFile_Clean.build.
Of course, if you have a large number of targets, this will be quite a bit of work.
Hope that helps.
No, I've just tried it for you, as I have a similar set-up, in that I have all of the build targets we use in a commonFile.build and then use the following code to bring it in...
<include buildfile="../commonFile.build"/>
In my newFile.build (that includes the commonFile.build at the top of the file), I added a new target called 'build', as it exists in the commonFile, and here's the error message you get in response...
BUILD FAILED
Duplicate target named 'build'!
Nice idea, probably bourne of OO principles, but sadly it doesn't work.
Any good?

How can I automate compiling a large Java project?

I'm working on an automation project for my employer. We have a pool for each revision of our source code. When you download a revision, you need to create a directory structure with a bunch of third party includes to eventually build the project. I've automated this entire process up to the point of having my script (.bat) compile each particular runnable java application. There are many applications to this single project, and the directory listing looks something like this:
Proj Name
-variousincludesfolder1
-variousincludesfolder2
-variousincludesfolder3
-variousincludesfolder4
-runnableapplicationsandmoreincludes
-con.java
Right now, I'd like to do an automated compiling of con.java, but I don't know where to begin. People have suggested I try Ant, but any automated Ant file generation I get using Eclipse seems only enough to build con.java while an active project file exists. Is there anyway to automate this without using eclipse, to the point of having the batch file generate a .jar itself?
This is definitely a job for Ant. Don't rely on Eclipse-generated Ant files; read through the manual and write one yourself. (You'll likely find out that Ant does things you didn't think of doing in your build script, too.)
To be more specific, here is the documentation for the jar task.
You can define wildcard and pattern matches to include/exclude all sorts of files and folders in your build. Take a look at the Ant manual to see how things like filesets work with include and exclude filters.
Also, read the tutorial.
Here is a simple build file that looks to compile all java files and reference all jars. Place it in the top level directory:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl"
href="http://www.ibm.com/developerworks/xml/library/x-antxsl/examples/example2/ant2html.xsl"?>
<project name="Proj Name" default="build" basedir=".">
<property name="src.dir" value="${basedir}" description="base folder where the source files will be found. Typically under /src, but could be anywhere. Defaulting to root directory of the project" />
<property name="build.dir" value="build" description="Where to put build files, separate from src and resource files." />
<path id="master-classpath">
<fileset dir="${basedir}" description="looks for any jar file under the root directory">
<include name="**/*.jar" />
</fileset>
</path>
<target name="build" description="Compile all JAVA files in the project">
<javac srcdir="${src.dir}"
destdir="${build.dir}/classes"
debug="true"
deprecation="true"
verbose="false"
optimize="false"
failonerror="true">
<!--master-classpath is defined above to include any jar files in the project subdirectories(can be customized to include/exclude)-->
<classpath refid="master-classpath"/>
<!--If you want to define a pattern of files/folders to exclude from compilation...-->
<exclude name="**/realm/**"/>
</javac>
</target>
</project>