How to setup xampp, phpunit, ant, zend framework - zend-framework

First post here, so take it easy please.
I'm working through the first chapter of Zend Framework 1.8 Web Application Development by Keith Pope in an effort to learn PHP and the MVC framework.
I thought I included all the paths correctly and installed PHPUnit 3.3 correctly as well as Zend 1.8 and 1.7.4 Xampp. with Ant version 1.8.2. However, I can't seem to get the first simplest build to build.
From looking at other q's and a's on this site I can tell some of the calls in the build.xml file for PHPunit aren't correct and I've tried to correct them, but now I'm getting the error that C:\xampp\htdocs\zendStoreFront/library/Zend does not exist and when I add the Zend directory in I get lots and lots of errors which is telling me that's probably not the right answer.
I understand there's a lot going on in the whole project and I'm willing to take the time to learn, but one question- On the line that says " --log-xml ${basedir}/build/logs/phpunit.xml ", is this file expected to be in this directory already, or does the build process create the file? On some attempts an error that's echo'd back say that file doesn't exist and currently there is no file in that directory.
Thanks,
hestes
cmd line output
*****************
C:\xampp\htdocs\zendStoreFront\build>ant
Buildfile: C:\xampp\htdocs\zendStoreFront\build\build.xml
buildPreparation:
getProps:
[echo] ---- Build Properties ----
[echo]
[echo] OS is Windows XP
[echo] Basedir is C:\xampp\htdocs\zendStoreFront
[echo] Property file is C:\xampp\htdocs\zendStoreFront/build/ant.properties
[echo] Script-suffix is .bat
[echo]
[echo] ---- Storefront Properties ----
[echo]
[echo] Environment is development
configure:
[copy] Copying 1 file to C:\xampp\htdocs\zendStoreFront\application
test:
[exec] The filename, directory name, or volume label syntax is incorrect.
[exec] PHPUnit 3.3.10 by Sebastian Bergmann.
[exec]
[exec] C:\xampp\htdocs\zendStoreFront/library/Zend does not exist
BUILD FAILED
C:\xampp\htdocs\zendStoreFront\build\build.xml:28: exec returned: 1
Total time: 1 second
C:\xampp\htdocs\zendStoreFront\build>cd ..
C:\xampp\htdocs\zendStoreFront>ant -version
Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Build.xml File
<target name="getProps">
<property file="${basedir}/build/ant.properties" />
<condition property="script-suffix" value=".bat" else="">
<os family="windows" />
</condition>
<echo message="---- Build Properties ----" />
<echo message="" />
<echo message="OS is ${os.name}" />
<echo message="Basedir is ${basedir}" />
<echo message="Property file is ${basedir}/build/ant.properties" />
<echo message="Script-suffix is ${script-suffix}" />
<echo message="" />
<echo message="---- Storefront Properties ----" />
<echo message="" />
<echo message="Environment is ${environment}" />
</target>
<target name="test" depends="getProps">
<exec dir="${basedir}/tests" executable="phpunit${script-suffix}" failonerror="true">
<arg line="--colors --coverage-html ${basedir}/build/report
--log-xml ${basedir}/build/logs/phpunit.xml
--log-pmd ${basedir}/build/logs/phpunit.pmd.xml
--log-metrics ${basedir}/build/logs/phpunit.metrics.xml
--coverage-clover ${basedir}/build/logs/phpunit.coverage.xml
AllTests.php"/>
</exec>
</target>
<target name="configure" depends="getProps">
<copy file="${basedir}/application/application.php.dist"
tofile="${basedir}/application/application.php" overwrite="true" />
<replace file="${basedir}/application/application.php" token="#ENVIRONMENT#" value="${environment}" />
</target>
<target name="buildPreparation">
<mkdir dir="${basedir}/build/logs" />
<mkdir dir="${basedir}/build/report" />
</target>
<target name="clean">
<delete dir="${basedir}/build/logs" />
<delete dir="${basedir}/build/report" />
</target>
<target name="build" depends="buildPreparation,configure,test"/>

