Cant get Junit to work with Spring in an ANT build - spring

I am trying to get Spring MVC and Junit working with eachother and I am having trouble configuring the build.xml file. I am fairly new at using ANT and do not really understand all the tutorials. I put the junit.jar file in the lib direcotory, but still am getting the following message from my console.
test:
BUILD FAILED
C:\Java\mmz\WEB-INF\build.xml:63: The <classpath> for <junit> must include junit.jar if not in Ant's own classpath
Total time: 223 milliseconds
Edit
Here is an example of wanting to run just one test
and I am not sure what I need to do, i tried doing something like the following, but I dont quite understand what its doing, so I dont know how to make changes
<path id="classpath.test">
<pathelement location="" />
<pathelement location="${test.dir}" />
</path>
<target name="test">
<junit>
<classpath refid="classpath.test" />
<formatter type="brief" usefile="false" />
<test name="TesterTest" />
</junit>
</target>
I am pretty lost on what to do next. Thanks

If you copy-pasted your build.xml file then there is probably a classpath element somewhere. Probably near the top of the file. In that element they have probably listed some paths and/or files. You need to add the junit jar to this section.

Related

How to install updates on Progress-4GL programs

Good afternoon,
In my company, we are regularly doing updates on customers' systems, all Progress-4GL technology. Currently we are doing all this manually, and I'd like to automate this.
The following actions are needed:
Take a dump (*.df) of the current database
Upload modifications to the database (*.df files)
compile *.w and *.p files.
Is there a tool that does all that (together with zipping/unzipping *.w, *.p and *.i files), or do I need to create such a tool myself?
In the latter case, what are the commandline commands for the mentioned actions:
Take a dump (*.df) of the current database
Upload modifications to the database (*.df files)
compile *.w and *.p files.
If you're familiar with ANT, the take a look at the PCT plugin for ANT:
https://github.com/Riverside-Software/pct
This makes is easy to create a delta.df file between the "new" full DF and the current database, e.g.:
<PCTDumpIncremental destFile="temp/delta.df" dlcHome="${dlc}"
debugLevel="2" activeIndexes="0" removeEmptyDFFile="true" msgBufferSize="${Mm}" >
<SourceDB dbname="temp/ref-SmartDB" singleUser="true" />
<TargetDB dbname="${smartdb}" dbDir="${smartdbdir}" singleUser="${smartdbsingleuser}"/>
</PCTDumpIncremental>
and then load the delta.df into the current application DB:
<PCTLoadSchema srcFile="temp/delta.df" dlcHome="${dlc}" onlineChanges="true" callbackClass="rssw.pct.AbstractLoadCallback" msgBufferSize="${Mm}" commitWhenErrors="false">
<DBConnectionSet refid="smartdbset" />
</PCTLoadSchema>
and then compile the application:
<PCTCompile destDir="${installroot}" graphicalMode="true" dlcHome="${dlc}"
md5="true" minSize="false" cpinternal="${cpinternal}" cpColl="${cpcoll}" cpstream="${cpstream}"
compileUnderscore="true" inputchars="32000" baseDir="${installroot}"
token="4000" progPerc="10" assemblies="${assemblies}">
<fileset dir="${installroot}" casesensitive="false">
<include name="Ccs/**/*.cls"/>
<include name="Consultingwerk/**/*.cls"/>
<include name="Consultingwerk/**/*.p"/>
<include name="Consultingwerk/**/*.w"/>
<include name="Setup/**/*.p"/>
<include name="src/**/*.p"/>
</fileset>
<propath>
<pathelement path="${installroot}/." />
<pathelement path="${installroot}/src" />
<pathelement path="${installroot}/Consultingwerk/Studio/ProdictDumpHack/src" />
<pathelement path="${dlc}/gui/netlib/OpenEdge.Net.pl" />
</propath>
<DBConnectionSet refid="smartdbset" />
</PCTCompile>
ANT and PCT are included in OpenEdge from 11.7 on. Since you're on 11.6, you'll have to bring your own ANT and PCT.

