How to make ccnet update multiple projects independently in a single mercurial repo? - mercurial

I have a central hg repository with multiple subprojects in it. Somewhat like this:
/Hg_central
/subproject-a
/subproject-b
/...
I am trying to set up a cc.net server so that it builds a subproject ONLY if its directory has been updated.
My current problem is once one of the subprojects has been updated and built, the server will not find any modifications for the other subprojects, since mercurial has updated the whole repository. CC.NET will not build the other subprojects, unless another update has been done. I've tried using inclusionFilters without success. I also can't afford to have a seperate WorkingDirectory for each subproject. What am I missing to make this possible?
My ccnet config file is currently like this:
<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
<project name="subproject-a">
<workingDirectory>G:\Hg-clone\</workingDirectory>
<triggers>
<intervalTrigger name="continuous" seconds="60" buildCondition="IfModificationExists" initialSeconds="20" />
</triggers>
<sourcecontrol type="filtered">
<inclusionFilters>
<pathFilter>
<pattern>/subproject-a/**/*</pattern>
</pathFilter>
</inclusionFilters>
<sourceControlProvider type="hg" autoGetSource="true" >
<repo>http://myserver/myproject</repo>
<multipleHeadsFail>false</multipleHeadsFail>
</sourceControlProvider>
</sourcecontrol>
<tasks>
<exec>
<executable>mybuild.bat</executable>
</exec>
</tasks>
</project>
<project name="subproject-b">
<workingDirectory>G:\Hg-clone\</workingDirectory>
<triggers>
<intervalTrigger name="continuous" seconds="60" buildCondition="IfModificationExists" initialSeconds="20" />
</triggers>
<sourcecontrol type="filtered">
<inclusionFilters>
<pathFilter>
<pattern>/subproject-b/**/*</pattern>
</pathFilter>
</inclusionFilters>
<sourceControlProvider type="hg" autoGetSource="true" >
<repo>http://myserver/myproject</repo>
<multipleHeadsFail>false</multipleHeadsFail>
</sourceControlProvider>
</sourcecontrol>
<tasks>
<exec>
<executable>mybuild.bat</executable>
</exec>
</tasks>
</project>
</cruisecontrol>

With svn this works like a charm, so i'm a bit surprised mercurial isn't.
Either way, a possible workaround is to define a single project whose purpose is to update source and all other project should have a Project trigger for that project.
HTH

Related

When should I rewrite my dll when using coyote to write unit test?

I am trying to write some unite tests based on coyote.
I found that in the tutorial I should rewrite my assembly before coyote test command.
However, when integrate coyote tests into unit test platform using TestingEngine, it explored bugs without doing any rewriting manually.
Did I doing the right thing? If I can explore the bug without rewriting assembly, what the operate exactly works for?
Thank you!
In that case, the easiest option is to rewrite during your build.
Add the following to .csproj.
<ItemGroup>
<None Update="rewrite.coyote.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="CoyoteRewrite" AfterTargets="AfterBuild">
<Exec Command="dotnet tool run coyote rewrite$(OutputPath)/rewrite.coyote.json -v info" />
</Target>
You have to put your rewrite.coyote.json in your project's root folder (next to your .csproj and set the AssembliesPath to ..
My rewrite.coyote.json looks like:
{
"AssembliesPath": ".",
"Assemblies": [
"MySut.dll",
"MySut.UnitTests.dll",
"MySut.Coyote.dll"
],
"IsRewritingConcurrentCollections": "false"
}

NoClassDefFoundError when checkstyle is running