Related

Use a phing ForEach loop to execute tasks

I want to execute an arbitrary selection of tasks in a Phing build.
I'm passing in a list of modules for building. Each module is of a particular type. The type is specified in the name, as {type}_{unitname}. I started with a build file that took a single module name and built it, that works fine. I now want to pass in a list of modules and have it build all of them. (What I'd really like to do is load the list of modules from an XML manifest file, but perhaps one thing at a time).
I've tried multiple ways and have found a problem with each.
I seem to need an ad-hoc task to derive my properties (task and related directory settings) from the module name. This seems to cause problems, but not at first.
At first I tried to use the loop variable as the target
<foreach list="${mylist}" param="item" target="${item"} />
but it doesn't seem to allow a variable as a target name. So I split it up into two tasks.
<foreach list="${parts}" param="dTarg" target="doIt" >
<task name="DoIt">
<phingcall target="build">
<property name="extension" value="${dTarg}" />
</phingcall -->
</task>
My problem here is (I think) "extension" is a constant and thus can't be overwritten. I tried using "var", which the docs say is a thing, but my setup complains it doesn't exist. Is it a 3.0 feature? I'm running 2.17.
So I tried changing the "phingcall" to "phing" and put my main functionality in a separate file. Here I run into problems with the ad-hoc task again. If I put it in the "subordinate" file, it complains that's it's re-declared (I think, the message isn't very helpful) when the file is called a second time. If I leave it in the main file, the subordinate file can't find it, even with inheritrefs and inheritall set.
How can I execute tasks whose names are in list?
At first I tried to use the loop variable as the target
<foreach list="${mylist}" param="item" target="${item"} />
but it doesn't seem to allow a variable as a target name
The target attribute of the foreach task is able to use variables as a value, but at this point param="item" is not yet available but in the target it is.
So I split it up into two tasks.
<foreach list="${parts}" param="dTarg" target="doIt" >
<task name="DoIt">
<phingcall target="build">
<property name="extension" value="${dTarg}" />
</phingcall>
</task>
Here you try to use a task task which is simply not a valid target.
What you want to do instead is to have targets to iterate over. The following example demonstrates the usage:
Input build.xml
<?xml version="1.0" encoding="utf-8" ?>
<project name="test" default="main">
<property name="mylist" value="A,B,C" />
<target name="main">
<foreach list="${mylist}" param="item" target="DoIt"/>
</target>
<target name="DoIt">
<echo>${item}</echo>
</target>
</project>
Output
test > main:
test > DoIt:
[echo] A
test > DoIt:
[echo] B
test > DoIt:
[echo] C
BUILD FINISHED
Complex Example (with property override and inheritAll)
<?xml version="1.0" encoding="utf-8" ?>
<project name="test" default="main">
<property name="mylist" value="A,B,C" />
<target name="main">
<foreach list="${mylist}" param="item" target="DoIt"/>
</target>
<target name="DoIt">
<phingcall target="${item}" inheritAll="true">
<property name="extension" override="true" value="${item}-ext" />
</phingcall>
</target>
<target name="A">
<echo>Inside target ${item} with ${extension} extension</echo>
</target>
<target name="B">
<echo>Inside target ${item} with ${extension} extension</echo>
</target>
<target name="C">
<echo>Inside target ${item} with ${extension} extension</echo>
</target>
</project>
Output
test > main:
test > DoIt:
test > A:
[echo] Inside target A with A-ext extension
test > DoIt:
test > B:
[echo] Inside target B with B-ext extension
test > DoIt:
test > C:
[echo] Inside target C with C-ext extension
BUILD FINISHED
Example execute as one task with changed values from the list
<?xml version="1.0" encoding="utf-8" ?>
<project name="test" default="main">
<property name="mylist" value="A,B,C" />
<target name="main">
<foreach list="${mylist}" param="item" target="DoIt"/>
</target>
<target name="DoIt">
<phingcall target="build">
<property name="extension" override="true" value="${item}-ext" />
</phingcall>
</target>
<target name="build">
<echo>Inside target build with ${extension}</echo>
</target>
</project>
Output
test > main:
test > DoIt:
test > build:
[echo] Inside target build with A-ext
test > DoIt:
test > build:
[echo] Inside target build with B-ext
test > DoIt:
test > build:
[echo] Inside target build with C-ext
BUILD FINISHED
Simplified and final build
<?xml version="1.0" encoding="utf-8" ?>
<project name="test" default="main">
<property name="mylist" value="A,B,C" />
<target name="main">
<foreach list="${mylist}" param="item" target="build">
<property name="extension" override="true" value="${item}-ext" />
</foreach>
</target>
<target name="build">
<echo>Inside target build with ${extension}</echo>
</target>
</project>
Output
test > main:
test > build:
[echo] Inside target build with A-ext
test > build:
[echo] Inside target build with B-ext
test > build:
[echo] Inside target build with C-ext
BUILD FINISHED