How to convert an ant snippet to Gradle

Hi I am completely new to Gradle. Can anyone please help me as to how I can convert this ant task into Gradle. I am trying to see if I can learn by example.
<property file="build.properties"/>
<path id="classpath">
<fileset dir="${ear.dir}/EarContent/APP-INF">
<include name="**/*.jar" />
</fileset>
</path>
<target name="clean">
<delete file="${dist.dir}/*.jar" failonerror="false"/>
<delete failonerror="false">
<fileset dir="${build.dir}">
<include name="**/*.class" />
</fileset>
</delete>
</target>
<target name="init">
<mkdir dir="${dist.dir}"/>
<mkdir dir="${build.dir}/classes"/>
</target>
<target name="jar" depends="clean, init">
<javac srcdir="${src.dir}" destdir="${build.dir}/classes" debug="on">
<classpath refid="classpath"/>
</javac>
<jar destfile="${dist.dir}/phIntegration.jar">
<fileset dir="${build.dir}/classes" />
</jar>
</target>
I'm not convinced that trying move ANT build 1-1 to Gradle is a good learning exercise, although Gradle provides good integration with ANT.
Generally speaking, the build.gradle file for your project shall like somewhat like that:
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'CLASSPATH_DIR', include: ['**/*.jar'])
//if you want you can use JARS from your filesystem as a classpath
//but you probably should use Ivy or Maven dependency management systems
}
sourceSets {
main {
java 'src/main/java'
//tweak the location of your source code, by default Gradle looks for sources in `src/main/java`
}
}
Once you invoke gradle clean build it will compile your sources and create a jar file containing the sources in build/libs directory. You can change the JARS name by adding the rootProject.name='your project name' in the settings.gradle directory.
The snippet uses Java plugin and the default behaviour of Gradle. If you want you can tweak its behaviour by using Delete Task or Jar Task.
If you define properly inputs/outputs of a task the init task won't be necessary since Gradle will take care of directories recreation if they're not existent. (Default tasks do that, if you start writing your own tasks you most probably will have to take care of that by your own)

srcdir attributes must be set

Im trying to migrate my code from ant to gradle and imported my build.xml in build.gradle and some of my tasks work fine.
However there are some tasks when i run them it says
Execution failed for task ':compile'.
srcdir attribute must be set!
Pasting a snippet of my Build.xml and the compile task below is failing.
<project basedir="." default="deploy" name="FitNesse">
<property name="fitnesse.target" value="/build/test-fitnesse"/>
<patternset id="test.patternset">
<include name="**/*Test*.java"/>
</patternset>
<propertyset id="test.propertyset">
<propertyref name="basedir"/>
<propertyref name="test.patternset"/>
</propertyset>
<fileset id="classpath.fitnesse" dir="./libs">
<include name="antlr-2.7.7.jar"/>
<include name="asm-4.1.jar"/>
<include name="asm-analysis-4.1.jar"/>
<include name="asm-commons-4.1.jar"/>
<include name="asm-tree-4.1.jar"/
><target name="compile" description="Compile java sources" depends="clean">
<mkdir dir="build/classes"/>
<javac includeantruntime="false"/>
<javac srcdir="src/main/java" destdir="build/classes" debug="on">
<classpath refid="classpath.compile"/>
<compilerarg value="-processorpath"/>
<compilerarg value="-AmethodConstraintsSupported=true"/>
</javac>
</target>
Source folder structure
/src/main/java/com/xebia/inc/xeb
I had changed my src folder structure from ant "src" to a gradle project "/src/main/java/com/xebia/incubator/xebium". and lib folder to libs
Please help. I'm kind of novice to this.
Thanks,
The full error message should give you the line number and it's most probably the line that contains
<javac includeantruntime="false"/>
which looks like a copy-paste error.

Maven / IDEA setting the Resource patterns