I have written a new checkstyle check as a filescanner. I modeled my junits after the code I found in the checkstyle code. The junits run just fine and everything looks good.
But then, I add the check to my project.
<module name="TreeWalker">
<property name="tabWidth" value="4" />
<module name="com.onuspride.codetools.checkstyles.DuplicateClassNames"/>
</module>
and my ant task
<taskdef resource="checkstyletask.properties">
<classpath refid="classpath" />
</taskdef>
<property name="checkstyle.suppressions.file" value="checkstyle/suppressions.xml" />
<property name="translation.severity" value="error" />
<target name="checkStyle" description="TestTask to evaluate the checkstyle system.">
<checkstyle config="checkstyle/checkstyle_checks.xml">
<fileset dir="${msg.src}" includes="**/*.java" />
<formatter type="plain" />
<formatter type="xml" toFile="${msg.build.jar}/checkstyle_errors.xml" />
<classpath refid="classpath" />
</checkstyle>
</target>
the duplicateclassnames class calls several classes in the same jar. For some reason, when ant runs it, ant finds the check class, but can't find the supporting classes, when they are all in the same jar file. here's what i get in ant
[checkstyle] [class]:0: Got an exception - java.lang.NoClassDefFoundError: com/onuspride/codetools/common/classpath/criteria/ClassNameCriteriaCollector
Im stumped. Ive checkd all the dependencies of my jar, they are all in the classpath, I don't understand how it can find one class file but not another in the same jar. Ive done all my dirty little tricks and I just don't get it.
any ideas?
You can do it like following :
Create plugin project and add your custom checks there.
Make appropriate changes to plugin.xml, checkstyle_packages.xml.
Export the project as Deployable Plug-ins and fragments (Export > Plug-in Developement)
Copy the jar file to Eclipse Plugin folde, so no need to install your custom check .
You can go through this tutorial for reference
To reduce effort, download a Sample Check, the file is here under the name net.sf.eclipsecs.sample
Just replace your source in src folder. Before replacing, refer this 3 files in src/net/sf/eclipsecs/sample/checks/ directory as you will need them in your com/onuspride/codetools/checkstyles/ directory :
checkstyle-metadata.properties
checkstyle-metadata.xml
messages.properties
After replacing the code, make appropriate changes in checkstyle_packages.xml file in src/ directory.
Extending Check is described nicely there.

CruiseControl unable to recognize modifications for Mercurial repository

I am trying to implement a continuous build stack, and decided to use CruiseControl with Ant. However, it seems that CruiseControl is having problem picking up the changes from my Mercurial directory. Here's some code from config.xml with a bunch of unnecessary elements taken out. One workaround I found was to set requiremodification to false, which will build the software regardless of the changes made. Am I missing something here? Or is this a bug of CruiseControl.
<!--config.xml-->
<project name="test_runner" buildafterfailed="false"
requiremodification="true" forceonly="${test_runner.inactive}">
<listeners>
<currentbuildstatuslistener file="${projectLogsDir}/status.txt" />
</listeners>
<bootstrappers>
</bootstrappers>
<modificationset quietperiod="${quietPeriod}">
<mercurial localworkingcopy="${mercurialDir}/solution1" property="solution1_changed" />
</modificationset>
<schedule interval="${scheduleInterval}">
<ant liveOutput="true" />
</schedule>
</project>
In CruiseControl.Net the server logs which command it performs to check for changes. You can check if this command is correct by running it yourself on the command line. I had the same issue with Perforce, and by running the command myself I found out that I had configured an incorrect view.
Note that I'm much more familiar with CruiseControl.Net than CruiseControl, so this might not apply to CruiseControl.

Converting CruiseControl from CVS to Mercurial