ant Sending email using does not work, without any error message [duplicate]

This question already has an answer here:
Getting error message "java.lang.ClassNotFoundException: javax.mail.internet.MimeMessage" while executing ant mail task
(1 answer)
Closed 6 years ago.
I'm using this ant script in order to send email:
<target name="install-jars" description="Install ANT optional jars">
<mkdir dir="${user.home}/.ant/lib" />
<get dest="${user.home}/.ant/lib/mail.jar"
src="http://search.maven.org/remotecontent?filepath=javax/mail/mail/1.4.4/mail-1.4.4.jar" />
<get dest="${user.home}/.ant/lib/activation.jar"
src="http://search.maven.org/remotecontent?filepath=javax/activation/activation/1.1/activation-1.1.jar" />
</target>
<tstamp>
<format property="TODAY_US" pattern="dd-MM-yyyy" locale="en,IL" />
</tstamp>
<copy todir="T:/Ali/backup/reports/AutoAccess_337/${TODAY_US}">
<fileset dir="log/current" />
</copy>
<target name="notify" description="notify team">
<mail mailhost="SRVSMTP" subject="latest deployment">
<from address="ali.t#ab.com" />
<to address="ali.t#ab.coml" />
<message>A new build has been pushed out to prod</message>
</mail>
</target>
for some reason Mail is not sent, with no any error message,
any suggestions.
After investigating the problem deeply:
I added two jar files into ant lib directory, in my case and because I'm executing ant from eclipse, I checked ant home value by navigate to: (Window >> Preferences >> Ant >> RunTime >> Classpath >> Ant Home Entries).
After that I added mail.jar and Activation.jar files to lib directory under Ant home directory.
this fixed the issue.
Br,
Ali

How to copy assets to build folder in FDT?

Flash Builder has an option to "Copy non-embedded files to output folder", which will copy resources loaded at runtime / not compiled into the application from source folders into the /bin-debug (build) folder.
How can I do this with FDT? Do I have to use an Ant task? If so -- I'm not familiar with Ant, how would I set this up?
I guess Ant's not so hard...the following did the trick:
<project default="copy">
<property name="from" value="./assets"/>
<property name="to" value="./bin/assets"/>
<target name="copy">
<echo message="Copying assets..."/>
<copy todir="${to}" >
<fileset dir="${from}"/>
</copy>
</target>
And I ran it via a Debug Configuration:

Using eclipse in order to find the opencv native library doesn't work