My project is using Maven to compile both Java and Groovy classes.
My project compiles and builds just fine using maven but I would like IDEA (IntelliJ) to build it correctly as well. I use maven to generate the IDEA project file with the following command:
mvn idea:idea
I noticed it doesn't build the groovy files, only the java files.
I found out the issue was that by default IDEA was considering all the files not having a .java extension as resources.
When I generate the project file with the maven IDEA plugin I get the following in the ipr file
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
</wildcardResourcePatterns>
...
I have to modify it this way in order to have my groovy files compiling (and few others kind of files):
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
</wildcardResourcePatterns>
...
Note: this information can be found/edited as well in IDEA -> Settings -> Compiler -> Resource patterns
I can generate it correctly using the following command:
mvn idea:idea -DwildcardResourcePatterns="!?*.java;!?*.groovy;"
Does anyone know how to configure this in the pom.xml?
This need to be added in the pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-idea-plugin</artifactId>
<configuration>
<wildcardResourcePatterns>!?*.java;!?*.groovy;</wildcardResourcePatterns>
</configuration>
</plugin>

How do I create a ZIP file of my Cruise Control builds?

I use CruiseControl.NET to automatically build my .NET 3.5 web applications, which works a treat. However, is there any way to automatically create a ZIP file of these builds, and put the ZIP's into a separate directory?
I have seen this is possible using NAnt but cannot find an example of how to get this working.
Can anyone offer help/examples?
I've just added such a Nant task to our CC machine.
See http://nant.sourceforge.net/release/latest/help/tasks/zip.html
Note when initially viewing the zip archive, it may appear as if all the files are at the same level, i.e no folders, but actually they folders are preserved.
Notice how you can exclude file types or folders.
You could take the approach of only including the file types you want and excluding the rest.
First define properties for where the source files are allcode.dir and the name and location of the zip file sourcebackup.zip
Now here is the nant task
<zip zipfile="${sourcebackup.zip}" includeemptydirs="true" verbose="true">
<fileset basedir="${allcode.dir}">
<include name="**/*" />
<exclude name="**/_resharper*/**" />
<exclude name="**/build/**" />
<exclude name="**/obj/**" />
<exclude name="**/bin/**" />
<exclude name="**/*.dll" />
<exclude name="**/*.scc" />
<exclude name="**/*.log" />
<exclude name="**/*.vssscc" />
<exclude name="**/*.suo" />
<exclude name="**/*.user" />
<exclude name="**/*.pdb" />
<exclude name="**/*.cache" />
<exclude name="**/*.vspscc" />
<exclude name="**/*.msi" />
<exclude name="**/*.irs" />
<exclude name="**/*.exe" />
</fileset>
<echo message="########## Zipped##########" />
Call this from your cc build like any other nant task.
We find it best if each CC project calls a single task if possible, then you only have to change the nant script, and you can run the nant script on your local machine.
Eg in the project block, we have the single target "build", which as part of its work calls ZipSource
<targetList>
<target>Build</target>
</targetList>
We use the above for a BizTalk project.
Enjoy.
If you're using Nant, then doesn't the Zip task work for you?
We are zipping the sources of a CruiseControl.NET project
but we are using ant
<target name="zipProject">
<mkdir dir="output"/>
<zip destfile="output\sources.zip" basedir="C:\project\src" />
</target>
i don't know about nant but i would expect it to be similar
#David: The NAnt Zip task is what I'm after, yes, but I'm asking how to integrate it as part of an automatic CruiseControl.NET build. If you take a look at the NAnt documentation for the cruise control config it doesn't make it clear if I can run an NAnt task from inside the <tasks> XML node in my CruiseControl config - it only says that it can be part of a <schedule>.
I have found a few examples of setting up your CruiseControl config and a few examples of NAnt tasks but nothing that integrates the two: specifically, zipping up a CruiseControl build.
If anyone has some sample XML of their CruiseControl config, hooking up to an NAnt zip task, post samples here.
Cheers.

Resources