We have an existing cc configuration that was setup by someone before I got here.
We've converted our repository from cvs to mercurial stored on bitbucket.
Everything in my question below is basically just wondering, where do I point to the bitbucket repository in my setup to check for changes? And information about my specific setup.
Looking at how the cvs projects were set up, we have a config.xml and a projectbuild.xml file that contain information about the repository.
I've found the documentation for tag options for the config.xml here :
http://cruisecontrol.sourceforge.net/main/configxml.html
but I'm not sure where I can actually look at the bitbucket repository to check for changes. I assume this would be in the projectbuild.xml file, but I'm not sure what the tag options would be for mercurial. I'm more than happy to be pointed toward some documentation, all I've been able to find is stuff on the config.xml.
Here is part of my config.xml and my projectbuild, or build-tnl-default.xml file as it's called for my specific case:
config.xml (Notice I don't have bootstrappers in this file, I've seen this in other examples and am not sure if this would help me.
<modificationset quietperiod="900">
<mercurial localworkingcopy="projects/${project.name}">
</modificationset>
<schedule interval="100">
<ant anthome="C:\usr\local\apache-ant"
antworkingdir="projects/${project.name}"
buildfile="build-tnl-default.xml"
uselogger="true"
usedebug="false"
propertyfile="C:\usr\local\ia\build.properties"/>
</schedule>
build-tnl-default.xml:
<project name="build-tnl-default"
default="build">
<target name="build">
<!-- Get the latest from mercurial -->
<mercurial>
<!-- Call the target that does everything -->
<ant antfile="build.xml" dir="tnl" target="all"/>
</target>
</project>
Here I have no idea what options are available to me in the mercurial tag. I assume I just need to point this to the repository on bitbucket? In the previous version, it looked like this was pointing to the cvs repository here. I'm just not sure what the mercurial attributes are.
I'm sorry about my newness with this stuff, I might require a little more explanation than many other users. Any help is appreciated. Thanks
You check for updates in your repository (regardless whereever it is hosted) via
<modificationset quietperiod="900">
<mercurial localworkingcopy="projects/${project.name}">
</modificationset>
These tags say, that you query the repository you've checked out under projects/${project.name} and that a build is triggered if within a time frame of 15 minutes (900 seconds) no further changes occured. (I think that 15 minutes is a bit much, btw)
Simply make sure that projects/${project.name} is a Mercurial project that was checked out via hg clone http://repositoryAtBitbucketAsAnExample projects/${project.name} (make sure to expand ${project.name}).
I did not fully understand what build-tnl-default.xml is supposed to do, but if it should grab the newest build.xml, you should think about doing it with an Execootstrapper running something like hg pull ${path.to}/build.xml.
I have no idea what options are available to me in the mercurial tag.
You should determine the <taskdef .../> is used that loads the mercurial tag. This should be somewhere in build-tnl-default.xml or a file that is imported by it.

copying a jar file in Apache Ant

I need to copy a jar file from one directory to another when my project is built. Placing the statement:
<copy file="${test.dir}/MyFirstTest.jar" todir="${share.path}"/>
works fine when the project is built alone, but if I clean and build the project I get a warning informing me that the ${test.dir}/ directory hasn't been created yet. If I'm understanding properly I should be able to create a 'target' and specify a dependency for this operation but I'm unsure of what dependency to specify. What series of statements do I need to use to ensure this copy will occur whether I clean and build or just build the project?
Please let me know if any further clarification is needed.
FYI I am using Netbeans 6.8 to build my project.
Assuming you have build, dist and javadoc folders do this in the clean.
<!-- Remove all output generated from this build script -->
<target name="clean" description="Clean project">
<delete dir="${build}" />
<delete dir="${dist}" />
<delete dir="${javadoc}" />
</target>
<!-- Initialize all elements needed for the Build -->
<target name="init">
<!-- Create the time stamp -->
<tstamp />
<!-- Create the build directory structure used by compile
and copy the deployment descriptors into it-->
<mkdir dir="${build}/classes" />
<mkdir dir="${dist}" />
<mkdir dir="${javadoc}" />
</target>
<!-- Write a target such as this -->
<target name="docopy" depends="init" description="do the copy">
<copy file="${test.dir}/MyFirstTest.jar" todir="${dist}"/>
</target>
When you run ant docopy It will run init first and then the docopy task.
You can create other tasks that have a depends="docopy" in it or move the copy file task to the init itself.
If I'm understanding properly I should be able to create a 'target' and specify a dependency for this operation but I'm unsure of what dependency to specify.
Well, either add a dependency to the target that actually creates ${share.path} if that makes sense or introduce a new target to create the directory if it doesn't exists. This is typically done is some kind of init target. Then, add the dependency like this:
<target name="copy-jar" depends="target-a, target-b">
<copy file="${test.dir}/MyFirstTest.jar" todir="${share.path}"/>
</target>
You could also simply try to create the directory before to copy the library:
<mkdir dir="${share.path}" failonerror="false">
<copy file="${test.dir}/MyFirstTest.jar" todir="${share.path}"/>