I'm attempting to use opencv on an ubuntu installation and am following this tutorial. Everything seemed fine and it even listed amongst the installed parts so I proceeded into this tutorial. This went well up until the moment where you have to add opencv as a user library as it was not amongst the (completely empty) list of libraries found. I have looked throughout the opencv folder and can't find anything like a library either am I missing something? Any idea on how to fix this?
Note that it did manage to produce .jar file however the library is still missing. If it matters opencv is installed in usr/local/src.
If in order fix this you require any extra information feel free to ask in the comments.
This might have something to do with the problem:
ulap:/usr/local/src/opencv-2.4.8/opencv/build/bin$ ant -DocvJarDir=path/to/dir/containing/opencv-248.jar -DocvLibDir=/usr/local/src/opencv-2.4.8/opencv/build/bin /opencv_java248/native/library
Buildfile: /usr/local/src/opencv-2.4.8/opencv/build/bin/build.xml
BUILD FAILED
Target "/opencv_java248/native/library" does not exist in the project "SimpleSample".
Total time: 0 seconds
thijs#thijs-ulap:/usr/local/src/opencv-2.4.8/opencv/build/bin$ ant -DocvJarDir=path/to/dir/containing/opencv-248.jar -DocvLibDir=/usr/local/src/opencv-2.4.8/opencv/build/bin /opencv_java248/native/library
Buildfile: /usr/local/src/opencv-2.4.8/opencv/build/bin/build.xml
BUILD FAILED
Target "/opencv_java248/native/library" does not exist in the project "SimpleSample".
Total time: 0 seconds
This is my build.xml:
<property name="src.dir" value="src"/>
<property name="lib.dir" value="${ocvJarDir}"/>
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="${build.dir}/jar"/>
<property name="main-class" value="${ant.project.name}"/>
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<target name="compile">
<mkdir dir="${classes.dir}"/>
<javac includeantruntime="false" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
</target>
<target name="jar" depends="compile">
<mkdir dir="${jar.dir}"/>
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
</jar>
</target>
<target name="run" depends="jar">
<java fork="true" classname="${main-class}">
<sysproperty key="java.library.path" path="${ocvLibDir}"/>
<classpath>
<path refid="classpath"/>
<path location="${jar.dir}/${ant.project.name}.jar"/>
</classpath>
</java>
</target>
<target name="rebuild" depends="clean,jar"/>
<target name="rebuild-run" depends="clean,run"/>
running
ulap:/usr/local/src/opencv-2.4.8/opencv/samples/java/ant$ ant -DocvJarDir=/usr/local/src/opencv-2.4.8/opencv/build/bin rebuild-run
gave me:
clean:
compile:
[mkdir] Created dir: /usr/local/src/opencv-2.4.8/opencv/samples/java/ant/build/classes
[javac] Compiling 1 source file to /usr/local/src/opencv-2.4.8/opencv/samples/java/ant/build/classes
jar:
[mkdir] Created dir: /usr/local/src/opencv-2.4.8/opencv/samples/java/ant/build/jar
[jar] Building jar: /usr/local/src/opencv-2.4.8/opencv/samples/java/ant/build/jar/SimpleSample.jar
run:
[java] Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java248 in java.library.path
[java] at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
[java] at java.lang.Runtime.loadLibrary0(Runtime.java:844)
[java] at java.lang.System.loadLibrary(System.java:1051)
[java] at SimpleSample.<clinit>(Unknown Source)
[java] Could not find the main class: SimpleSample. Program will exit.
[java] Java Result: 1
rebuild-run:
BUILD SUCCESSFUL
Total time: 1 second
According to the first tutorial (how to build OpenCV from source), the result should be a JAR file and a .so native lib in the bin/ directory of your OpenCV directory. In the "SETTING UP ECLIPSE FOR USING OPENCV (JAVA) IN UBUNTU" tutorial, you must create the User Library by following the steps in the tutorial. That process involves browsing your file system to select the OpenCV JAR that was produced by the first tutorial and then selecting the .so file as the native library. Eclipse will not automatically "find" your OpenCV library, you have to configure it to know about it, that's what the second tutorial is doing.
I think you were running the wrong command with ant. You can read the manual here: https://ant.apache.org/manual/running.html
Below is the format to run ant:
ant [options] [target [target2 [target3] ...]]
So maybe your command line should look like:
ant -DocvJarDir=/usr/local/src/opencv-2.4.8/opencv/build/bin rebuild-run
given that /usr/local/src/opencv-2.4.8/opencv/build/bin contains the opencv-248.jar
As shown on your build.xml file that the property ocvJarDir is pointing to the location of the classpath requires to build the project:
<property name="lib.dir" value="${ocvJarDir}"/>
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
And you need to specify the target "rebuild-run" in the command line since your build.xml does not have a default target specified.
Try installing 2.4.6 version. I have similar problems when installing in VS. Older version worked. Maybe it's the same in Eclipse, too.

NAnt + Project with GUID must be included

I just started using NAnt today, I followed some of the examples. I am having a hard time with one issue:
Its saying: "Project with GUID '{32845370-6F32-411F-B4C5-383F9C3EDE29}' must be included for
the build to work."
Now I was able to track down the project. Here is my directory structure:
c:\dev\stockclockbuild -> this is where the solution and build file is located.
So I run the command:
nant -buildfile:c:\dev\stockclockbuild\stocks.build
I have a project that it located in c:\dev\_sharedlibs\mdrlibs called "MDR.StockPlatform" which seems to get included, but within that project file I found the project (dependency) that has the GUID mentioned in the error.
That project is called "MDR.Base" but its located in the same folder as MDR.StockPlatform.
Also if I were to open this solution and build it in visual studio it builds without errors.
Here is the complete verbose output:
c:\Dev\_Misc\Tools\nAnt\bin>nant -buildfile:c:\dev\stockclockbuild\stocks.build
NAnt 0.92 (Build 0.92.4543.0; release; 6/9/2012)
Copyright (C) 2001-2012 Gerry Shaw
http://nant.sourceforge.net
Buildfile: file:///c:/dev/stockclockbuild/stocks.build
Target framework: Microsoft .NET Framework 4.0
Target(s) specified: rebuild
clean:
build:
build.stockclock:
[solution] Starting solution build.
[solution] Loading projects...
[solution] Loading project 'c:\dev\stockclockbuild\StockClock.Common\StockClock
.Common.csproj'.
[solution] Using MSBuild version 4.0.30319.1.
[solution] Loading referenced project 'c:\dev\_SharedLibs\MDRLibs\MDR.StockPlat
form\MDR.StockPlatform.csproj'.
BUILD FAILED
Project with GUID '{32845370-6F32-411F-B4C5-383F9C3EDE29}' must be included for
the build to work.
Total time: 0.6 seconds.
Here is a copy of the build file:
<project name="Solution Build Example" default="rebuild">
<property name="configuration" value="release"/>
<target name="clean" description="Delete all previously compiled binaries.">
<delete>
<fileset>
<include name="**/bin/**" />
<include name="**/obj/**" />
<include name="**/*.suo" />
<include name="**/*.user" />
</fileset>
</delete>
</target>
<target name="build" description="Build all targets.">
<call target="build.stockclock"/>
</target>
<target name="rebuild" depends="clean, build" />
<target name="build.stockclock">
<solution configuration="${configuration}" solutionfile="Stockclock.sln" verbose="true">
</solution>
</target>
</project>
I'm assuming you're using a modern IDE, and from the NAnt Documentation:
Note: Right now, only Microsoft Visual Studio .NET 2002 and 2003 solutions and
projects are supported. Support for .NET Compact Framework projects is also not
available at this time.
In my NAnt scripts I use the NauckIT MSBuild task:
<msbuild projectFile="${solution.file}" targets="Build" verbosity="Quiet">
<property name="Configuration" value="${build.configuration}" />
<property name="Platform" value="${build.platform}" />
<arg value="/flp:NoSummary;Verbosity=normal;LogFile=${build.log}" />
<arg value="/p:SignAssembly=true" if="${isReleaseBuild}" />
<arg value="/p:AssemblyOriginatorKeyFile=${solution.keyfile}" if="${isReleaseBuild}" />
<arg value="/p:DelaySign=false" if="${isReleaseBuild}" />
</msbuild>
However that is a personal preference as you could also use the NAnt exec task and call msbuild directly.